Skip to content

Instantly share code, notes, and snippets.

@jkutner
Last active January 19, 2024 19:09
Show Gist options
  • Save jkutner/da0cd7046719dd9be6e92215738c0539 to your computer and use it in GitHub Desktop.
Save jkutner/da0cd7046719dd9be6e92215738c0539 to your computer and use it in GitHub Desktop.
Turn a Raspberry Pi into an Astrophotography Autoguider

UPDATE (2021-03-31): I've posted an improved version of this guide with newer versions of the software.

Turn a Raspberry Pi into an Astrophotography Autoguider

@codefinger

I hate when my images turn out like this:

Drift

You can barely see the Crab Nebula drifting through the frame because I didn't align my mount well. To keep my telescope fixed on an object during long exposures, I needed an autoguider. But I also hate having a laptop in the field, which is required for most autoguiding solutions. To avoid this burdensome piece of equipment, I turned a Raspberry Pi with a touchscreen case into an on-board autoguiding system for my astrophotography rig. 

Astrophtography Rig

The autoguider is the little white rectangle attached to the mount.

I'm using an Orion ED80, a Canon 70D, and a Celestron CGEM II on wheels so I can roll it out onto my driveway. The autoguiding system includes:

With this hardware, all I needed to do was install the software. Here's how I did it:

Step 1: Install Raspbian Stretch

Stretch is the operating system for the Raspberry Pi. To install it, follow the official instructions. All of the commands in the steps that follow are run from a terminal session on the Raspberry Pi.

Step 2: Install libnova 0.14

The default version on Stretch is 0.16, but the Atik INDI driver is linked to 0.14. For that reason, we need to download the Debian package for libnova 0.14 and install it:

$ curl -OL http://http.us.debian.org/debian/pool/main/libn/libnova/libnova-0.14-0_0.14.0-2.1_armhf.deb
$ sudo dpkg -i libnova-0.14-0_0.14.0-2.1_armhf.deb
$ curl -OL http://http.us.debian.org/debian/pool/main/libn/libnova/libnova-dev_0.14.0-2.1_armhf.deb
$ sudo dpkg -i libnova-dev_0.14.0-2.1_armhf.deb

Step 3: Install Git

Because we'll need to compile and build some software from source code, we need to install Git to download the code for the projects:

$ sudo apt-get install git

Step 3: Build INDI

The first project we need to build from source is INDI, which allows the Raspberry Pi to connect to my camera and mount. To begin, we'll install INDI's dependencies (note: libnova-dev is exclude to ensure the correct version installed earlier):

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

