Monitoring mice in their home cage
14 Feb 2014[Aug 4, 2014, updated] [March 2015, moved to cudmore.github.io]
Goal
- videotape mice in their home cage.
Parts
Computer
- Raspberry Pi, Model B 512MB RAM, [Adafruit 998](http://www.adafruit.com/products/998) target="_blank">Adafruit 998</a>
- 4 GB SD Card, Adafruit 102
- USB 2 Wifi Dongle (802.11b/g/n), Adafruit, 814
- USB 2 Powered Hub, 5V 2A, Adafruit, 961
- USB 2 hard-drive, Old laptop drive with a SATA to USB 2 connector
- 5V 1A AC to DC converter, Adafruit, 501
Video
- Raspberry Pi NoIR camera, Adafruit, 1567
- 12" flex cable for Raspberry Pi NoIR Camera, Adafruit, 1648 (24", Adafruit 1731)
- 4x Right-angle 1/2" post clamps, Newport CA-1
- Mini Ball Head, B&H Giottos MH1004
- 1/2" hollow aluminum tubes, these are cheap and easily cut with hack-saw, Home Depot
Lights
- 2x LED Driver, 12VDC 700 MA, SuperBrightLeds, CCD-700
- 4x LED PCB, SuperBrightleds, MLED-PCB, 84778101387
- 2x Mosfet PCB, Sparkfun, COM-10256
- LED - Super Bright White (25 pack)
- LED - Infrared 850nm (25 pack), Sparkfun COM-09854
- LED - Infrared 950nm (25 pack), Sparkfun COM-10557
- 2x LED Light Bar - White (SMD), Sparkfun, COM-12014
- Light Holders, 25 lb circular magnets, 3 foot threaded rods, screws, washers (Ace Hardware)
Running Wheels
- Empty running wheels from Med Associates (find cheaper solution)
- 2 Hall Effect sensors per wheel (Optek/TT O090U), Mouser 828-OH090U
Miscellaneous Sensors
- Visible light sensor (Vishay, TEPT5600), Mouser 782-TEPT5600
- IR sensor (Vishay BPW83), Mouser 782-BPW83
- Temperature and Humidity Sensor (AM2302 wired DHT22), Adafruit 393
Acquisition Software (Python scripts running in Pi)
Script 1:
- Acquires sequential 5 minute videos and save each to a timestamped .h264 file.
Script 2:
- Turns IR and White lights on and off, uses time-of-day from Raspberry Linux.
- Reads from IR and visible light sensors to check light levels and sends an email if either IR or white lights burn out.
- Reads temperature and humidity.
- Reads wheel turn events using low level GPIO callbacks to get more accurate time.
- Logs all of this to text file locally on Raspberry.
- Pushes all of this to online web server so I can check if the mice have been running.
Remote webserver has a PHP script to accept and save name/value pairs of data. Now using mySQL on external web server.
Software Analysis
- Python/OpenCV motion detection using a modified version of this (Thanks to Derek Simkowiak). Motion detection does not run on Pi, runs offline on desktop/laptop (OS X)
- In future, write in C++/OpenCV using this.
- How to install Python/OpenCV/ffmpeg on OSX
- Another project to monitor a hamster in their cage, the hamster party-cam (from the Raspberry people).
=====================================================================
Wish List
Sensors
Temperature and Humidity sensor, Adafruit, 393, $15Upgrade temperature/humidity to something like, Adafruit 1293, $30, no tutorials 2/14/14
Camera Holder
Right-angle 1/2" post clamps, Thor Labs, RA90 (google image search for 'Right Angle Clamp rod'). Will order Newport right-angle post clamp, Newport CA-1. In general, it seems that any kind of post system with clamps, junctions, and T's triples in price as soon as the post/rod diameter goes below 1/2". Because I need many of these post clamps, 3-4 for camera and 3-4 for lights) I will stick with the 1/2" variety. My choice to go with Newport is based on this comment.1/2" aluminum OR wood tubes/dowels12" flex cable for Raspberry Pi NoIR Camera, Adafruit, 1648
=====================================================================
Notes
Temp/Humidity Sensor (DHT22) spits out readings once per second (fine) and does it fast (not fine). On Raspberry Pi this requires some C code to read ‘bit-banged’ sensor output. See Adafruit.
The AM2315 is a more accurate temperature/humidity sensor, and data comes in via I2C. This particular sensor has a fixed address.
The Pi NoIR camera is just the standard Pi camera with the IR filter removed. Right now there are no detailed specs on the nm sensitivity of the NoIR camera, the IR filter or the original camera for that matter. According to the Embedded Linux Wiki, the Pi NoIR camera has a CMOS Omnivision 5647 CMOS chip. Also see the pdf spec/ad sheet. Aphesa has some pretty in depth discussion of the spectral response properties of silicon image sensors.
I tried 950nm LEDs and got a pretty grainy video, I switched to 850 nm LEDs and the image is brighter and less grainy (as expected). In both these cases, the camera is about 20” from subject and IR lights are off to the left and right, 4 LEDs on the left and 4 LEDs on the right. See this discussion and here for a guess at the spectral sensitivity.
-Try -night switch for video with IR LEDs.
-Raspberry Control, a general purpose Android based Raspberry Pi Controller.
Camera board has 2mm screw holes, see Gert’s drawings.