Raspberry Pi as a time-lapse controller.
In my quest to travel with the least posible amount of equipment, I decided to leave the
intervalometer at home and use the Raspberry Pi as a time-lapse controller for the Sony A7 . Since time-lapses take a long time to shoot for obvious reasons, I’ll be using the II Sense on the Raspberry Pi as a progress bar to give the user a general indication of how many shots are left. HAT
Here is an example of a time-lapse sequence controlled by the Raspberry Pi and the way it is displayed on the Sense
I was inspired by
David Singleton’s post, and I must say, he did a much more comprehensive Job on his post. He even managed to set the exposure parameters on the camera based on actual light conditions by analyzing the photos being taken on the Raspberry Pi. Since the Python library used to interact with the camera currently provides limited functionality for the Sony A7 series of cameras, I put together a much simpler script. However, I think it works better and provides more flexibility than a regular hardware intervalometer. Hardware Requirements
gPhoto2, command line set of applications used to interact with digital cameras from Unix-like systems.
Click, Python package used to quickly create command line interfaces for scripts and applications with as little code as possible.
Sense Python library. HAT
Prompt iOS App for connecting to the Raspberry Pi from iOS devices. However, connection can be made from Mac, Windows or Linux machines. Time-lapse Python script, which can be found in the
Installation of the first four requirements is pretty straightforward, just refer to the appropriate sections in the above referenced links.
Python Time-Lapse Script
This is a
Command Line Interface ( CLI) script. Meaning that there is no graphical user interface and everything is handled from the command line on the Raspberry Pi. However, don’t let that discourage you from using this method. As I’ll explain in the following lines, it’s a fairly easy process and sometimes, the simplicity and speed offered by the command line can’t be replicated through graphical interfaces.
The script sets up the camera for a time-lapse shoot based on certain parameters provided by the user. It offers two commands:
by_clip_length: The script calculates the number of shots and interval between them based on the final clip length and the actual event duration (both provided by the user). The script assumes 30 frames per second (fps), no delay before initiating process and use of the Sense HAT to show progress. However, these last three parameters are optional and can be modified.
by_interval_length: The script calculates the total event duration and final clip length based on the interval length between shots and the total number of shots (both provided by the user). The script assumes 30 frames per second (fps), no delay before initiating process and use of the Sense HAT to show progress. However, these last three parameters are optional and can be modified.
After each photo is taken,
it is downloaded to the folder in the Raspberry Pi where the script was ran from, and then it is deleted from the camera. This keeps the camera’s SD card from filling up with hundreds of time-lapse photos, but more than a feature, is a consequence of limitations gphoto2 has on Sony cameras.
As the camera keeps taking photos, the
LED matrix on the Sense Hat is updated to show the progress.
Sense HAT on Raspberry Pi showing finished time-lapse.
Let’s assume we want to setup the camera for a time-lapse event that will last 3 hours, and we want to end up with a time-lapse clip of 20 seconds, at 30 frames per second (fps), which is the default value. Also, lets suppose the script resides in
home/pi/scripts/photos. Once in the folder where the photos will be copied, the following would need to be typed on the command line to set everything up:
python3 /home/pi/scripts/timelapse.py by_clip_length --clip 20 --event_duration 180
This however, requires the
SSH connection to the Raspberry Pi to be alive while the time-lapse is in progress. To setup everything, disconnect from the Raspberry Pi and let it do its thing, the following should be typed:
nohup python3 /home/pi/scripts/timelapse.py by_clip_length --clip 20 --event_duration 180 &
Obviously, this can be simplified further by creating a bash script and
/or making the Python script accessible from any directory. It all depends on your personal preference and how comfortable you feel with the command line.
The script is provided with easy-to-read help text available with the
—help modifier. Thus, to see a list of available commands, just type:
python3 timelapse.py --help
To see all options available for the
by_clip_length command, for example, just type:
python3 timelapse.py by_clip_length --help
Note on Battery Life
Due to Sony A7’s infamous battery life, I ran out of battery during one of my time-lapses. Here are some tips to prevent it from happening:
Set the camera on
flight mode. This effectively turns off all wireless connections to/from it. Turn off the auto-switch between the Electronic View Finder (
EVF) and LCD and set it to EVF only. That way, the LCD will remain off and the EVF will only turn on when you get close to the camera and look into it. Put a fresh battery in before starting a new time-lapse.
Set the camera to manual focus. That way, the camera doesn’t try to focus on every shot, which is a hit on the battery life, especially in low light conditions.