cobbystreet/picam
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
This is the Raspberry Pi Timelapse Camera Server (picam)
This README details the composition of the basic components and the steps necessary to
install it on top of a previously configured raspberry pi.
Basic Structure:
camServer.py runs at all times and takes picture between start and end times every interval period.
startserver.sh is run every minute by cron to check whether the camServer failed and restarts it if
necessary.
It also runs the ftpsync script and checks for config reloads
webConfig.py is called from the lighttpd if the user opens the browser configuration. It parses
and saves config data, changes WPA settings and issues photo and FTP testing.
These three parts are running asynchronously. startserver.sh ties it all together.
#extract raspbian image to device. BEWARE: CORRECT DEVICE NAME NEEDED HERE
unzip -p *-wheezy-raspbian.zip |dd of=/dev/sdb bs=1M
#make sure ssh starts at boot
ln -s /etc/init.d/ssh /etc/rc2.d/S04ssh
#configure WPA settings in /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="SSID"
psk="PASSWORD"
key_mgmt=WPA-PSK
}
#boot up the PI and figure out it's IP address. ssh into it with
ssh pi@IPADDRESS
#become root
sudo su
#finish PI config
raspi-config
Expand Filesystem
Localization -> TimeZone
Localization -> Change Locale
Enable Camera
#exit and allow to reboot. Relogin
#Installing prerequisits:
apt-get update
apt-get upgrade
apt-get install hostapd dnsmasq python-opencv python-imaging lighttpd lftp
#Configure wpa in
/etc/wpa_supplicant/wpa_supplicant.conf
#Deactivate Servers
update-rc.d hostapd remove
update-rc.d dnsmasq remove
#Get picam:
wget "https://github.com/ashtons/picam/archive/master.zip"
unzip master.zip
cd picam-master
python setup.py install
#Allow the webconfig script to restart the network fallback:
insert into /etc/sudoers
www-data ALL=(ALL) NOPASSWD: /usr/sbin/service networkfallback start
www-data ALL=(ALL) NOPASSWD: /usr/sbin/service networkfallback stop
www-data ALL=(ALL) NOPASSWD: /usr/bin/killall -SIGUSR1 dd
www-data ALL=(ALL) NOPASSWD: /usr/bin/stdbuf -o 0 /var/www/cgi-bin/clonesd.sh
#Allow for address redirection in case of a WIFI connect failure:
insert into /etc/dnsmasq.conf
address=/#/192.168.5.1
domain=picam
dhcp-range=192.168.5.50,192.168.5.150,12h
#Copy hostapd.conf into /etc/hostapd and insert into /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"
Change /etc/hostname and /etc/hostapd/hostapd.conf ssid to something unique
#If you have a wifi dongle that doesn't work out of the box do:
lsusb
#and locate the line that lists the dongle. Copy this line along with "hostapd"
#into google and hope for the best...
#Allow www-data to take pictures
addgroup www-data video
#Create directories:
mkdir /home/pi/.picam
chown pi.video /home/pi/.picam
mkdir /var/log/picam
chown pi.video /var/log/picam
mkdir /var/lib/picam
mkdir /var/lib/picam/images
chown -R pi.video /var/lib/picam
chmod -R g+w /var/lib/picam/
chown -R www-data.video /var/www/
chmod g+w /var/www
#Edit pi crontab:
crontab -e -u pi
* * * * * /var/www/cgi-bin/startserver.sh >>/var/log/picam/startserver.txt 2>&1
#Getting rtl8188CUS hostapd:
wget -O /usr/sbin/hostapd.rtl "http://dl.dropbox.com/u/1663660/hostapd/hostapd"
chmod 755 /usr/sbin/hostapd.rtl
#Change /etc/init.d/hostapd to try both binaries:
start-stop-daemon --start --oknodo --quiet --exec "${DAEMON_SBIN}.rtl" \
--pidfile "$PIDFILE" -- $DAEMON_OPTS >/dev/null || start-stop-daemon --start --oknodo --quiet --exec "${DAEMON_SBIN}" \
--pidfile "$PIDFILE" -- $DAEMON_OPTS >/dev/null
#Activate networkfallback
update-rc.d networkfallback start 2 3 4 5