Software Development

Raspberry Pi time lapse server

Raspberry Pi time lapse server

Building a time lapse server with a Raspberry Pi and a webcam

I had a Raspberry Pi lying around that I use to use as a media server, and an old webcam that I used before laptops came with webcams. I had an idea to create a time lapse server.

timelapse camera

What is does

It simply takes a photo every minute and saves it to a directory within the path of a webserver (Nginx).

Then a basic webpage takes input from the user (me) a time stamp as a parameter and starts playing the images at 1 image per second (60 times faster than they were taken).

Details on setting it up

Firstly I wiped the memory card of the Raspberry Pi that original had the OpenELEC (a Kodi distribution for Raspberry Pis) operating system and installed Rasbian.

$> lsb_release -a
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

I then installed

  • git
  • Python 3
  • Nginx

I created a Github repository and cloned it down to the home directory of the logged in user (just the default pi user). I created a virtual Python environment for development.

In the Nginx webserver root directory I copied the webserver files.

Running the service

To ensure the Python service is running always in the background I ran.

nohup python photo-service.py &

This will take a photo every minute and save it to the Nginx hosted webserver at /var/www/html/webcam/webcam-yyyymmddhhmm.jpg

Then, knowing the IP address of the Raspberry Pi on our network, we can use a browser to see the photos.

timelapse webserver

Time lapse results

This is a time lapse of me at my desk played back at 5 frames per second.

This is a time lapse at me buring the midnight oil, coding away at 10 frames per second.