Raspberry PI Zero – Timelapse with the new camera's 8 megapixels [Part I]

With the recent release of the new Raspberry Pi Zero with slot for camera, Opens a wide range of possibilities thanks to the small size of this device, What offers the same features as the model B +.


If to this we add the new model of camera's 8 megapixels the Foundation has recently launched, us can happen an infinite number of projects; in this tutorial We will see how to make easy one, or several timelapse taking advantage of the system cron daemon, and the tool raspistill.

Changes in the design that has been PI Zero one model to other, only noteworthy is the connector for the camera, the slight displacement suffered from connections PP1 and PP6 Since It can affect compatibility with some HAT market, and the need for an additional cable, Unlike the original in one of its ends due to the small size of the connection slot.

Connections PP1 and PP6 in Raspberry PI Zero v1.2 and v1.3

To start developing this small project, first We will update both the system and the kernel of our Raspberry, so this detects our new camera model, and finally the activate in the menu raspi-config.

pi@zero:~$ sudo apt-get update && sudo apt-get upgrade && sudo rpi-update
pi@zero:~$ sudo raspi-config

Activating the camera in raspi-config.

After reboot to apply the changes, we will test the camera with the tool raspistill, with the following example line, We can generate seven images in a time of one minute; We can see all the options offered by raspistill consult the manual of the tool by the order man Terminal.

pi@zero:~$ raspistill -o a%04d.jpg -t 60000 -tl 10000

Then, and after checking that the camera works will create the Directory timelapse in the Directory IP user's home, that will contain the subdirectories to accommodate the images captured by the our Raspberry camera.

pi@zero:~$ mkdir /home/pi/timelapse

Inside the folder created in the previous step, We are going to write a script to which I have called “tomafoto“; whenever we launch it we will obtain a picture of the camera with the current time and the minute as name, and in jpg format.


MIN_FOTO=$(date +%H:%M)
DIRECTORIO=$(date +%d_%m_%y)

raspistill -o /home/pi/timelapses/$DIRECTORIO/$MIN_FOTO.jpg

Finally, we will add the following lines of code in the file /etc/rc.local so every time you start the system, create a subdirectory for the day in the case that he has not previously, and with the current date as a name; It is important to place them on the last line of the script, that is what contains “exit 0“.

#Comprueba si existe la carpeta de hoy, y si no, la crea.

if [ ! -d /home/pi/timelapses/$(date '+%x'|tr -s “/” “_”) ]; then
  su -c "mkdir /home/pi/timelapses/$(date '+%x'|tr -s “/” “_”)" pi
  printf "Se ha creado el directorio de timelapse de hoy"

exit 0

After restart, We can see that it has been correctly created the directory that will contain the images captured throughout the day from today through the output on screen during system startup, or alternatively by using the command “ls“.PiZero_Carpeta1

In my case, I'll make a trip in which I intend to disconnect after a hard year of work and studies, so my idea is that the project starts to capture images automatically by feeding my Raspberry Pi; I will use for this purpose the system daemon cron, Since for the use that I shall give him will be more stable than the option timelapse own tool raspivid.

pi@zero:~$ crontab -e
no crontab for pi - using an empty one

Select an editor.  To change later, run 'select-editor'.
  1. /bin/ed
  2. /bin/nano
  3. /usr/bin/vim.tiny

Choose 1-3 [2]: 2

In the file cron user, We should add a line by invoking to the script tomafoto and indicating with that frequency should be executed automatically; below we can see some syntax examples with different frequencies of execution.

# m h  dom mon dow   command

#Capturamos una imagen cada minuto.
* * * * *  /home/pi/timelapses/tomafoto

#Capturamos una imágen cada 5 minutos.
0,5,10,15,20,25,30,35,40,45,50,55  * * * * /home/pi/timelapses/tomafoto

#Capturamos una imágen cada 10 minutos.
0,10,20,30,40,50  * * * * /home/pi/timelapses/tomafoto

The variables used to name subdirectories and the images they contain, They allow us to identify with the date in the case of directories, and the hour and minute in the catches in order to compile then a video based on the pictures taken as we shall see in the following delivery of this tutorial.

If you like you can follow me on Twitter, Facbook, Google +, LinkedIn, Feedly, or share it with the buttons under this publication, If you have any questions or suggestions please do not hesitate to comment.

Help us to reach more readers Share on LinkedInShare on FacebookTweet about this on TwitterShare on Google+Email this to someone

"One thought on"Raspberry PI Zero – Timelapse with the new camera's 8 megapixels [Part I]

  1. I appreciate all the effort of this super site, go ahead my appreciation. Hi I am trying to develop something similar to what you have proposed in home automation controls, but I have had problems in the control of the raspicam (It doesn't work). I've placed the code on the web address. Does the code raspicam. On the other hand does not work cronetap system, I have tried it in another computer aside from the raspi, with LinuxMint and not running scheduled tasks. I am not doing well. A greeting.

Leave a Reply