2012-06-05

Battery powered, Wireless, Motion detecting Raspberry Pi

Hardware

Software

  • Arch Linux ARM
  • Motion
  • Lighttpd

Set up

Update Arch

Before installing any new software it's a good idea to get up-to-date. I was caught out with an issue which seems to be catching others out too - when upgrading I got this:
error: failed to commit transaction (conflicting files)
hwids: /usr/share/hwdata/pci.ids exists in filesystem
hwids: /usr/share/hwdata/usb.ids exists in filesystem
Errors occurred, no packages were upgraded.
In this case, for these two files, it's OK to rename them and try again - it seems that there's been a change of which package supplies these files and it's not handled very gracefully.
[root@alarmpi ~]# mv /usr/share/hwdata/pci.ids /usr/share/hwdata/pci.ids.save
[root@alarmpi ~]# mv /usr/share/hwdata/usb.ids /usr/share/hwdata/usb.ids.save
[root@alarmpi ~]# pacman -Syu

Wifi

I chose the ASUS USB-N10 because of its size and the fact that it works out-of-the-box with Arch. It uses the r8712u module which is already installed with the distro. Getting the wireless to work well enough is not particularly straightforward. However there are some good instructions here: ArchWiki Wireless Setup. For the wireless management software I chose netcfg and wrote a script similar to the one given under "Intermittent Connection Failure" so I had complete control over what I wanted to do whenever I lost connection to my router. This was helpful for troubleshooting and useful when you're walking around the garden trying to find a good place to put the box.

Motion

Motion is a great piece of software. Just use pacman to install it and then follow the instructions on the Motion site for setting this up. My top tip would be to edit /etc/motion/motion.conf to set up the stream and control ports and switch off webcam_localhost and control_localhost. Then run it on the console "motion -s" and use the web control to fiddle with the settings - for some changes you'll have to restart motion. Sometimes you might need a mask file. I found that taking one of the snapshots, loading it in Gimp and painting over the top was the best way to do this. You can then export the file in pgm format. At 320x240 the Raspberry Pi was quite happy to run at 5fps with motion using about 20 to 25% CPU and low memory usage (I've still got 194M free).

Lighttpd

To get at the snapshots and movies that Motion has captured it's nice to be able to grab them from a web page. I'm going to write some Python to do this nicely, but in the mean time I've set up lighttpd to present the capture directory really quickly. Simply use pacman to install it and then edit /etc/lighttpd/lighttpd.conf following the quick instructions here: Tutorial Configuration

Note: I am now uploading my videos to Google Drive rather than keeping them on the Raspberry Pi. See: Motion Google Drive Uploader and Emailer

Results

I have been consistently getting nearly 12 hours running time from the battery pack on a full charge. That gave me enough time to leave the box out all day and catch some "wildlife". Now I just need to write some software at last! (More posts on that coming soon)

video
Post a Comment