Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Turn a Raspberry Pi into an Astrophotography Autoguider

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

This comment has been minimized.

Copy link

@Gianca48 Gianca48 commented Jan 9, 2020

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

@dustinjbailey

This comment has been minimized.

Copy link

@dustinjbailey dustinjbailey commented May 24, 2020

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

This comment has been minimized.

Copy link
Owner Author

@jkutner 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

This comment has been minimized.

Copy link

@dustinjbailey dustinjbailey commented May 25, 2020

@Pnwastrootter

This comment has been minimized.

Copy link

@Pnwastrootter Pnwastrootter commented Jun 20, 2020

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

This comment has been minimized.

Copy link

@TigerClaw33 TigerClaw33 commented Oct 27, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.