Jetson nano uses Python to read and parse GPS data (GPRMC, gpgga).

I am writing an article for the first time, mainly records the process of this code, the requirements of the teacher is on the nano version of reading to the GPS data from the python and parses the latitude and longitude, the rate and the number of satellite late by GUI graphical and less on the reading of the GPS in the nano tutorial, there are also the article use the GPS module but is not conducive to I work late, so their imitation has written a series of simple code.

first download and install cutecom to see if nano has read the GPS data. Use the command:

sudo apt-get install cutecom

is followed by Nano installation of pthon3-serial and pynmea2.

I remember using sudo apt-get intsall python3-serial last night, but PIP install pyserial

is also available online

as for which can try by itself, I think this process is not important, as long as pyserial is installed successfully, pyserial is understood to be python serial communication module, through which we can read the serial port tool.

for installation of pynmea2

I want to mention that the file PIP is not found with PIP, but rather we use python3 and PIP should be called pip3 so that the installation is successful. Pynmea2 is understood as a third party module for handling the NMEA 0183 protocol. Used by us to resolve the NAME 0183 protocol. this is my reference page. And then you write your own code.

is first to import two downloaded modules, followed by import time module, I don’t know what is the use is to follow them to add.

the ser is a serial port assignment in ser (about this), the first one is behind your serial port of the serial port is usually ttyTHS1 USB is usually ttyUSB0 these names should be available through cutecom, the second is the baud rate I use the default 115200 online is a lot of the people followed 9600 change, the timeout I followed others change, I feel it doesn’t matter how much I feel OK. This is followed by a while statement. Line 8 USES pyserial to read the serial data and assign it to the line variable, line 9 because line reads bytes and then needs to be changed to a string (that’s about it), followed by the GPRMC in the two if statements. This is what you read using GPS, line 11 USES pynmea2.parse () to parse

let me mention why I use this instead of using lists like many other tutorials on the web. The main reason is that I think GPS signals can be unstable and lead to parsing errors. This method is also very useful, but I just don’t know if it will go wrong. If you add a break at the end of the if statement, you can stop the loop, because there are two if statements here. We’d better add a break at the second if. If you add a break at the first if, it will make the second if unusable, then it will just exit the while statement.

18 is saved into TXT file at the beginning, mainly I have been written in a+ way, at the beginning I was using W or W+ to try to find TXT only GPGGA data after the interview. 19 changed to STR, because Python can only be a string, 20 is a blank line, 21 needs to be saved.

. Well, that’s about it. I won’t go into much detail. Don’t understand can go baidu once. First time write success, go to the next refueling!

Read More: