Introduction: Easy Timelapse: Raspberry Pi and PiCamera (V3 Wide)

About: I born in Italy in 1971, and since few years I live with my family in The Netherlands. On free time I like to build "useless devices", a pretest to learn coding and control theory

I've always been fascinated by timelapse videos, perhaps because my patience is dwindling as I grow older.

Anyhow, I wanted to capture memories of an event where I wouldn't have been able to take pictures, and none of my family members could join me to help. This was the trigger to start the timelapse project, giving a purpose to the spare Raspberry Pi 4b I had lying around for some time.

Yes, you're right, I was just searching for an excuse to start this project, and I did find it...


In internet there are many tutorials for Timelapse systems, based on Raspberry Pi; Compared to others, this system offer an interesting combination of features, like:

  • setting the parameters in a simple text file.
  • automatic erasing of the old pictures.
  • automatic video rendering.
  • shared folder to easily access the pictures/movies via the file manager from your PC.
  • based on a rather recent version of Raspberry Pi OS as well as PiCamera model.


Main timelapse characteristics are:

  1. Raspberry Pi 4b (it works well on Zero2 for picture capsuring, it doesn't for video rendering)
  2. PiCamera V3 wide
  3. Mini display for feedbacks
  4. 3D printed case, with:
  5. standard fixing for tripod
  6. rotating arm for the camera
  7. storage for the excess of camera ribbon cable
  8. easy to access microSD
  9. Raspberry Pi OS "Bullseys"
  10. Programmed in Python, using picamera2 library
  11. Timelapse settings are stored in a easy to edit json text file.
  12. Some of the parameters in the settings file provide insight into the Timelapse capabilities:
  13. start shooting time (hh:mm)
  14. stopt shooting time (hh:mm)
  15. shooting interval (seconds)
  16. consecutive shooting days (unit)
  17. HDR (y/n)
  18. autofocus (y/n)
  19. automatic video rendering (y/n); the video lenght can be set to:
  20. predefined fps (frame per second value)
  21. predefind video time (in seconds), and the fps will be adapted
  22. automatic pictures erasing and wastebin emptying (y/n)
  23. and more....

The used camera is a PiCamera V3, having interesting features like autofocus, hdr and it's available on different FoV / UV-lenses combinations; My choice went for the V3 Wide version, having more than 100degrees as horizontal angle.... quite a wide FoV.

When HDR is enable, the max resolution for this camera is 3Mb allowing full HD timelapse video (1920x1080); More info about the V3 cavera at: camera-module-3-product-brief.pdf (raspberrypi.com)


My purpose:

My intention has been to document the visitors approaching the CUBOTino stand at Hannover Maker Faire 2023. Anyhow, by testing the system at sunrise and sunset, I had already been rewarded by this project.


Possible usage:

Sunset, sunrise, plant and flowers growing, slow moving events, etc


Other tutorials:

There are many tutorials in internet to make timelapse systems. I found interesting and well made the one from Carolin Dunn

Supplies

Total cost of the project, on July 2023, has been ca 130€ (shipments excluded)


Screws, nuts and washers:

  • 1x 1/4"-20 UNC (nut with thread for tripods)
  • 2x M2.5x4mm cylindrical head
  • 4x M2.5x5mm cylindrical head
  • 4x M3x14mm cylindrical head
  • 1x M3x8mm cylindrical head
  • 6x M3x8mm conical head
  • 6x M3 nuts
  • 11x Washers for M3

Step 1: 3D Print the Parts

Notes:

  • Printing orientation as per images
  • Do not use support

Step 2: Assemble Arm - Cover

  1. Inserts the (4x) M3 nuts into the slots, after aligning the nut as per image; Forcing the nuts into the slots requires some force, peraps a little hammer might help.
  2. Add (8x) washers in between the arms, as per image; This generates friction between the arms and limit the screws unlocking. Also this step requires some brutal force....

Step 3: Insert the Nut for Tripod to the Base

Force the 1/4"-20 UNC nut into the slot.

Note: Pay attention to the complete insertion of the nut, to prevent it from short circuiting the Raspberry Pi; In case of doubts, add a piece of tape on top of the nut.

Step 4: Assemble Display Support Leg

The display foot can be easily made by a screw, two nuts and three washers.

The foot is necessary to support the display when pressing on the buttons, to prevent from bending inward and damaging its own connector and the GPIO connector

Step 5: Complete the Assembly

  1. Position Raspberry Pi on the Base, as per image, and fix it with the screws.
  2. Insert the camera ribbon into the CSi connector (ribbon's contacts oriented as per picture).
  3. (Optional) Insert the display on the GPIO connector (the first 16 pins). The display leg, made with screw and nuts, has to be prepared upfront.
  4. Connect the ribbon to the PiCamera module.
  5. Position the Cover onto the base; Fix it with the 6 screws.
  6. Squeeze the PiCamera module in between the camera_support and camera_cover; Fix the Cover with the 2 screws.


Note: On the base there are a couple of side holes that can be used for other fixing systems. For instance, brackets with suction caps to suspend the system on a window, and for that reason the camera arm har large rotation angle.

Step 6: How It Looks Like

Step 7: Raspberry Pi Setup

Setting up the Timelapse:

1. Flash bullseye OS (32 bit) in a fast (V30) microSD card, via Raspberry Pi Imager or other imager tool. The image could be downloaded from this official link (https://downloads.raspberrypi.org/raspios_oldstable_armhf/images/raspios_oldstable_armhf-2023-10-10/2023-05-03-raspios-bullseye-armhf.img.xz)

1.1 It is convenient to set a meaningfull Hostname (i.e. timelapse).

1.2 For convenience with the script, leave Username as "pi", while you're invited to set your own password (do not use 'raspberry' as password).

1.3 Configure the LAN from which you're going to initially connect (i.e. via SSH).

2. Into the "boot" folder copy the wpa_supplicant.conf text file with included the wi-fi connections you might need (phone AP is a convenient one); An example of this file is provided as reference, to be personalized with your Country digits, the Wi-Fi SSID and Passwords.

3. Into the "boot" folder make an empty text file named ssh (without extention); An example of this file is provided.

4. Insert the microSD into the Raspberry Pi, power on and wait until the green LED stops blinking.

5. Check for the Raspberry Pi IP in your network.

6. Connect to the Raspberry Pi via SSH (i.e. via Putty).

7. Update the system: sudo apt update

8. Upgrade the system: sudo apt upgrade -y

9. Install the picamera library (it should be already installed): sudo apt install python3-picamera2

10. Install the driver for the display: sudo pip3 install ST7789==0.0.4

11. Enable the SSH, SPI, VNC, set VNC Display resolution and BOOT type: sudo raspi-config

11.1 Interface Options, SSH  (then YES)

11.2 Interface Options: SPI(then YES)

11.3 Interface Options: VNC  (then YES)

11.4 Select Display Option, VNC Resolution (choose the one that suits your PC monitor, then OK).

11.5 To enable preview feature, select System Options, Boot / Autologin, Desktop Autologin.

11.6 Select: Finish

11.7. Confirm the reboot with YES (if you miss it, from the terminal type: sudo reboot)

12. Connect via VNC (i.e. via realVNC)

13. Open the Terminal, and clone the repository: git clone https://github.com/AndreaFavero71/timelapse.git (this step can be done from step 7)




(Optional) Making a shared folder via SMB protocol:

I found convenient to share a Raspberry Pi folder via SMB protocol, allowing quick access via a pc. For this reason, the pictures_folder is generated in the shared folder, making easy to access and copy the timelpase movie from the Raspberry Pi.


1. Install samba; From the Terminal: sudo apt install samba samba-common-bin (confirm with y, and select yes at DHCP package wins)

2. Make the folder to share: mkdir /home/pi/shared(shared is the folder name for the shared folder)

3. Edit samba config file: sudo nano /etc/samba/smb.conf  (at the file end add the below 6 rows, Ctrl + Ins to paste)

[shared]

path=/home/pi/shared

writeable=yes

create mask=0777

directory mask=0777

public=no

4. Save and close the samba config file: Ctrl+Xthen Ythen Enter

5. Associate your username:sudo smbpasswd -a pi  (pi is the username)

  once requested enter your password (the one to access the Raspberry Pi)

  once requested enter your password again (the one to access the Raspberry Pi)

  at this point there should be a confirmation "Added user pi."

6. Restart smb service: sudo systemctl restart smbd

7. Get the Raspberry Pi IP: hostname -I (capital I)

8. On your File Explorer Adress bar paste the IP, after the prefix "\\" and followed by the postfix "\shared": \\xx:xx:xx:xx\shared

9. Enter the password, and check it to get memorized.

10. The Raspberry Pi "shared" folder should be visible as a network folder; map it as a drive for convenience.



(Optional) automatic script start at Raspberry Pi booting

  1. Edit the crontab: sudo crontab -e
  2. Add at the end:

@reboot /bin/sleep 5; bash -l touch /home/pi/timelapse/timelapse_terminal.log && chmod 777 &_ (single raw)

@reboot /bin/sleep 5; bash -l /home/pi/timelapse/timelapse_bash.sh > /home/pi/timelapse/timelapse_terminal.log 2>&1 (single raw)

  1. Save and exit: Ctrl + X, followed by Y, followed by Enter.
  2. After Raspberry Pi boots, the timepse.py script will be excuted according to parameters saved at settings.txt file.

Note: To prevent the script from executing at boot, edit the crontab, comment out the two commands and save.



(Optional) automatic Raspberry Pi shut-off

Edit the timelapse_bash.sh: nano timelapse_bash.sh

Toward the end of the file, uncomment the row "# sudo halt -p"

Save and exit: Ctrl + X, followed by Y, followed by Enter.

Step 8: How to Use It

The overall idea is to predefine the job, let it go, and collect the assembled movie once the job is done.

The system is based on a python script and a text file for the settings (the only file to be edited).


The settings.txt file includes:

  • shooting start (hh:mm).
  • shotting stop (hh:mm).
  • interval between shoots (seconds).

Other options are:

  • Start shooting immediately (true/false); If true, then shooting start and it will stop after period_hhmm.
  • Start and Pause shooting via the buttons at the display.
  • Camera resolution.
  • HDR (High Dinamic Range) function at camera (true/false).
  • 180deg rotation of the captured image.
  • VNC camera image preview (true/false).
  • Camera preview on the tiny display.
  • Erasing older pictures from the microSD card that includes emptying the Wastebasket (true/false); This is done at the starting of a new job.
  • Auto video generation after the shooting (true/false); this can be based on:
  • predefined fps (frame per second value.
  • predefind video time (in seconds), and the fps will be consequently adapted; For this choice fix_movie_t (true/false) and movie_time_s (seconds).
  • Number of shooting days (integer), for the period defined by start and stop time.
  • Folder name where saving the pictures and generating the movie.
  • Usage of the display at Raspberry Pi (true/false).
  • Some parameters for the display, like width, height, horizontal and vertical shif, orientation.

Note: Boolean variables can be set as true/false or 1/0 or yes/no or....


Usage:

  • Switch on the Raspberry Pi.
  • Connect to it; If you want a camera preview, a remote desktop connection is necessary like VNC Viewer.
  • The relevant files are into the timelapse folder: cd timelapse
  • Edit the settings.txt file (quite self explanatory) and set the parameters according to your needs: nano settings.txt (save the file, with Ctrl + X, followed by Y, followed by Enter)
  • Run the script: python timelapse.py (changes at the settings are only loaded at the scrip start)
  • Feedbacks on the display:
  • At the start it shows the main settings, including an estimation of pictures quantity the microSD can store
  • Time left for the first picture
  • After the first picture is taken, it indicates the picture progressive number
  • After the last picture is taken, if set, it indicates the video editing status
  • In case the movie is not sattisfactory: Via the script video_render.py the video can be (re)made by changing some parameters. For this reason, when set, the pictures aren't automatically erased after a job completion; pictures are automatically erased at the start of a new job.
  • By pressing one of the buttons for 5 seconds the cycle is stopped
  • By pressing one of the buttons for more than 10 seconds the script is quitted; If the automating shut-off is set, this is the way to safely close stuff before unpowering the Raspberry Pi.


Methods defining the shooting approach:

1) Shooting predefined between start_hhmm and stop_hhmm, for one or multiple days:

  • Set start_now as False and local_control as False.
  • This method ends automatically, once the stop_hhmm of the last day is reached.

2) Shooting starting once the script is launced (eventually automated at the Raspberry Pi boot), and lasting for the period_hhmm:

  • Set start_now as True and local_control as False.
  • Also in this case the pictures quantity are predefined.
  • Can be imputed more than 2 digits at the hours of period_hhmm, therefore the shooting can be proceed over days, weeks, etc.

3) By manually starting and pausing the shooting, eventually multiple times, via the buttons on the display:

  • Set local_control as True.
  • In this case the pictures quantity aren't predefined.

In all cases:

  • The interval between shots is defined by interval_s
  • A long press (>10 secs), of one of the buttons, will terminate the shooting and the script.

Step 9: Some Results As Example

Faire event (Hannover Maker Faire 2023): https://youtu.be/wAfPYTDUh8o (recording in pubblic might require a proper warning).

Out of the windows: https://youtu.be/wO7wYDtcbZA

Step 10: PWM on Display

This type of display keeps the backlight always ON; In case you'd like to reduce power consumption, it is possible to control the backlight via PWM via a little modification to the display

1) Make a bridge between Pin 12 (GPIO18) and Pin 15 (GPIO22) as per pictures.

2) Set a couple of parameters to the settings.txt file: modified_disp to True and disp_bright to a integer value between 0 and 100.


Step 11: Possible Improvements

  1. The screws, at camera arm, tend to unlock by rotating the arm. Self locking nuts will be preferable, yet the design is not adapted for those nuts yet.
  2. Increase and improve feedback via the display (it's still quite under used).
  3. I'm open for your suggestions.


Step 12: Revisions

Rev 0.1 on 19/11/2023: Added multiple features, also in line with the received feedback

Step 13: Provide Feedback

If you've enjoyed the project and/or you've suggestions, please feedback.

If you have built this project, please add it to the "I MADE IT !" section: Search for the yellow button "I MADE IT!" below.