How to Set Up Your Raspberry Pi Time-Lapse Setup - Raspberry Pi Projects, Tutorials, Learning DIY Electronics - Makergenix

Breaking

 


How to Set Up Your Raspberry Pi Time-Lapse Setup

 In this tutorial, I'll show you how to build up your own Raspberry Pi time-lapse setup from start to end.

How to Set Up Your Raspberry Pi Time-Lapse Setup

In this tutorial, we'll use the Raspberry Pi camera. This interesting camera is available at any respectable electronic store that sells the Raspberry Pi.


I'll walk you through all you need to know to get things set up and running. It's a simple procedure, and you'll learn how to set up cron jobs and more.


This tutorial is also a great way to get a better understanding of the Raspberry Pi camera and what you can accomplish with it.


The equipment you will need in this tutorial is listed below.

  • Raspberry Pi
  • Raspberry Pi Camera
  • Power Supply
  • Micro SD Card
  • USB Keyboard
  • USB Mouse

Setting up the Time-Lapse Machine in Video

If you prefer not to read, watch the wonderful video I created specifically for you on how to do the Raspberry Pi time-lapse.

It walks you through every step of getting your Raspberry Pi to take images so you can utilise them in a time-lapse video.

IOTPi

Setting up the Camera

The most crucial step is to appropriately connect the Raspberry Pi camera to your Pi.

This procedure is rather simple, however anyone new to this type of thing will benefit from this part.

Hardware

To install the camera, go to the ribbon cable attachment and gently press on both sides of the connector with two fingers and pull up.


After using this method to open the attachment, insert the cable with the metal leads pointing away from the Ethernet port.

Once everything is matched up and the cable is entered far enough, gently press the connection back down to secure the cable.

Software

You'll need a copy of Raspbian installed on your Raspberry Pi to get started with this time lapse project. You would have enabled the Raspberry Pi camera capabilities if you had followed my instructions for installing NOOBS.

If you haven't already, you can activate it by typing the following command into the terminal.
sudo raspi-config

After that, select yes to enable the camera. The Raspberry Pi will then need to be rebooted.

Putting the Camera to the Test

1. If your Raspberry Pi is currently turned off, now is the moment to switch it on.

2. Open a terminal window and type the command below.
raspistill -o cam.jpg
3. If you now type ls, you will notice that the image file has been created (cam.jpg). Open this image with a file browser or, if you're using SSH, from your workstation.

If you're new to Linux, you might find the ls command guide helpful.

4. If the image is upside down, your camera is not properly positioned. Using the following command, you can either correct the camera or just flip the image.
raspistill -hf -vf -o cam2.jpg
5. Verify that the image is now facing up in the proper orientation.

Make a script.

It's now time to develop a script that will take a picture and append the date and time to the file name.

If you'd rather not develop your own script, you can download camera.sh, which I've already written. You can also use the wget command to download it directly to the Raspberry Pi.
sudo wget https://files.pimylifeup.com/timelapse/camera.sh
The script is simple, but keep in mind that if your camera is currently upside down, you'll need to add the -hf and -vf parameters.

Enter the following command to create a directory and name it timelapse.
mkdir timelapse
Enter the command below to get into this folder.
cd ./timelapse
Now we need to use a text editor like nano to generate a bash script named camera.sh. You can do so by typing in the following code.
sudo nano camera.sh
Copy and paste the bash script below into this file.
#!/bin/bash
DATE=$(date +"%Y-%m-%d_%H%M")
raspistill -o /home/pi/timelapse/$DATE.jpg
Run the following line to see if the script works.
sh camera.sh
Look at the error message and try to troubleshoot the code if it fails to execute. Also, compare your code to the code I provided above.

If it doesn't fail, we'll go on to the next step, which is setting up a running schedule for the Pi.
Schedule the photo shoot according to the script.

The script above is now complete, and while you can make changes to it, we'll keep it simple for the sake of this article.

After that, we'll need to set the script to run for a certain period of time, allowing us to collect hundreds or thousands of photos.

Let's modify the crontab by typing the following commands.
sudo crontab –e
If you've never used cron before, it'll ask you to choose a text editor. I choose nano since it is the simplest to learn rapidly.


Once you've logged in, scroll down to the bottom of the page to see some useful column headers like the ones below. These instructions will help you set up a cron job.

To understand more about how the cron system works, see our cron jobs guide. If you're just getting started and want to learn more, this is the book for you.
# m h dom mon dow   command
Add the following line to the schedule to have the time-lapse start every minute. You are free to edit this to whatever you choose.
* * * * * sh /home/pi/timelapse/camera.sh 2>&1
Exit and save by hitting CTRL + X, then Y when you've finished. Finally, hit ENTER.

The following message should appear after that.
crontab: installing new crontab
If you put watch ls in our new timelapse folder, it should now begin to fill with photographs that you can use to create a time-lapse.

You can shut it down and relocate it wherever you want, and it will start taking images again once the Pi is rebooted.

If you ever need to change or remove the cron job, simply repeat the steps above and change or remove the line we introduced.

Now, this approach just saves the photographs to the Pi, but you may configure it to save to a USB stick, network drive, or other storage device.

Simply put a USB stick into the Raspberry Pi and copy and paste the files onto the USB stick using the GUI (Graphical User Interface).

Putting your Raspberry Pi Time-Lapse on the Internet

The Pi's portability and energy efficiency are two of its most impressive features. You can operate the Pi for a few hours if you have a battery pack, and the greatest part is that you can put it wherever you want.

After you've finished configuring the Raspberry Pi camera and the cron job, you can simply unplug it and place it anywhere you like. You don't need to connect the Pi to a screen for it to operate.

You now have your very own Raspberry Pi time-lapse, which you can use to shoot some pretty cool photographs and then turn into a beautiful time-lapse.

IOTPi

 


Most Viewed Posts

Write For Us

Name

Email *

Message *

All Blogs