We are now going to learn how to build a super simple time lapse camera using the raspberry
pi. The principle behind a time lapse camera is very straightforward. We simply capture
images at regular intervals and these can then be used to create a video to give you
the time lapse effect.
You do not need a display to recreate this project but I used one simply to show you
how it all works together. For that reason, I will also be using a raspberry pi 3, though
you can do this with almost any raspberry pi variant that supports a camera. The first
step was downloading the Raspbian image and I selected the desktop version for the display.
I then flashed this onto the microSD card using etcher. Next, I had to copy the SSH
and network file so that the board can access the WiFi network. I’m using SSH to log into
and control the board but you can also directly use the terminal from the raspberry pi desktop,
by connecting a keyboard.
Once that was done, it was time to connect everything and boot the board. The display
I am using, uses the USB connection to obtain power and also for the touchscreen interface
but yours may vary. As you can see, the resolution is incorrect, so that was the first thing
that needed to be fixed. Doing this is extremely simply. First, I used angry IP scanner to
obtain the boards IP address. I then used a terminal window to SSH into the board and
then opened up the config file. I added the following lines which set the HDMI resolution.
These were obtained from the support page for the display so yours may vary. All that
was left to do was reboot the board. Once done, the display resolution was fixed and
it looked much better overall.
Next I had to enable the camera and this was done by logging back into the board and running
the raspi-config tool. The camera is under the interfacing option and once enabled, I
had to reboot the board again. Before writing the script, I decided to test the camera and
doing this was simple enough. I simply had to run the raspistill command to capture an
image. You will be able to see a preview on the display and you can confirm that the file
is created by running the ls command.
Now that the camera is working, it was time to create the script. This is similar to the
IP camera we created a few videos ago and this time we will be using the raspistill
command. The first section simply tells the board to take images continuously for 20 seconds,
at intervals of 1 second. I also specify the resolution and the location where the image
needs to be stored. I then saved the file by typing Ctrl+x, Y and enter. I then made
the script executable and finally tested it out by running it. This gave me an error and
it was because the images directory was invalid so I went ahead and created it. The script
was then able to run and I could also view the preview on the display. The images were
stored in the images folder and this could also be checked using the terminal.
Now that the script was working, I simply had to automate it. I decided to use the systemd
method like last time which involved creating this file. I’d recommend copying the code
straight off the written post instead of typing it all. I simply saved the file, enabled the
status and then rebooted the board. As you can see the service is run on boot and you
can view the preview of the images which are being captured. The script stops taking images
after 20 seconds, so I updated the it to run continuously by passing 0 to the t flag. I
also didn’t want the preview to keep showing up so I added the n flag to disable it. Once
done, I simply rebooted the board. You can see the files being created in the images
folder and this will continue indefinitely, until the board is powered OFF.
Before I conclude this video, let me quickly show you how you can save the images to a
USB drive. The USB drive has to be formatted in the FAT32 file system for the raspberry
pi to recognize it. Simply insert it into a USB port and then open it up using the file
manager. Keep a note of the file path as we will be using it. We then need to stop the
script and update it. I first updated the file location so that the images are saved
to the USB drive. I then updated the time interval to 5 seconds and then saved the script.
Before we can run the script, we need to navigate to the USB drive and create a folder with
the name images. Once done, we can simply start the script. You will be able to see
the files being saved to the USB drive.
You can then shutdown the board and plug the usb drive into a computer to view the images.
There are many applications that you can use to create a video from the images and one
such application is the Time lapse creator that you can obtain from the Microsoft store.
You simply have to select the folder containing the images, set the duration and generate
the file.
And that’s how easy it is to capture time lapse images using the Raspberry PI. There’s
a lot more than you can do with this and we will be looking at some applications in the
upcoming videos. So do subscribe to stay notified. Thank you for watching, and I will see you
in the next one!