Combine PocketC.H.I.P. with a GPS module and know exactly where you are, wherever you are. (Unless, of course, you’re in a cave. GPS and caves don’t really mix.)
Scott, one of the NTC hardware engineers, was tinkering with a GPS module from our lab the other day, and in no time at all he had the little module output its longitude and latitude to PocketC.H.I.P.. This project takes about an hour if you’re new to soldering and software setup, and it’s a great way to expand the capabilities of PocketC.H.I.P..
GPS is an extremely powerful technology and with Scott’s project it’s pretty easy to enable PocketC.H.I.P. with GPS information. Since GPSd (the software you’ll learn how to use and setup) is an extremely customizable program, there are bound to be interesting ways you can extend this project and make it even better. For example, why not pull the coordinates from GPSd and feed them into the Pokemon tracker or figure out a way to pass the data to a PICO-8 game?
This isn’t the cheapest build we’ve done. The GPS module alone will set you back around $40. But Scott has constructed the project in such a way that you can easily disassemble and reuse all the components –most especially the pricey GPS unit.
- Wire snips
- Soldering iron and solder
- Heat shrink tubing
- Lighter (or hot air gun)
- Hot glue gun and glue
The goal of this step is to add female jumper wires to the GPS module. This will make it easier to work with the module and to combine it with the USB USB-to-Serial module.
Cut and strip the end of each individual wire from the module. Slide a small bit of heat shrink tubing over each wire and move the tubing away from where you’ll be soldering –you don’t want your soldering iron to accidentally shrink the tubing just yet.
Identify each wire by consulting the datasheet. Combine the two GND (or ground) wires by physically twisting them together. Then solder a female jumper wire to them. The result is two wires from the module output as one female jumper wire. With the soldering done, slide the heat shrink tubing over the solder joint and use a lighter (or heat gun) to shrink the tubing.
Solder the remaining three wires of the GPS module to their own female jumper wires and don’t forget the heat shrink tubing.
Note: Scott added the female jumper wires to the GPS module and used a USB-to-Serial module to make this project more reconfigurable. You could solder the GPS directly to the PocketC.H.I.P. UART, but you’d have to configure more software and you wouldn’t be able to easily disassemble the build.
Connect the female jumper wires from the GPS module to the USB-to-Serial module. The wires need to connect the two GND (ground) pins on the GPS module to the GND pin on the USB-to-Serial. VIN (short for “voltage in”) connects to 5V. The TX and RX wires are crossed over between the two modules i.e. RX connect to TX and vice versa. The GPS NC pin doesn’t connect to anything — NC is short for no connect.
- GND to GND
- VIN to 5V
- RX to TX
- TX to RX
- NC means no connection
The only wiring left to do is plug the USB connector on the USB-to-Serial module into PocketC.H.I.P.. That’s it! Now it’s time for software.
There are many different options for attaching the GPS module to PocketC.H.I.P.. While Scott wanted this project to be easy to disassemble, he ended up using cyanoacrylate (better known as Super Glue).
The way the GPS module is housed, it’s not too difficult to pry the module off without damaging it or PocketC.H.I.P.. Plus, there’s really no way for the module to accidentally fall off — a problem with some of the more temporary velcro methods.
Note: Whatever you do end up using to secure the module to PocketC.H.I.P. make sure that you don’t cover up the exposed GPIO header pins. Or, if you do, that you have ample shielding between the GPS housing and the bare metal of the pins.
Before you get too deep into the software setup, make sure that Linux is detecting your USB-to-Serial module. This module is the main link between PocketC.H.I.P. and the GPS, so if it’s not detected, there’s no way you’ll be able to communicate with the GPS.
Run the following command, which polls the system and outputs any detected USB devices.
Look at the output and verify that PocketC.H.I.P. is properly detecting the USB-to-Serial cable. You should see output similar to what’s in the screenshot above.
Ensure that your PocketC.H.I.P. has a list of the latest software packages by tapping the Terminal application on the home screen and typing in the following command and pressing enter.
sudo apt update
You’ll be prompted for your sudo password, which by default is chip.
Note: While you can use the PocketC.H.I.P. keyboard to complete the project, some people prefer to set up an SSH server and connect wirelessly to PocketC.H.I.P. from their laptop. One advantage of this method is that you can easily cut and paste into an SSH session.
sudo apt install ssh installs an SSH server and you can then follow these instructions to use SSH and PocketC.H.I.P..
The main software package you’ll be using is GPSd. GPSd monitors the serial port for any GPS modules and, if there’s GPS data, it makes it available to PocketC.H.I.P.. The command below also installs some packages to help organize and view the raw GPS data.
sudo apt install gpsd gpsd-clients python-gps
Note: GPSd is a powerful tool and it even has a rad hacking section of its website. It’s not to be missed!
Systemd controls certain low-level services that run on PocketC.H.I.P., like when networking gets initialized and when to start the GUI Pocket Home.
In the case of GPS, you actually want to stop and disable the Systemd service. If you left it running, it would interfere with the GPSd program and you wouldn’t be able to see the GPS data.
sudo systemctl stop gpsd.socket
sudo systemctl disable gpsd.socket
To start the GPSd run the command below.
sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock
Note: You’ll need to run this command each time you restart PocketC.H.I.P. and want to use the GPS.
To connect to the GPSd so that you can see the GPS data, simply type the following command and press enter.
Note: Depending on the font size you’ve set your Terminal to display, you may need to adjust the resolution. To increase the size, tap the magnifying glass with a plus in it. To decrease the size, tap the one with a minus.
Whether you integrate this project with the Pokemon tracker or pull the coordinates into a PICO-8 game, whatever you do with PocketC.H.I.P., make sure to share it! Send us a tweet, share it on Facebook, or join the conversation in the forums.