Skip to content

Instantly share code, notes, and snippets.

@willbarton
Forked from jkutner/raspberry-pi-autoguider.md
Created October 22, 2022 17:26
Show Gist options
  • Save willbarton/3e35f885c491c08fc13a97be78016431 to your computer and use it in GitHub Desktop.
Save willbarton/3e35f885c491c08fc13a97be78016431 to your computer and use it in GitHub Desktop.
Raspberry Pi Autoguider for Astrophotography

This is an update to an older post about how to Turn a Raspberry Pi into an Astrophotography Autoguider. I rebuilt my autoguider from scratch with newer versions of the software. It's even a bit easier now.

Step 1: Install Raspberry Pi OS

Follow the official instructions and install the "Raspberry Pi OS with desktop and recommended software". All of the commands in the steps that follow are run from a terminal session on the Raspberry Pi.

Step 2: Install Git

You'll need to compile and build some software from source code, which requires Git to download the code for the projects:

$ sudo apt-get install git

Step 3: Build INDI

The first project you need to build from source is INDI, which allows the Raspberry Pi to connect to my camera and mount. To begin, install INDI's dependencies (note: in the previous version of this post, I had to install a specific version of libnova, but that's not required anymore):

$ sudo apt-get install -y libnova-dev libcfitsio-dev libusb-1.0-0-dev zlib1g-dev libgsl-dev build-essential cmake git libjpeg-dev libcurl4-gnutls-dev libtiff-dev libfftw3-dev

Now you can get the source code (I built with v1.8.9, but v1.4.1 is supposed to be the version used with the Atik INDI driver. I guess they both work):

$ cd ~
$ git clone https://github.com/indilib/indi
$ cd indi
$ git fetch --tags
$ git checkout v1.8.9 -b v1.8.9

And build:

mkdir -p ~/build/indi-core
cd ~/build/indi-core
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug ~/indi
make -j4
sudo make install

Step 4: Install the Atik INDI Driver from CloudMakers

Because I'm using an Atik camera, I need the Atik driver for INDI, which is maintained by the good folks at CloudMakers:

$ curl -OL http://download.cloudmakers.eu/atikccd-1.30-armhf.deb
$ sudo dpkg -i atikccd-1.30-armhf.deb

Step 5: Build PHD2

Now we can install PHD2, the autoguiding software. First, install its dependencies (I've exclude libindi-dev to ensure the correct versions above):

$ sudo apt-get install build-essential git cmake pkg-config libwxgtk3.0-dev wx-common wx3.0-i18n gettext zlib1g-dev libx11-dev libcurl4-gnutls-dev

Now get the source code (I used 2.6.9 because it was the latest stable at the time. No other reason):

$ cd ~
$ git clone https://github.com/OpenPHDGuiding/phd2
$ cd phd2
$ git fetch --tags
$ git checkout v2.6.9 -b v2.6.9

And build:

$ mkdir -p tmp
$ cd tmp
$ cmake ..

In any case, the next step is to install the compiled package:

$ sudo make install

Step 6: Start the INDI Server

We're ready to run the autoguider, but first we need to start the INDI server, which exposes an interface to the camera and mount:

$ indiserver indi_atik_ccd indi_celestron_gps

Note: You can add -vvv to get detailed logging. This helps if you're having trouble in the next step.

Step 7: Run PHD2!

Start the program by running:

$ phd2

The program will prompt you with a dialog to setup your camera and mount. Once you've finished, be sure to export the profile because I tends to get wiped when the program can't connect to the INDI server.

Step 8: Make a script to start it all in one click

I created a script that I keep on my desktop to launch both INDI and PHD2 in one step. Create a start.sh file and put the following code in it:

#!/bin/bash

indiserver -vv indi_atik_ccd indi_celestron_gps &
phd2

Then run the following from a terminal session:

$ chmod +x ~/Desktop/start.sh

Option: Install QHY PoleMaster

It's a little difficult to use the PoleMaster software on a 7-inch display, but it works.

Step 1: Install OpenCV 2.4

The default version of libopencv-imgproc and libopencv-core on Raspberry Pi OS is 3.x, but the QHY software is linked to version 2.4. You can install 2.4 with these commands:

$ curl -OL http://http.us.debian.org/debian/pool/main/o/opencv/libopencv-core2.4v5_2.4.9.1+dfsg1-2_armhf.deb
$ sudo dpkg -i libopencv-core2.4v5_2.4.9.1+dfsg1-2_armhf.deb
$ curl -OL http://http.us.debian.org/debian/pool/main/o/opencv/libopencv-imgproc2.4v5_2.4.9.1+dfsg1-2_armhf.deb
$ sudo dpkg -i libopencv-imgproc2.4v5_2.4.9.1+dfsg1-2_armhf.deb

Step 2: Install the QHYCCD SDK

Download and unzip SDK Installer:

$ curl -OL https://www.qhyccd.com/uploadfile/2018/1222/20181222054316365.zip
$ unzip 20181222054316365.zip

Inside of the zip file is a rar file that the QHY instructions don't tell you about. The rar format is pretty obscure, and there are different versions of it. The format QHY uses is 3.0, which doesn't work with the unrar-free package you can install by running apt install unrar-free. There is appearently an unrar-nonfree you can install, but I decided to extract the rar file on my Mac (using The Unarchiver.app) and transfering the extracted files to my Raspberry Pi via a file server. This is pretty ugly.

Once you have the extracted rar file contents, you can run the install.sh script

$ sudo ./install.sh

Step 3: Install the PoleMaster Package

Download and unzip the PoleMaster Debian package:

$ curl -OL https://www.qhyccd.com/uploadfile/2018/1222/20181222054634222.zip
$ unzip 20181222054634222.zip

Then install the package using the dpkg command:

$ sudo dpkg -i PoleMaster_Qt-for-RPI-Ubuntu-1.3.5.0.deb

After the installation is complete, move into the /usr/bin/PoleMaster directory and check if it was successful.

$ cd /usr/bin/PoleMaster
$ ldd PoleMaster

Make sure all the listed dependencies map to a file location. If they aren't, you'll see a message like:

libqhyccd.so.4 => (file not found)

Step 4: Run the PoleMaster Software!

First, confirm that your PoleMaster device is plugged into the Pi by running:

$ lsusb

You should see a line like:

 Bus 0001 Device 009: ID 1618:0941

This line means the PoleMaster is connected.

Now run the PoleMaster software (I put this in an executable script on my desktop that I can double-click):

$ sudo /usr/bin/PoleMaster/PoleMaster

When program starts up, open the Device menu and click Connect. You're ready to polar align!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment