Introduction: Long Exposure and Astro-Photography Using Raspberry Pi

About: We are two young inventors, Kousheek Chakraborty and Satya Schiavina. We like using digital fabrication, electronics and various other fields of knowledge to create projects that focus on simplicity, efficienc…

Astrophotography is the photography of astronomical objects, celestial events, and areas of the night sky. Apart from recording the details of the Moon, Sun, and other planets, astrophotography has the ability to capture objects invisible to the human eye such as dim stars, nebulae, and galaxies. This fascinated us because the results obtained are breathtaking and can be achieved with long exposure shots.

To expand the versatility of a regular camera, we decided to design and build a raspberry pi powered module that can connect to a DSLR camera. This allows the photographer to preset certain variables thus automating the capturing process over long durations. Other than astrophotography stills, this module can generate star trails using the help of an inbuilt program and can also create time-lapses.

Follow on to build your very own module and take amazing pictures of the night-sky. Do drop a vote in the Raspberry-Pi Contest to support our project.

Step 1: Overview of the Module

The program that we made handles three distinct processes:

  • The front-end of the application, or the graphical user interface - this is what the user will use to interact and control the module
  • Controlling the camera - this is the part of the program that is responsible for triggering the camera at the correct time for the right amount of time
  • Processing the images - this is the section of the program that is responsible for combining and merging the pictures taken into a beautiful star-trail image or into a timelapse video

The GUI gathers the parameters such as the interval between pictures and exposure time of the camera from the user. It then instructs the camera to capture images based on these factors. Once all the images are captured the post-processing takes place. And the final result is stored onto the raspberry pi's internal memory for the user to access via the cloud or locally.

Step 2: Materials Needed

The hardware for this project is pretty straightforward, the following list contains all the materials needed.

