|
META TOPICPARENT |
name="WebHome" |
The Neo 6M GPS receiver |
| Here is a photo of the device:
 |
|
> > | Reading NMEA sentences with the ESP32
Once the connection is made and the UART instantiated all you need is an endless loop to read the UART line by line. This is what you will see if you print the result:
These are sentences of the NMEA protocol. You will need a parser that extracts the relevant information from these messages. It is not too difficult to write such a parser yourself but why do you want to do it if the job has already be done for you? In fact Peter Hinch has a github repository with gps drivers containing all you need:
https://github.com/peterhinch/micropython-async/tree/master/gps
He uses the NMEA parser from https://github.com/inmcm/micropyGPS but adapted it to his asynchronous driver. |
| Connecting the GPS receiver to your PC
In order to read out the GPS receiver from the PC we need a USB to serial converter: |
|
gpsd |
|
< < | The GPS daemon gpsd connects to a GPS receiver and provides its data to clients over a TCP connection.You can find it on https://gpsd.gitlab.io/gpsd/index.html
Reading NMEA sentences with the ESP32 |
> > | While u-center is a Windows application and can only be run on Linux through Windows emulation, there is also a GPS suite that runs natively on Linux named gpsd. |
| |
|
< < | Once the connection is made and the UART instantiated all you need is an endless loop to read the UART line by line. This is what you will see if you print the result: |
> > | The GPS daemon gpsd connects to a GPS receiver and provides its data to clients over a TCP connection.You can find it on https://gpsd.gitlab.io/gpsd/index.html. |
| |
|
< < |  |
> > | Check the gpsd documentation and in particular INSTALL.adoc and build.adoc in the source repository for information on how to build and install gpsd. |
| |
|
< < | These are sentences of the NMEA protocol. You will need a parser that extracts the relevant information from these messages. It is not too difficult to write such a parser yourself but why do you want to do it if the job has already be done for you? In fact Peter Hinch has a github repository with gps drivers containing all you need: |
> > | Once installed we first make sure that the daemon is not already running:
systemctl stop gpsd systemctl stop gpsd.socket |
| |
|
< < | https://github.com/peterhinch/micropython-async/tree/master/gps |
> > | To check that the GPS receiver is sending data we can check with gpscat:
gpscat -s 115200 /dev/ttyUSB0 |
| |
|
< < | He uses the NMEA parser from https://github.com/inmcm/micropyGPS but adapted it to his asynchronous driver. |
> > |
Then we can run gpsd as a foreground process (-N), specify the baud rate (-s 115200) and the serial port to which the neo 6M is connected (/dev/ttyUSB0):
gpsd -N -s 115200 /dev/ttyUSB0
Once the daemon is running we use gpspipe to see the NMEA sentences on the console:
gpspipe -r
This time the the NMEA sentences are not picked up from the USB to serial converted but from the TCP/IP port 2947 where gpsd provides information to its clients.
Now that we know that gpsd is working normally we can start gspmon which extracts basic GPS information like latitude, longitude, altitude and time and some information about the satellites seen.
Finally we run xgps to give us a graphical representation of the satellites in the sky.
More programs are part of gpsd but I will let you discover those yourself.
Showing GPS position information on a map
There is a nice tutorial from the Linux journal describing how to use gpsd when taking GPS information from a mobile phone:
What we will try to do is taking the data from the ublox neo 6M connected to the PC through the USB to serial connection instead of using the mobile phone.
The strategy will be this:
- Get the GPS data from the neo 6M connected through a USB to serial adapter connected to the PC and send the information to gpsd
- Run gpsmon to verify that the data are seen.
- Send the data to OpenStreetView and display them in marble
.
- Move the neo 6M to the ESP32 and write a program that transfers the NMEA sentences to gpsd running on the PC through a tcp socket.
Following the tutorial step by step here is a screen dump of the result:
 |
|
-- Uli Raich - 2020-07-01 |
|
META FILEATTACHMENT |
attachment="u-center.png" attr="" comment="" date="1598177875" name="u-center.png" path="u-center.png" size="190473" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="nmeaPC.png" attr="" comment="" date="1598177877" name="nmeaPC.png" path="nmeaPC.png" size="110073" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="dosdevices.png" attr="" comment="" date="1598177877" name="dosdevices.png" path="dosdevices.png" size="93199" user="UliRaich" version="1" |
|
|
> > |
META FILEATTACHMENT |
attachment="gpsmap.png" attr="" comment="" date="1598294383" name="gpsmap.png" path="gpsmap.png" size="186619" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="gpsmon.png" attr="" comment="" date="1598294388" name="gpsmon.png" path="gpsmon.png" size="94988" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="gpspipe.png" attr="" comment="" date="1598294745" name="gpspipe.png" path="gpspipe.png" size="109475" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="gpscat.png" attr="" comment="" date="1598294401" name="gpscat.png" path="gpscat.png" size="93425" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="xgps.png" attr="" comment="" date="1598294733" name="xgps.png" path="xgps.png" size="143391" user="UliRaich" version="1" |
|