I would like to ask if it possible to get NMEA code/string from a GPS module that connected to one of the GPIO of a Raspberry?
2 Answers
You don't mention which GPS module you have, so I can not provide a definitive yes, but given the right GPS module it is possible using the UART (tx/rx pins). Another alternative depending on your module is to use one of the USB ports (either directly connected for modules that have a usb cable or via a USB to TTL cable). Adafruit has a complete tutorial covering the use of a GPS module with the Raspberry Pi.
-
hi @SteveRobillard right now my collegue told me that our GPS antenna provide NMEA code/string by means of its either TTL and RS323– CeciliACommented Jan 9, 2017 at 5:23
-
-
-
Sir @SteveRobillard is there a way i can get the NMEA string using python?– CeciliACommented Jan 9, 2017 at 5:34
-
1Don't be sorry take it as a lesson learned, we were all noobs once and I learned this lesson from the very first system administrator I ever worked with. Commented Jan 9, 2017 at 6:29
Getting GPS's Data: GPS receives data from output NMEA0183, tcp: // 2947, class: TPV & amp; tag: GPGGA.
Next is the step in the terminal to access GPS data:
- Install: gpsd, gpsd-clients. (Note: install both use apt-get install)
- Reboot (sudo reboot or sudo init 6)
- Sudo dpkg-reconfigure gpsd (Note: configuration baudrate = 9600, 8 N 1 data format).
- Serial tests with the command: gpspipe -r or cat /dev/ttyS* or /dev/ttyUSB* (Note: the * sign matches the read, use command ls /dev/ttyS*, /ttyS*, /ttyAMA* or /ttyUSB* or others).
If point 3 fails, stop and disable socket 2947 for a while. Try to type with the command & then reboot Raspberry Pi immadiately:
$ sudo systemctl stop gpsd.socket
$ sudo systemctl disables gpsd.socket
Then start and enable gpsd socket with command:
$ sudo systemctl start gpsd.socket
$ sudo systemctl enables gpsd.socket
Start daemon using command:
$ sudo gpsd /dev/ttyS0 –F /var/run/gpsd.sock
For live straming:
$ cgps –s or $ cgps or gpsmon
In practice way to get stream data GPS from NMEA Output, you can also use a simple command:
$ timeout 10s gpspipe -w -n 10 | grep -m 1 speed
$ timeout 10s gpspipe -w -n 10 | grep -m 1 speed | jq
Using json query / jq for pretty printing.
In python script:
def getGPS():
gpspipe= "timeout 10s gpspipe -w -n 10 | grep -m 1 speed"
p = subprocess.Popen(gpspipe, stdout = subprocess.PIPE, shell = True)