Raspberry Pi time-lapse Camera Setup

This tutorial will walk you through setting up your own Raspberry Pi time-lapse Camera setup from beginning to end.

Hardware components

Hardware Setup

To install the camera use the ribbon cable and press the side of the connector and pull up.

Software Setup

To start this Raspberry Pi time-lapse project you will need a copy of Raspbian installed. And for this complete tutorial, we are going to use SSH only. So make sure to install any one serial terminal software.

In this, I’m going to use MobaXtream, which is a more convenient tool to use SSH.

Next, let’s move to the programming part. Power on the Raspberry Pi and log in to SSH using the tool.

Then update the software by using these commands.

sudo apt-get update
sudo apt-get upgrade

Next, we have to enable the camera interface in the Pi. Use the following commands to enter the Raspberry Pi configs.

sudo raspi-config

And select option 3, and enable the camera.

And enable that.

That’s all next just reboot and log in again to the SSH.

Testing the Camera

Use the following command to test the camera.

raspistill -o cam.jpg

You can see this command will take a picture, and it will save that.

Just double-click on the image and check the image.

Python to take an image

So, now our camera is working fine, the next step is to take multiple images and convert them, to a video.

Use the following command to create a new Python file.

touch timelapse.py

Next, open and edit the python file.

Use the following command to edit the python file.

nano timelapse.py

And these codes in it. You can access the GitHub repository of the project from here

from picamera import PiCamera
camera = PiCamera()
for i in range(5):

Then save the file using ctrl+x.

Note: Make sure the intentions.

Next, run the script by using “python timelapse.py”.

Once it finished the process, it will print “Done”. And you can see all the captured images.

Creating Time-lapse

Next, create two new folders in the name of Pictures and Video. We are going to use these two folders to capture and store the images and videos. You can access the GitHub repository of the project from here

from picamera import PiCamera
from os import system
import datetime
from time import sleep
tlminutes = 1
secondsinterval = 1 #number of seconds delay between each photo taken
fps = 60 #frames per second timelapse video
numphotos = int((tlminutes*60)/secondsinterval) #number of photos to take
print("number of photos to take = ", numphotos)
dateraw= datetime.datetime.now()
datetimeformat = dateraw.strftime("%Y-%m-%d_%H:%M")
print("RPi started taking photos for your timelapse at: " + datetimeformat)
camera = PiCamera()
camera.resolution = (1024, 768)
system('rm /home/pi/Pictures/*.jpg') #delete all photos in the Pictures folder before timelapse start

for i in range(numphotos):

print("Done taking photos.")
print("Please standby as your timelapse video is created.")
system('ffmpeg -r {} -f image2 -s 1024x768 -nostats -loglevel 0 -pattern_type glob -i "/home/pi/Pictures/*.jpg" -vcodec libx264 -crf 25 -pix_fmt yuv420p /home/pi/Videos/{}.mp4'.format(fps, datetimeformat))

print('Timelapse is complete'.format(datetimeformat))

In this code, you can define how long you want a video and frames per second.

Next, just run the script. Once the time-lapse is done it will show this message.

Navigate to the pictures you will see the captured images.

Same as in the videos folder

Please follow and like us:
Pin Share

Notify of

Inline Feedbacks
View all comments


TOP PCB Companies