I have the camera module for the raspberry pi. I need to know, how do I program the pi to take an image every 30 seconds and save the images to the inserted 64gb SD card.

  • There are atleast 10 ways to do this if not 101 ways. Are you using the desktop? You want to write a script, program? raspicam has a timelapse feature and motion also but there are so many other ways. What have you tried? – Piotr Kula Jan 28 '16 at 20:11

One way is to create a bash script and cron job.

Create a bash script inside /home/pi directory using your favourite text editor and name it takephoto.sh for example.

DATE=$(date +"%Y-%m-%d_%H%M")
raspistill -o /home/pi/stills/$DATE.jpg

Then when you saved it you need to set the execute flag on the file with the following command.

chmod +x takephoto.sh

Create a directory, like /home/pi/stills, the same as in the bash script. Now from /home/pi you can test the script by executing it using ./takephoto.sh

You should have an image created inside the still folder with the timestamp.

Now you can setup a cron job to execute the script with the interval you require.

|improve this answer|||||
  • 1
    Thank you for the responses. This pi setup is going in a weather balloon to take images, saved to sd card. The pi will be powered by a lipo battery. I want to take the sd card out of the pi and upload them to my desktop. – Bra Nil Jan 28 '16 at 20:43
  • 1
    crons minimum resolution is 1 minute so probably simplest to just have a sleep(30) and loop the script continuously. – joan Jan 28 '16 at 22:07

You could just use the raspistill's built in timelapse option:

raspistill -t 30000 -tl 2000 -o image%04d.jpg

That will take a picture every 2 seconds over a total period of 30 seconds with the files named image1.jpg, image0002.jpg...image0015.jpg. The %04d will be changed into a four-digit number with leading zeros added. I.e. %08d would give you an eight-digit number.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.