Extracting GPS and Print to Serial

Hello everyone,

Im trying to extract GPS data from a GPS unit and print it to serial but i cannot seem to get it to work as my GPS unit sends this data -

B$GNRMC,164901.000,A,2858.06521,N,10437.51943,W,0.00,101.13,2

So how to extract the LAT and LONG from this NMEA sentence using arduino?

The easy way would be to use a library

Slightly more difficult would be to build a character array as each character is received and when the line is complete parse the data out using the strtok() function

The GPS data are in NMEA format, the representation for latitude and longitude is described here:

There are several Arduino libraries that will read an NMEA sentence and decode the data (e,g, TinyGPS++, NeoGPS, Adafruit GPS library) but they probably won't recognize the B$GNRMC sentence type.

Are you sure about the "B"? What device produced that sentence?

The prefix "B" signifies that the data is coming from the BeiDou Navigation Satellite System.

Are you sure about that? According to this page

$BD = BeiDou (China)

$GN = Combination of multiple satellite systems (NMEA 1083)

My bad - you are right…

Agreed that the initial "B" should be ignored by libraries like TinyGPS++, and it should then recognize $GN as the start of the sentence.

However, the sentence as posted is also not complete. There is more at the end, such as the required checksum.

It is a -

https://www.aliexpress.us/item/3256805853905656.html?spm=a2g0o.order_list.order_list_main.5.34851802LGLLVk&gatewayAdapt=glo2usa

And thats the reason im looking for help as Arduino doesn't seem to be able to recognize this sentence due to what i thought was the B in front, no idea why this device puts the B there

This is the manual for the device -

Free Protocol.
(1) Send $001,RGPS01# to get the RMC information of the device GPS with address 001.
Hex: 2430 30 31 2C 52 47 50 53 30 31 23
The return content is as follows: $SGNRMC,105356.00,A,3637.25480,N,11700.53908,E,0.050,,200717,,,D7D
RMC Resolution: $GNRMC,105356.00,A,3637.25480,N,11700.53908,E,0.050,,200717,,,D
7D

This shows the CRC but sending that command does not work so they sent me this instead -
For example, a device with address 1 needs to send the instruction: 01 03 00 01 00 21 D4 12
01 is the address
03 Function code
00 01 Register address
00 21 21 (decimal 33) read 66 data
D4 12-bit RCR checksum
Returns
01 03 42 24 47 4E 52 4D 43 2C 30 37 30 35 34 36 2E 30 30 30 30 2C 41 2C 33 36 33 37 2E 32 36 38 36 34 2C 4E 2C 31 31 37 30 30 2E 35 35 38 30 33 2C 45 2C 30 2E 32 37 37 37 2C 32 30 38 2E 32 37 2C 30 33 31 31 31 37 AA 6F
ASC1 shows: where $GNRMC, 070546.000, A, 3637. 26864, N, 11700. 55803, E, 0. 277, 208. 27, 031117 was used for data analysis.

And here I can see the CRC isnt there.

So am I wrong by sending this command 01 03 00 01 00 21 D4 12 to get the GPS data via RS485?

The $S won't be recognized by TinyGPS++. Did you copy it correctly?

$GNRMC should be recognized and properly interpreted by TinyGPS++, unless the checksum is wrong, in which case you will have to write your own code. Or buy a more conventional GPS module.

Read this page:

http://arduiniana.org/libraries/tinygpsplus/

and try the TinyGPS++ example code.

Edit: I just checked the Aliexpress product page for that GPS module, and found this, which should be compatible with TinyGPS++:

 For example, send $RGPS01#.
Return information:
$GNRMC, 35407, A, 2230.71149, N, 11355.11382, E, 0.000,2.60010613, A*77 

Thats what i found as well but sending $RGPS01# via Serial Rs485 to GPS module does nothing, no response or anything.

Could be a hardware or code problem.

For better informed help, please post a wiring diagram (hand drawn is preferred, with all pins, parts and connections clearly labeled, the Arduino code, using code tags, and a link to the RS485 adapter.

Posting hints can be found in the "How to get the best out of this forum" post.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.