Go Down

Topic: Reading GPS (NMEA) data to serial monitor (Read 334 times) previous topic - next topic

HPB

Hi there, I am looking for some suggestions of where I may be going wrong with my arduino communications with a GPS unit through RS232.

I have a GPS unit which uses a trimble module, this then goes through a max 232 and outputs data to the RS232. The output of the RS232 is NMEA data in ascii format proven by being displayed on the computer via an RS232 cable on tera term.

(NMEA data, eg: $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47)

If I connect the output of the RS232 to a digital pin of the arduino and connect the ground cable to the arduino's ground, then use the code attached to serially print the data that is received to the serial monitor via usb from the arduino, the output to the serial computer monitor is jumbled characters.

         (GPS Unit ---------RS232 cable--------Arduino Digital pin-------USB cable------Computer)

I have tried adjusting baud rates as I thought this would solve the problem, this will change the output but this output is still just a jumble of characters. The baud rate that is used in tera term where it displays accurately is 9600.

I have tried altering the pins to (0,1) of the arduino as well. I have tried a few different GPS codes that people have posted and shown to be working, however as I have said I think the problem is in how the data is being received/processed by the arduino.

Please let me know if I am unclear or if there is anything I have missed, thank you so much in advance for your time.

pylon

You may damage your Arduino if you connect an RS232 line directly to one of it's pins. RS232 is in the range 2 - 15V and -2 - -15V. Most setups with a MAX 232 will use voltages in the 5V range for the positive signal but any negative signal is very dangerous for the Arduino pin. If you want to do that use a MAX232 on the Arduino side too.

Larry_2

Hi,
what GPS unit do you have?
If you have a Neo-6M try this:
NeoGPS library (you can find it in your library manager) and wiring as follows:



-dev

Quote
You may damage your Arduino...
+1

Also, don't use SoftwareSerial.  More info here about choosing a serial port for your GPS device.

If you get the GPS connected safely (through the MAX232), NeoGPS also has a diagnostic program.

On an UNO or Mini, NeoGPS will expect the GPS to be on pins 8 (to GPS TX) and 9 (to GPS RX).  On Arduinos that have an extra hardware serial port (e.g., Mega, Leo, Due or Teensy), it will use Serial1.

HPB

Thank you very much for the replies. I have not been connecting the arduino directly and this has been through a max232 to convert to TTL. The module that I am using is a trimble GPS module.

The NeoGPS software has been very helpful, thank you very much for pointing me to this. I am able to get GPS data out of one of the outputs of the GPS module and read this through the arduino, however I have some further questions:


- Only seem to be able to use pin 8 as a receive pin not pin 0 even after changing the GPSport to contain only the information that is advised as follows:

#ifndef GPSport_h
#define GPSport_h

#define gpsPort Serial
#define GPS_PORT_NAME "Serial"
#define DEBUG_PORT Serial

#endif

(Please let me know if I have completely misuderstood this instruction)

- Using pin 8 I have started trouble shooting using the NMEA order code as the diagnostic advised that the sentences are not correctly ordered. This displays:

ERROR: LAST_SENTENCE_IN_INTERVAL is incorrectly set to NMEAGPS::NMEA_RMC!
  You must change this line in NMEAGPS_cfg.h:
     #define LAST_SENTENCE_IN_INTERVAL NMEAGPS::NMEA_ZDA

There seems to be a number of NMEAGPS_cfg.h files. I have tried at one stage altering them all from having RMC to ZDA as the defined last sentence, however this did not have any effect and the error message is still the same.

Do you have any ideas why this may be?

freaklabs

Hi. I recommend first testing out the GPS data is coming in properly by echoing the direct output from the GPS module to the terminal. If you see the NMEA sentences properly, then you have the connections okay and then its an issue of dealing with the software libraries you're using.
FreakLabs
Open Source Wireless Sensor Networks
https://freaklabs.org
Twitter: @freaklabs

-dev

Quote from: HPB
- Only seem to be able to use pin 8 as a receive pin not pin 0 even after changing the GPSport to contain only the information that is advised as follows:

Code: [Select]
#ifndef GPSport_h
#define GPSport_h

#define gpsPort Serial
#define GPS_PORT_NAME "Serial"
#define DEBUG_PORT Serial

#endif

Please let me know if I have completely misuderstood this instruction.
That's exactly correct if you connect the GPS TX to Arduino pin 0 and GPS RX to Arduino pin 1.  This should make all examples read Serial for GPS characters.  But...

Which Arduino are you using?

Which sketch are you using?  One that comes with NeoGPS, or one you modified?

Quote
- Using pin 8 I have started trouble shooting using the NMEA order code as the diagnostic advised that the sentences are not correctly ordered. This displays:

ERROR: LAST_SENTENCE_IN_INTERVAL is incorrectly set to NMEAGPS::NMEA_RMC!
  You must change this line in NMEAGPS_cfg.h:
     #define LAST_SENTENCE_IN_INTERVAL NMEAGPS::NMEA_ZDA

There seems to be a number of NMEAGPS_cfg.h files. I have tried at one stage altering them all from having RMC to ZDA as the defined last sentence, however this did not have any effect and the error message is still the same.
[Emphasis mine.]  This tells me that you are not modifying the one true NMEAGPS_cfg.h in your Arduino/Libaries/NeoGPS/src directory.  You cannot have local copies of those config files in your sketch directory.  And the files in the src/config directories have no effect on the build.  They're a little out-of-date, so I wouldn't bother with them for now.

HPB

Thank you all very much, I have had a fresh look today and cleared it up.

The NEO GPS code helped a lot to find the baud rate needed and the pin of the module that I needed to connect the arduino to. From there I have been able to get the NMEA data and now just a case of organising my code.

Again thank you all so much for the comments and assistance.

Go Up