Amateur Astronomy and Imaging.

Projects > SunCam


Building upon the success of the all-sky cameras I have built in the past, I decided to turn my hand to a Sun Camera. I wanted to re-use as much of the all-sky camera interface and code as possible, so there are a lot of similarities between the two. Imaging the Sun requires very short exposures, so the Pi Camera is a perfect choice. The first task was to determine an appropriate image scale. To keep the project compact, I chose a ZWO 40mm finderscope. With the Pi camera this offers me a field of view approximately 3 solar widths high by 4 solar widths wide.

The most difficult part of the project was choosing the metalwork to build the pan/tilt frame. I struggle with the mechanical side of these projects, and excel at the technical/software aspects. I used Actobotics components to build the frame, but did spend about 200 collecting all the various parts. Once the framework was constructed I started work on the software.

Designing the software was very much an iterative process. The first task was to control the motors to position the camera. I decided the easiest way would be to carry out the alignment with the Sun manually through the web interface, and from that point on to track the Sun automatically. The code (written in C) determines the position of the Sun, and assumes the pan/tilt platform is aligned with the Sun. It calculates how far to move the motors to reach the new Sun position at set intervals as defined by the user. I found this worked, but not as well as I hoped. The main reason it didn't work reliably was caused by backlash in the gears. If the platform isn't level, this also affects positioning accuracy. To overcome this problem I added an option to automatically centre the Sun if it moves to far from the centre of an image. Each time an image is collected it determines whether the Sun is too far from the center of a frame and automatically repositions the platform if necessary. It took a while to get this code working reliably enough to cater for backlash, but after a lot of trial and error it would not track all day assuming the Sun is visible. If the Sun were to disappear behind the clouds for more than an hour or so it would have to rely on calculations alone to determine the Sun's position, and that is usually only reliable for less than an hour. I'm happy with this level of performance.


I use solar film to bring exposures down to an acceptable level and to avoid damage to the components. My C program determines the position of the Sun in the image and crops around the Sun's disc. This also helps ensure that the images stored all have the Sun positioned centrally regardless of how far from the image centre the Sun was in the actual exposure. I use a HoughCircles function in the OpenCV library for this purpose, and although it isn't always perfect, it is usually close enough.

It's a shame that a period of minimal solar activity coincides with the completion of this project (summer 2019). It is however, primed and ready for the Mercury transit later in the year. I just need to obtain a 12V batter to power the platform since I'll most likely need to find a better location than home to image in November when the Sun is low in the sky.

Suncam web interface

For those interested in the technical aspects of the project, I wrote the website in PHP styled with CSS. The website makes calls to a Python script to control the motors using an Adafruit hat. The motors are 12V Adafruit motors. Image capture is also through Python, but image post processing and analysis for automatic centring is carried out by my own compiled C code.

After setting the project for Solar imaging, I realised it should work just as well on the Moon, albeit without the solar filter. I updated the code to accommodate the moon too, and surely enough it works quite well.

Here is a sample image taken with the Suncam:

Final image taken through the camera before it failed