Electronics and Hardware :

  • Raspberry Pi
  • LCD Touch Display
  • M3 Bolts x 8
  • M3 Heated Inserts x 8
  • A camera that exists in the following list (
  • A Standard Power Bank to power the system in areas where a plug may not be easily accessible

Programming and configuring the raspberry pi will require a few peripherals:

  • A mouse and keyboard
  • An external HDMI monitor

Step 3: 3D Printed Parts

We 3d printed out a case to hold all the components and designed a clamp to mount the module on a regular tripod. The parts take around 20 hours of printing time and we have linked a file for the following STL files below.

  • Raspberry Pi Case x 1, 20% infill
  • Cover x 1, 20% infill
  • Tripod Mount x 1, 40% infill
  • Tripod Clamp x 1, 40% infill

Once the printed parts are ready, one can carefully take out the supports.

Step 4: Embedding the Heat Inserts

To strengthen the plastic mounting holes, we embedded heat inserts. Using a soldering iron gently push in the inserts till they are flush with the top surface. Repeat the process for the eight mounting holes while making sure the bolt threads in easily and is perpendicular.

Step 5: Mounting the Raspberry Pi and Screen

Using M3 bolts secure the raspberry pi in place using the corresponding mounting holes. Then plug in the display by aligning the connector pins. Finally, place the cover over the screen and fasten the bolts. The module is now ready for the software to be uploaded.

Step 6: Attaching to the Tripod

To make the module easily accessible to the camera, we decided to position it on the tripod. We designed a custom mounting bracket that fits a standard tripod. Simply use two screws to clamp the mount around a leg of the tripod. This allows one to attach and remove the module with ease.

Step 7: Setting Up the Raspberry Pi's Operating System

The raspberry pi on the module is running a Debian based operating system called Raspbian. As of the time of Instructable, the latest version of the OS is Raspbian Buster, which is what we decided to use. The OS can be downloaded using the following link. (Raspbian Buster OS) Make sure to download the option that says "Raspbian Buster with desktop and recommended software" because some of the recommended software will be useful for this project. Once the zipped folder is downloaded, you will need a micro SD-card with a memory of about 16 to 32 GB.

To flash the SD-card with the OS, we recommend using the Balena Etcher software, as it is simple to use. It can be downloaded from the following link. (Balena Etcher) Once you open the software, you will be instructed to select the zipped folder you just downloaded, then plug the SD-card into your computer, and the software should automatically detect, finally click on the flash icon. The process should take 2 to 3 minutes. Once complete, unplug the memory card and plug it into your raspberry pi.

Connect the raspberry pi to an external monitor using an HDMI cable, and connect a mouse and keyboard via the USB ports. Finally, power the pi using the micro-USB port and a 5v adapter, and the pi should begin the booting process. The OS will then walks you through the necessary updates and various other settings, such as connecting to a wireless network and setting up the date and time, simply follow along. Once the process is complete, you have set-up the OS on your pi and you can now use it as a regular computer.

Step 8: Additional Libraries and Requirements

To make sure the program runs, the raspberry pi requires some libraries and dependencies to be installed. Here is a list of all of them (note: we used python3 for this project and we recommend you to do the same):

  • Tkinter (this comes inbuilt when you downloaded python)
  • PIL (this also comes preinstalled with python)
  • sh
  • OpenCV
  • gphoto2

Before installing any packages we recommend updating the raspberry pi's OS using the command sudo apt-get update. The sh library can be downloaded and installed by opening up a terminal and using the following command:

  • sudo pip3 install sh

To install the gphoto2 package simply use the following command:

  • sudo apt-get install gphoto2

Downloading and installing the OpenCV package is a slightly longer process. We recommend using the following link, which walks you through the steps and provides all the commands in great detail:

Step 9: Additional Drivers for the Onboard Touchscreen Display

The onboard touch screen requires some simple configuring for it to function. Power up the raspberry pi and open up a terminal and use the following commands:

  • sudo rm -rf LCD-show
  • git clone
  • chmod -R 755 LCD-show
  • cd LCD-show/
  • sudo ./LCD35-show

Once you entered the last command, your external monitor should go blank and the pi should boot up and display the desktop on the onboard touchscreen. To revert back to your external monitor, open up a terminal window on the onboard screen and use the following commands.

  • chmod -R 755 LCD-show
  • cd LCD-show/
  • sudo ./LCD-hdmi

Step 10: Running the Timelapse Module Program

Firstly connect the raspberry pi to an external power bank, using the power port. To run the program, download and unzip the zipped folder that is attached below. Copy the entire folder onto the raspberry pi's desktop. To run the program and the GUI, open up the file named and the GUI should appear on the raspberry pi's touch screen.

Next, connect the camera to the raspberry pi using a USB cable. Keep the default values on the GUI and click on the start button. This should trigger the camera 5 times at intervals of 2 seconds. Once complete, you can see the pictures that the camera has taken in the Images folder.

Troubleshooting: In case the camera does not trigger, make sure the model of your camera is present in the following list. If your camera is on this list, make sure that the connections are secure and your camera is turned on.


Step 11: Recommended Camera Settings for Astro-Photography

Here are some camera settings we recommend while doing astrophotography.

  • Your camera should be on manual focus and set the focus to infinity
  • Mount the camera onto a tripod
  • The camera settings should be on manual mode
  • Shutter speed: 15-30 seconds
  • Aperture: Lowest possible for your lens, f-2.8 is ideal
  • ISO: 1600-6400

Apart from the camera settings, make sure to have clear skies. Ideally one should also be in the countryside away from all the city lights for ideal results.

Step 12: Understanding the GUI

The GUI contains three values that the user can adjust:

  • Exposure Time determines the shutter speed of your camera. For example, when you are shooting stars in the night sky, a shutter speed of 15 to 30 seconds is recommended, in such cases, set this value to 30 seconds. If the exposure time is anything below 1 second, you can keep the value as a 0.
  • Interval Time determines the amount of time you want between two exposures. In the case of time-lapses, we recommend an interval time of something between 1 to 5 minutes.
  • Number of Exposures determines the number of pictures you would like to take for the timelapse. Standard videos play at about 30 fps, which means that if you click 30 pictures you would get one second of video. Based on this the user can decide the number of pictures that are required.

The UI features a self-explanatory interface. The arrow buttons are used to increment or decrements the values and the start button when the parameters are finalized. This triggers the camera that should have already been connected via one of the pi's USB ports. The images are then saved on the raspberry pi's memory where further modifications can be made.

Step 13: To Infinity and Beyond

After having used this module frequently, we are happy with the results obtained. With a bit of experience in astro-photography one can capture beautiful stills. We hope this project was helpful, if you liked it do support us by dropping a vote.

Happy Making!

Raspberry Pi Contest 2020

Runner Up in the
Raspberry Pi Contest 2020