Overview: Required libraries

  • Wiring Pi - Library that provides a command line interface to the GPIO pins. This should be installed by default.
  • GPIO - Python library to control GPIO pins.
  • picamera - Python library to control the camera.
  • flask - A python web server.
  • Adafruit_DHT - (optional) Python library to read from a DHT temperature and humidity sensor.
  • uv4l - Command line tool for live video streaming to a web browser.
  • avconv - Command line tool to convert video files.

1) Get a functioning Raspberry Pi

These instructions assume you have a functioning Raspberry Pi. To get started setting up a Pi from scratch, see our setup intructions.

2) Clone the repository

This will make a folder homecage in your root directory. You can always return to your root directory with cd

# if you don't already have git installed
sudo apt-get install git

git clone

3) Install python libraries

# if you don't already have pip installed
sudo apt-get install python-pip

pip install rpi.gpio
pip install flask
sudo pip install flask-cors # not sure why sudo is needed?

# if you run into errors then try installing
sudo apt-get install build-essential python-dev python-openssl

4) Install uv4l for live video streaming (optional)

If you run into trouble, then follow this tutorial.

curl | sudo apt-key add -

# add the following line to /etc/apt/sources.list
# start editor with `sudo pico /etc/apt/sources.list`
deb stretch main

sudo apt-get update
sudo apt-get install uv4l uv4l-raspicam uv4l-server

5) Install avconv to convert videos from .h264 to .mp4

If you run into trouble, then see this blog post.

sudo apt-get update
sudo apt-get install libav-tools

Video files will be saved to /home/pi/video. This can be changed in the web server configuration file homecage/homecage_app/config.json. If your going to save a lot of video, please mount a usb key and save videos there.

6) Install DHT temperature sensor (optional)

If you run into trouble then go to this tutorial.

mkdir tmp
cd tmp
git clone
cd Adafruit_Python_DHT
sudo python install

7) Start the web server at boot (optional)

Edit crontab

crontab -e

Add the following line to the end of the file (make sure it is one line)

@reboot (sleep 10; cd /home/pi/homecage/homecage_app && /usr/bin/python /home/pi/homecage/homecage_app/

Done installing !!!

At this point you can interact with the homecage either through the web or from the command line.