Sony’s Spresense board sports many powerful features; one of them is GNSS connectivity, which provides precise satellite-fed data on the current position on the board, along with other useful information (for example, the current time).
Zerynth offers an example that can get you started with Spresense’s GNSS functionality in seconds in a few lines of Python code.
If you haven’t done that already, make sure to connect, register and virtualize your board with Zerynth Studio. You can find more info on how to get started with Sony Spresense and Zerynth in this tutorial.
Then just clone the “GNSSData” example from Zerynth’s Example Library, connect the board to your computer, and uplink the program to the board. You can find more info about the library of this driver in the official documentation.
After opening the Serial Monitor in Zerynth Studio, you should see the value acquired from the satellites:
Here is the example’s code:
Of course, this is just the start: you can use the data collected by the board to power an application that performs live tracking on a map!
Let’s do that with Jupyter.
First of all, we need to install Jupyter, along with gmaps and PySerial:
Once that’s done, we can uplink the following firmware to the Spresense board:
And then, by running the following Jupyter notebook, we can see the position of the Spresense on a map in real-time:
To generate a Google Cloud API key follow this tutorial.
You can change the values of the center and the zoom level to customize the display of the map:
For this second script you will need to ensure that the path to the serial device is the right one; in our case, it’s /dev/tty.SLAB_USBtoUART.
Note that you might have to wait a bit for the Spresense to acquire enough satellite signals for it to be able to display the right position.
Here are some general things to be aware of when testing your GNSS application:
- The receiver needs to find at least four satellites to be able to determine its position.
- Make sure you have a clear sky. The receiver will have a hard time finding a satellite if there is something blocking the way, such as a roof.
- Try to avoid obstructions around you. Satellites may be positioned low towards the horizon and e.g. buildings with lots of concrete, metal girders etc could block them from the receiver.
- Depending on the conditions and the state of the device it might take minutes to get a fix, so please be patient.
If you want to add more sensors to the mix, you can add the data you want to show to the Python dictionary that the Spresense board sends over the serial connection, and then visualize it with Jupyter.