0

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?

techraf
  • 4,254
  • 10
  • 29
  • 41
CeciliA
  • 7
  • 1
  • 5

2 Answers2

3

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.

Steve Robillard
  • 34,158
  • 17
  • 102
  • 108
  • hi @SteveRobillard right now my collegue told me that our GPS antenna provide NMEA code/string by means of its either TTL and RS323 – CeciliA Jan 09 '17 at 05:23
  • read the linked tutorial – Steve Robillard Jan 09 '17 at 05:24
  • You can also search this site for nema – Steve Robillard Jan 09 '17 at 05:26
  • Sir @SteveRobillard is there a way i can get the NMEA string using python? – CeciliA Jan 09 '17 at 05:34
  • @CeciliA I understand you are just starting out as a developer and this is all new to you, but one of the skills you should already have an exercise first when you don't know the answer (all developers do this) is searching (google this site etc.). Only after doing the research should you ask the question. When my students/colleagues come to me with a question onee of the first things I ask is what have you tried. In this case a quick google search will likly answer your question https://www.google.com/search?q=nmea+strings+python+raspberry+pi&ie=utf-8&oe=utf-8. – Steve Robillard Jan 09 '17 at 05:57
  • Sorry @SteveRobillard :( – CeciliA Jan 09 '17 at 06:27
  • 1
    Don'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. – Steve Robillard Jan 09 '17 at 06:29
  • The USB port is the best option. It works. – SDsolar Jan 10 '17 at 02:21
  • I have not tried using the GPIO yet, but I think so. I got it through USB-RS232 adapter. You can easily check it with a command from your linux / mac / putty: Screen /dev/tty.usbserial-FTG62868 4800 Change tty.usbserial-FTG62868 through your COM port NMEA0183 goes at a speed of 4800 baud I connected Garmin GPS to the RaspberryPi without problems – cthemudo Jul 25 '17 at 08:40
1

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:

  1. Install: gpsd, gpsd-clients. (Note: install both use apt-get install)
  2. Reboot (sudo reboot or sudo init 6)
  3. Sudo dpkg-reconfigure gpsd (Note: configuration baudrate = 9600, 8 N 1 data format).
  4. 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).
  5. 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

  6. Then start and enable gpsd socket with command:

    $ sudo systemctl start gpsd.socket

    $ sudo systemctl enables gpsd.socket

  7. Start daemon using command:

    $ sudo gpsd /dev/ttyS0 –F /var/run/gpsd.sock

  8. 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)