Now we can get the source code (I built with v1.7.4, 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 origin/v1.7.4 -b v1.7.4

And build:

$ mkdir -p build/libindi
$ cd build/libindi
$ cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug ../../libindi
$ make
$ 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.26-armhf.deb
$ sudo dpkg -i atikccd-1.26-armhf.deb

Step 5: Build PHD2

Now we can install PHD2, the autoguiding software. First, install its dependencies (I've exclude libindi-dev and libnova-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.5 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 origin/v2.6.5 -b v2.6.5

And build:

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

I built with all drivers (including ones I don't need like QHY and ZWO). It's likely I could have run the following command instead:

$ cmake -DOPENSOURCE_ONLY=1 ..

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

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.

This setup is perfect for me. I can roll my entire rig into my driveway and start imaging in just a few minutes.

If you don't want to build you're own autoguider, you might consider the Lacerta MGEN II, which is the only solution I know of that doesn't require a laptop.

Update (July 2020): QHY PoleMaster

I've added a QHY PoleMaster to my rig, and I've update the Pi to run the software for it. The PoleMaster helps me get an almost perfect polar alignment. I tried using the tools built into PHD2, but I could never get them to work well.

QHY provides an entire Raspberry Pi image for the PoleMaster (including the operating system), but I didn't want to use that image because I already have my PHD2 set up. I wanted to add the PoleMaster software to my existing system. Here's how I did it:

Step 1: 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 2: 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 3: 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!

Using the program from my 7" Touchscreen Display is a bit of a pain, but it can be done. I had to connect a mouse in order to double-click Polaris, so I used a Logitech Trackball that I keep in my pocket. That way I don't need a table in the field.

@Gianca48
Copy link

Gianca48 commented Jan 9, 2020

Great! I’ve an ASI120MM from ZWO, how can I mod sw!.

@dustinjbailey
Copy link

Really excited to try this out. I’m using a star adventurer, so could I get by with only installing PHD2, or do I still need to install INDI and libnova?
(I have no idea what I’m doing)

@jkutner
Copy link
Author

jkutner commented May 25, 2020

@dustinjbailey I believe you will only need PHD2 as long as it automatically works with your guide camera (assuming you have an RJ12 cable going from your camera to the mount). What guide camera do you have?

I actually have a Star Adventurer too, but I've never tried this setup with it. Please let me know how it works out.

@dustinjbailey
Copy link

dustinjbailey commented May 25, 2020 via email

@Pnwastrootter
Copy link

Thanks for the response! I’m using the Orion star shoot auto guider. It does work with PHD2 through my laptop right now and with the RJ12 cable. I’m working on this project with my mom and brother, we all pitched in together to get the gear. We got an OK shot of the pinwheel galaxy last night on our first try using the system. I’m going to use my raspberry pi 4 to try to eliminate the laptop from our set up via your tutorial. I’ll let you know how it goes. One last question though, would I be able to connect to the pi wirelessly using my iPad or iPhone as the screen, instead of buying a touch screen? Or is that another tutorial in itself? 😑 Thanks again!
On Sun, May 24, 2020 at 8:06 PM Joe Kutner @.> wrote: @.* commented on this gist. ------------------------------ @dustinjbailey https://github.com/dustinjbailey I believe you will only need PHD2 as long as it automatically works with your guide camera (assuming you have an RJ12 cable going from your camera to the mount). What guide camera do you have? I actually have a Star Adventurer too, but I've never tried this setup with it. Please let me know how it works out. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://gist.github.com/da0cd7046719dd9be6e92215738c0539#gistcomment-3316730, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOC6TEQOQHTWTVEKUP7BLR3RTHADHANCNFSM4KETSAYQ .
-- Dustin J. Bailey Architectural Photographer 605.595.2321 - www.dustinjbailey.com

very curious if you were able to get it work. i'm watching some listings for the same guider and i use the star adventurer exclusively since i backpack. I'm hoping to take on this project specifically so i can have something to use while backpacking with my dslr and william optics telescope i just ordered. should be fun since i have no coding experience.

@TigerClaw33
Copy link

Hi,

is there a possibility to build the guider with an ZWO 178? And can I use the guided separately from mount which is controlled with my smartphone with WiFi adapter instead of a stable and a notebook?

Thanks

@astro-moose
Copy link

Hi,

is there a possibility to build the guider with an ZWO 178? And can I use the guided separately from mount which is controlled with my smartphone with WiFi adapter instead of a stable and a notebook?

Thanks

Hello tiger, i ve compiled PHD2 last week using the ZWO Asi 187MC as an guiding cam - we are finally working on the same solution as jkutner - i will report if we are ready :-)

regards from Austria!

@astro-moose
Copy link

Hello, we can now say it works flawless with the ZWO Asi 178MC.

@astro-moose
Copy link

@jkutner Hello, may i ask - how did you solve the Problem with PHD2 and the touch display? I cannot reach the OK and cancel buttons in some menues, the resolution of the touch display is not as great as PHD demands... we tried the funniest things but my LINUX-Expertise ist hm - not even moderate... ;-)

@jkutner
Copy link
Author

jkutner commented Jul 26, 2021

@astro-moose oh, I hate this problem with the OK/cancel buttons. But I've been able to workaround it by doing most things with an external display connected (a large one) and then setting everything as default so that I don't need the menus in the future. In one case, (setting up new equipment) I connected a keyboard and was able to memorize the number of times I need to hit Tab and then Return.

Thanks for the information about the ZWO Asi 178MC! I plan to buy a ZWO ASI290MM Mini soon.

@astro-moose
Copy link

@jkutner i see. well, i left a note at the fb-group related to PHD2 with "our" problem, probably some of the developers reads it :-)

@astro-moose
Copy link

@jkutner Hello Joe, i found a solution for our "hidden ok button"-issue:

https://forums.raspberrypi.com/viewtopic.php?f=108&t=184762

The size of the content is slightly smaller but hey - it works :-) Having keyboard and mouse within the Raspy is no bad idea anyway...

greetings and clear skies, Gerhard

@jkutner
Copy link
Author

jkutner commented Dec 2, 2021

@astro-moose awesome! thanks for sharing. I ended up buying wireless logitech keyboard+trackpad. this will go great with it.

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