Automatic connection of Bluetooth controller

A project log for Raspberry Pi Driven Telescope Mount

full telescope control over WiFi using INDI on a RPi Zero W

Dane GardnerDane Gardner 05/28/2017 at 00:030 Comments

I was having problems with consistent connections of the Bluetooth controller, and found that despite configuring calibration settings at boot time, they were lost if the device wasn't already connected. I ended up writing a script that could be run periodically using a cron job that would attempt to connect the joystick if it wasn't already, and then calibrate it if it wasn't already.

Here's the complete code:

Save that file to your home directory on the Raspberry Pi, and ensure that it's executable. Then add a cron job that runs every minute using `crontab -e` at the command line:

* * * * * ~/

Now, if your joystick isn't on and ready to connect when you start your telescope, it will take a maximum of one minute before it's discovered, connected, and configured once you do turn it on!