Python 2.7 software for Raspberry Pi based camera.
A wiring diagram can be found in the /doc folder. Here is a list of the main items.
- Raspberry Pi Model A+
- Raspberry Pi Camera Module v1
- Adafruit USB wifi dongle
- Adafruit Nokia LCD display
- Adafruit PowerBoost 500 Charger
- Adafruit 2200mAh lion battery
- Adafruit 5 way navigation switch
- Canon WP-DC20 Waterproof Case
A brief description of the various software components.
camera_server.py
- provides a web interface for performing timelapsescampi.py
- defines a class for interfacing with the hardwaretimelapser.py
- defines a thread class for performing a timelapsemjpegger.py
- defines a thread class for serving a MJPEG streamboot_menu.py
- can be run at boot to bring camera up in various modes
- Tornado Web Framework for web interface and control
- picamera for Python access to camera module
- Python Imaging Library used for drawing to LCD
- Adafruit Nokia LCD library for LCD display
- Adafruit Python GPIO for SPI access
- RPi.GPIO for GPIO access
This project uses hostapd to run the wifi in access point mode. If you're lucky, you can simply:
sudo apt-get install hostapd
However, the USB wifi donlge I used has the RTL8188CUS chipset, which required a custom build of hostapd. Here's what I did:
- Download zip file from here
- Choose RTL8188CUS, click GO, download Unix (Linux) driver
- filename: RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911.zip
- unzip that file
- go to /RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911/wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8_rtw_r7475.20130812/hostapd
- make and install by running
make
sudo make install
- this should put the files hostapd and hostapd_cli in /usr/local/bin
- rename existing hostapd and add links to custom build
sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.bak
sudo ln -s /usr/local/bin/hostapd /usr/sbin/hostapd
sudo chown root:root /usr/sbin/hostapd
sudo chmod 755 /usr/sbin/hostapd
- then configure by editting the file /etc/hostapd/hostapd.conf to have contents similar to:
interface=wlan0
ssid=picamera
hw_mode=g
channel=6
auth_algs=1
wmm_enabled=0
I initially tried udchpd but could not get it to work. I switched to isc-dhcp-server which worked. Luckily, this is easy to install:
sudo apt-get install isc-dhcp-server
Then update the following line in file /etc/default/isc-dhcp-server:
INTERFACES="wlan0"
Once the above have been installed and configured, start them:
sudo service hostapd start
sudo service isc-dhcp-server start
NOTE: this is sysv init style, systemd would be different.
Once you've installed the above dependencies and have them working, simply clone this repo and run the server:
$ git clone https://github.com/caternuson/rpi-camera.git
$ cd rpi-camera
$ sudo python camera_server.py
With the server running, you should be able to open a web browser and navigate to the pi to setup and run a timelapse.
http://piaddress:8080/
The program boot_menu.py
is intended to be run at boot to provide a way
to select from various camera modes. Options are shown on the LCD display
and selected using the 5 way navigation button. If you want to use this feature,
you will need to supply the needed startup programs referenced in the script.
Currently, the server simply captures a bunch of individual JPEG files. They are named using the current date and time and then serialized with a four digit number using the format: yyyymmdd_hhmm_xxxx.jpg. These can be rendered into a movie using avconv with the following command:
avconv -i <yyyymmdd_hhmm>_%04d.jpg -vcodec libx264 outputname.mp4
where <yyyymmdd_hhmm>
is replaced with the basename of the JPEG files. Also,
outputname can be changed to whatever. For example:
avconv -i 20160704_1938_%04d.jpg -vcodec libx264 fireworks.mp4