Wednesday, August 8, 2012

Wireless, Battery Powered, Time-lapse Video with a Raspberry Pi

I was looking for cool projects for my Raspberry Pi and came across a really cool project by Jeremy Blythe: Battery powered, Wireless, Motion detecting Raspberry Pi.

It inspired me to build something similar, but instead of using the Pi as a security camera, I wanted to do some outdoor time-lapse photography. Here is an animated GIF that the Pi produced. I'm working on longer and higher resolution versions.



And here is the device itself, the "Lapse-Pi":


I used the following hardware to build it:

1. Microsoft Lifecam Show 2.0MP - $13 from NCIX
2. Power Bank 12000mAh External Battery Charger USB - $25 from eBay
3. Ultra Mini USB Wireless LAN Adapter 802.11n - $7 from Monoprice.com
4. Lego Bricks, Raspberry Pi, SD Card etc.

Below is a close-up of the battery. I've let my Raspberry Pi idle on it for around 24 hours before the juice runs out.



I've had lots of trouble getting webcams working on Linux, fortunately, the Microsoft Lifecam Show 2.0MP is UVC compatible. It was basically plug and play. I highly recommend getting a UVC compatible webcam. It will be almost guaranteed to work with your Raspberry Pi. See the Linux UVC driver webpage for compatible webcams.

On the software side I am using:

1. Official Raspbian Wheezy Image, "2012-07-15-wheezy-raspbian.zip"
2. Streamer
3. Imagemagick Convert
4. sshfs

Step by step instructions:

1. Install Streamer and SSHFS

sudo apt-get install streamer
sudo apt-get install sshfs

2. Mount your network share to store the time lapse images wirelessly. I use SSHFS, however you can use SAMBA, NFS, or whatever else you want.

mkdir server_mount
sshfs username@server:/home/username /home/pi/server_mount

3. Run streamer to capture the frames.

mkdir -p server_mount/timelapse
cd server_mount/timelapse/
streamer -o 0000.jpeg -s 352x248 -j 100 -t 00:20:00 -r 0.1 -c /dev/video0

Some notes on the command line parameters:

  • "-o 0000.jpeg" specifies the filename format for the individual frames
  • "-s 352x248" specifies the resolution. I think the Pi can handle much higher than this.
  • "-j 100" is the JPEG quality"
  • "-t 00:20:00" instructs it to capture for 20 minutes
  • "-r 0.1" indicates the frame rate of 0.1 frames/second
  • "-c /dev/video0" specifies the video device. It should be the same for you.

4. On the server, convert the captured frames to an animated GIF using Imagemagick's "convert" utility

convert -delay 5 *.jpeg -loop 0 animated.gif

Future Plans:

I have recently purchased a 4.5V OCV / 450mA SCC solar panel from eBay for about $20. I am in the process of figuring out how to charge the battery with it. If that happens then I can take time-lapses over multiple weeks and months rather than just 1 day.



I also will be trying higher resolution time-lapses. The Lifecam Show is capable of 2MP or 1600x1200. And hopefully in October the official Raspberry Pi camera module will come out that will be capable of 5MP or 1080p at 30fps!

5 comments:

  1. That battery is 12000mAh, not 120000mAh. Still, awesome everything. I was just thinking about doing this and wondered what kind of cam I could use... now I know. You rock good sir!

    ReplyDelete
  2. Whoops! Updated the post accordingly, thanks for the find. Good luck with the camera. It works great. And until the official camera module comes out, there is no point getting an HD webcam as the Pi can't really handle more than 320x240 video.

    ReplyDelete
  3. I just ordered that same WiFi dongle, did it require you to install any drivers on the Raspberry Pi? I've had no luck with another one of my WiFi dongles.

    ReplyDelete
    Replies
    1. Yes you need additional drivers to the dongle working. There is an excellent thread on the Raspberry Pi forums dealing with this. Please see:

      http://www.raspberrypi.org/phpBB3/viewtopic.php?f=26&t=6256&hilit=8192

      Good Luck!

      Delete
    2. Okay, thanks for the link! It just arrived yesterday and I am going to test it now.

      Delete