##Purpose
A Raspberry Pi computer and camera to continuously record video of small animals in their cage.
- Records video in 5 minute chunks, saving .h264 files into video/ folder.
- Turns white light on during the day, 6 AM to 6 PM
- Turns IR light on during the night, 6 PM to 6 AM
- Optionally records temperature every 30 seconds (is this correct? Seems too much?)
- Listens for triggering of 4 magnetic hall sensors (2 per wheel) and records to file.
All events are logged to files saved in the video/ folder. The name of the log file is timestamp for the date and time for when the code is started. For example, YYYYMMDD_HHMMSS.txt.
See this post to install a base Raspian system on a Raspberry Pi.
We need to use screen
so the code continues to run even after the pi user logs out.
sudo apt-get install screen
All code is written in Python using widely used libraries. Most of these Python libraries should already be installed by default. If libraries are missing, here are the required libraries.
RPi.GPIO
picamera
Adafruit_DHT # requires install
To use a DHT22 temperature sensor, install the Adafruit_DHT library.
git clone https://github.com/cudmore/homecageactivity.git
cd homecageactivity
screen
python video.py
#exit screen with ctrl+a then d
screen
python testhome.py
#exit screen with ctrl+a then d
#login as user pi using ssh
#screen -r #gives a list of your two screen session
screen -r xxx #to return to the first screen
screen -r xxx #to return to the second screen session
The Python code can be stopped with ctrl+c
.
Pin | Goes To |
---|---|
8 | 5V Relay channel 1 (white light) |
7 | 5V Relay channel 2 (IR light) |
| |17 |DHT22 Temperature/Humidity Sensor | |23 |Wheel 1, sensor 1 |24 |Wheel 1, sensor 2 |14 |Wheel 2, sensor 1 |15 |Wheel 2, sensor 2
This image is oriented as if pins on Raspberry Pi are in the top-left corner.
Item | Cost | Link |
---|---|---|
Raspberry Pi Model B+/2/3 | $35 | mcm electronics |
5V >2A AC/DC Adapter | $6 | mcm electronics |
16GB SD Card (class 10) | $8 | amazon |
| |Raspberry Pi NoIR Camera (5MP or 8MP) |$30 |adafruit |>1 meter ribbon cable for camera |$3 |adafruit | |SainSmart 5V relay (2 channels) |$10 |sainsmart or amazon |IR LEDS (make sure they are less than 900 nm) |$1.15 |link |White LED (single led or strip) |$1 or $5 |sparkfun single or mouser strip | |Low Profile Non Counting Running Wheels (Med Associates, ENV-044-02) | | link |4x hall effect sensors |$1 |link |4x 660 Ohm resistors (gold/brown/blue/blue) | |DHT22 Temperature and Humidity Sensor |$10 or $2.50 |adafruit or ali express | |128 GB USB Stick (Sandisk ultra USB3) |$28 |b&h |Wood or 80/20 parts to build frame |Something to hold camera | | |Total $150 |
- Done: Get rid of all reference to sql crap including bobsql. Just save everyhting in a local file.
- Write simple plotting and analysis functions
- Wrap code in web interface (video.py and home.py should be two seperate processes)
- 20160705 Rebuilding the system for Valerie. I erased the SD card on original Raspbery when installing Trigger Camera on Pi 3 for Zeng You. Copied from robertcudmore.org/raspberry/raspberrycam2/homecage.