Equipped with only a Raspberry Pi, a Raspberry Pi Camera, and small USB Lithium Battery pack, I set out to capture some Astrophotography images on a clear winters night.
In particular I was aiming to capture star trails - the trails that appear to be left by stars as they move across the night sky (in fact it is the observer who moves as the earth rotates). I would take a series of still images using the Raspberry Pi's camera and store them onto the Pi's memory card. Later I would try to combine the images which would hopefully plot the star trails.
The first step was to prepare the hardware. I bought a Model A Raspberry Pi and a Raspberry Pi Camera and Mount from Pimoroni. The Model A has a lower power drain than the Model B and the latter's ethernet port and extra USB port and extra memory were not needed for this project. Using the camera mount I bolted the camera to the inside of an ice cream tub large enough to house the Raspberry Pi and battery (after I had eaten all the ice cream, obviously). I made a small hole in the side of the tub so that the camera lens was exposed. The result was an enclosure which, while not entirely waterproof, would at least mostly keep the elements out.
I also formatted a 16Gb memory card and loaded the latest version of Raspbian onto it.
Next I booted and configured the Raspberry Pi. In the home directory of the pi user, I created a startrails subdirectory and inside this directory I created a startrails.sh script with the following contents.
#/bin/sh cd `dirname $0` sleep 7200 raspistill -bm -tl 1000 -v -set -ISO 800 -awb off -awbg 1,1 -t 21600000 -ss 6000000 -o %06d.jpg shutdown -hP now
This script sleeps for 2 hours and then uses the raspistill command to take a series of long exposure pictures, using settings discussed in this forum thread. As advised in the thread I used rpi-update to update to the latest version of the firmware as long exposure capabilities were recently added.
The -ss 6000000 setting configures a 6 second exposure for each still. The -t 21600000 setting indicates the number of milliseconds to continue shooting (6 hours).
Finally the script will shut down the Raspberry Pi after the photographs have been taken.
Next I configured the Raspberry Pi to run the startrails.sh script at boot time (I would take the equipment to a location as far as possible from sources light pollution and turn the Raspberry Pi on about an hour before dark). I added the following command to the file /etc/rc.local to run the startrails script on each boot:
One final point, this will run the startrails.sh script from the root account. I opened permissions up on the startrails folder and made the startrails.sh script executable with the following command on the pi.
chmod -r 777 /home/pi/startrails
All that remained was to take the Raspberry Pi out to a remote location (I chose the Bramshill Plantation about 5 miles south of the town of Reading, in the UK) and point it north towards the Pole Star (you can use the Android skymap app or similar to aim the lens in the correct direction). I booted up the Pi, put the lid on its ice cream box and left it overnight with the camera running.
The next morning I returned to collect the equipment, covered in a thin layer of frost but unharmed. Booting up the Pi revealed that approximately 9 Gb of jpeg images (each image was approximately 2.5 Mb in size) had been stored to the /home/pi/startrails directory. The images were named XXXXXX.jpg where XXXXXX is the number of seconds since the raspistill command was launched that the exposure started. The first image was named 000001.jpg. I copied the images to a temporary folder on a linux laptop where I had installed imagemagick.
I then created a script called convert.sh in the temporary directory on the laptop, to invoke imagemagick's convert tool to repeatedly combine the images. Running the script took approximately 30 minutes and the resulting image was stored in /tmp/000001.jpg.
#!/bin/bash cp 000001.jpg /tmp for f in `ls *.jpg` do echo $f convert /tmp/000001.jpg $f -gravity center -compose lighten -composite -format jpg /tmp/000001.jpg done
Here is the final image scaled to 800x600 pixels. You can see that the stars appear to rotate around the Pole Star near the top of the picture, just as I had hoped. Unfortunately there are also a few other trails of light left by aircraft traveling across the camera's field of view.
The full jpg (2592 x 1944 pixels, ~4Mb) is available here. I will be experimenting in future with some different settings on the Raspberry Pi and some different post-processing steps to see if I can improve on these results further.