Introduction: Ublox SAM-M8Q GPS With Toit

Lots of IoT project requires position data to be collected, along with the actual sensor data. Toit comes with a ready-made driver for several ublox GNSS modules and things pretty much work out-of-the-box. In this instructable we'll learn how to hook up a ublox SAM-M8Q GNSS module to an ESP32 dev board, and get some position data in clear text.

Supplies

  • ESP32 dev kit. I like this one since it has a narrower form factor and is therefore better suited for breadboards. The form factor leaves breadboard-space on both sides of the dev kit for connections.
  • ublox Sara SAM-M8Q module

Step 1: Hooking Up the Hardware

The ublox SAM-M8Q model supports I2C which makes the connections really easy. Connect 3v3 and GND to the corresponding terminals, and connect GPIO 23 and 22 on your Huzzah ESP32 devkit to SDA and SCL, respectively, on the GNSS module.

Step 2: The Code

Some example code on how to get GPS position from the module can be found here:

https://github.com/nilwes/ublox_SAM-M8Qdemo

After cloning the repository, install the required driver package by running

$ toit pkg install github.com/toitware/ublox-gnss-driver

If you are curious about what other drivers that are available from Toit, please visit the Toit Package Manager at pkg.toit.io.

Step 3: Getting a First GPS Fix

Make sure you have line-of-sight from your GPS module to the sky. Note that also a glass window may block the extremely weak GPS satellite signals from reaching your module.

When you run the program it will display "getting location" on the serial output from the ESP32. The time to get the first fix (TTFF) may take several minutes if conditions are not optimal. When a first fix is aquired the position data begins streaming from the GPS module to the ESP32 and subsequently printed on the serial output.