-
1Install the Sense Hat
Push the Sense Hat onto the Pi's GPIO header. Be careful to put it on straight so you don't bend any pins.
-
2Put the Pi into your case
This is a no-brainer. Note, though, that if you're using the case from my parts list, which is designed to fit a Pi with a hat, you'll have to remove the clear plastic window on top, or drill a small hole. The Sense Hat's joystick is just a bit too tall to allow the case to close completely. However, I haven't found operating without the lid to be a problem.
-
3Connect the Pi to a monitor, keyboard and mouse
You'll need to do the first few steps of the configuration this way, though later you can switch to using the network to complete the project if you like.
-
4Power up and boot off of a clean Raspbian image
Write a clean Raspbian image to your favorite SD card. We don't need a lot of space, so 8GB should do just fine. I'm using Stretch, but if you want to use another version (or even another Linux distribution), feel free. You might have to make some minor adjustments to these build instructions, but the underlying software should still work.
Insert the card into your Pi, connect the power and wait for it to boot up. You should notice that the Sense Hat shows a pretty rainbow pattern when it's first powered up.
-
5Configure the base OS settings
Once you've booted Raspbian, connect it to your network. I recommend WiFi, as it'll be more convenient for you to log in later, but a wired connection should also work.
If you plan to complete the rest of the instructions remotely (e.g., without using an attached monitor/keyboard), now's also a good time to enable either SSH or VNC, according to your taste.
You can also go ahead and set any other system options you need. For example, I have to set my keyboard layout to US English. You can also set the system time zone if you like, but we use UTC time from the GPS for planet-finding anyway, so it's optional.
I'm a computer security guy by day, though, so let me just say.... SET A GOOD PASSWORD FOR THE 'pi' USER!
-
6Apply updates and install necessary software
In the terminal, type the following commands to update all your current packages and to add the new ones you'll need:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gpsd gpsd-clients python-gps
sudo pip install pyephem
-
7Plug in your GPS and make sure it's working
In the previous step you installed GPSD, the standard Linux daemon for interfacing with GPS hardware. Now we need to make sure it's working.
First, plug in your USB GPS. Nothing visible will happen on the screen, but if you examine the last several lines in /var/log/syslog, you should see that the system has recognized it. For example, here's what appeared in my log:
Sep 15 10:41:51 planetfinder kernel: [ 420.947199] usb 1-1.2: new full-speed USB device number 7 using dwc_otg
Sep 15 10:41:51 planetfinder kernel: [ 421.079504] usb 1-1.2: New USB device found, idVendor=1546, idProduct=01a7
Sep 15 10:41:51 planetfinder kernel: [ 421.079519] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Sep 15 10:41:51 planetfinder kernel: [ 421.079527] usb 1-1.2: Product: u-blox 7 - GPS/GNSS Receiver
Sep 15 10:41:51 planetfinder kernel: [ 421.079535] usb 1-1.2: Manufacturer: u-blox AG - www.u-blox.com
Sep 15 10:41:51 planetfinder mtp-probe: checking bus 1, device 7: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2"
Sep 15 10:41:51 planetfinder mtp-probe: bus: 1, device: 7 was not an MTP device
Sep 15 10:41:51 planetfinder kernel: [ 421.213417] cdc_acm 1-1.2:1.0: ttyACM0: USB ACM device
Sep 15 10:41:51 planetfinder kernel: [ 421.214132] usbcore: registered new interface driver cdc_acm
Sep 15 10:41:51 planetfinder kernel: [ 421.214137] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
Sep 15 10:41:51 planetfinder systemd[1]: Created slice system-gpsdctl.slice.
Sep 15 10:41:51 planetfinder systemd[1]: Starting Manage ttyACM0 for GPS daemon...
Sep 15 10:41:51 planetfinder gpsdctl: gpsd_control(action=add, arg=/dev/ttyACM0)
Sep 15 10:41:51 planetfinder gpsdctl: reached a running gpsd
Sep 15 10:41:51 planetfinder systemd[1]: Started Manage ttyACM0 for GPS daemon.From this, you can see that not only did my system recognize the GPS as /dev/ttyACM0, but it also notified gpsd of the new device so it could start using it. Unless you have the same model GPS as I do, your device name is probably different, though it probably still starts with /dev/tty.
Since gpsd now knows about the GPS, try the gps client and see if it's recognized. In a terminal window, type the following command:
cgps
If the GPS is recognized, the client will print a bunch of info from your GPS. At first, it might just display the time until it acquires a lock on the satellites. Be patient. Getting a lock takes take, especially if you are indoors (try moving near a window). Still, if you're seeing the time, your GPS is working!
Press 'q' to exit the GPS client program.
-
8Calibrate the Sense Hat
The magnetometer (compass) and accelerometer (orientation sensors) in the Sense Hat need to be calibrated in order to work accurately. Although the Sense Hat software comes with a pre-calibrated config file, I've found that it didn't work well for me. Fortunately, calibrating the sensors is pretty easy.
Following the instructions in the official Sense Hat documentation, use the RTIMULibCal utility to calibrate both sensors. A few tips:
- Calibrating these sensors requires you to rotate the Pi across the full range of X, Y and Z axes. This is possible to do while it's hooked up the monitor and keyboard, but not much fun. If you enabled SSH or VNC in the earlier steps, now would be a good time to disconnect unnecessary wires.
- I didn't bother with the optional "calibrate magnetometer with ellipsoid" function, because it didn't work for me and the system worked OK without it. You can probably skip this. However, if you do get it to work, please leave a comment and let me know what you did!
- The accelerometer calibration isn't documented in the page I linked, but the instructions inside the utility itself will help if you read them carefully.
Once you've completed the calibration and exited the utility, it will create am RTIMULib.ini file in the current directory. You need to copy this into /etc so that it will be the default when you use the sensors later:
sudo cp /etc/RTIMULib.ini /etc/RTIMULib.ini.orig
sudo mv ./RTIMULib.ini /etc -
9Install and test the PiPlanetFinder software
Change to your home directory (probably /home/pi) and download the PiPlanetFinder software from GitHub:
cd
git clone https://github.com/DavidJBianco/PiPlanetFinder.gitThis will create a PiPlanetFinder subdirectory where all the files live.
Now test the software to make sure it runs (i.e. that you have installed all the necessary python modules):
cd PiPlanetFinder
./ppf.pyIf everything works well, you should see some debug output from the script in your terminal, and the Sense Hat LEDs should scroll "GPS". Eventually, once it acquires the GPS lock, you should see a green checkmark, though the LEDs may go dark while it's trying to contact the satellites.
If you got this far, everything's working!
-
10Ensure PiPlanetFinder runs at boot
Edit /etc/rc.local to add the following line just before the exit command at the end:
/home/pi/PiOrbitFinder/ppf.py &
Reboot the system and make sure the LEDs scroll "GPS" when it starts, and you're ready to go!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.