GPS NMEA sentence reader for Nucleo boards.

Dependencies:   mbed MODSERIAL

I had a lot of trouble getting other GPS examples to work. So I took Edoardo De Marchi's code from 2014 and hacked it until it was working on newer hardware.

Advice:

  • Start with confirming the module works in U-Center, and know the baud rate. Many older libraries assume 9600. Newer modules run at higher baud rates
  • Use a good terminal program and confirm you have human readable messages starting with "$GNGGA" or "$GPGSV" or similar.

Comments in code include links to NMEA sentence guides:

Most libraries do not include sentence filters for the types of sentences output by my M8N (and perhaps other modules as well)

Most older versions of the MODSERIAL library do not update properly to support STM32. I have found and included a version of the lib which will compile without errors. However, when using it in my code, the NMEA sentence gets corrupted somehow (for example showing some HUGE [6 digit] Satellite count, etc.

Files at this revision

API Documentation at this revision

Comitter:
edodm85
Date:
Fri Aug 22 12:43:55 2014 +0000
Parent:
0:ea14ad6794af
Child:
2:c16325a7d225
Commit message:
Added support for LPC4330

Changed in this revision

MODSERIAL.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
main.h Show annotated file Show diff for this revision Revisions of this file
mbed-src.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
--- a/MODSERIAL.lib	Sat Apr 12 11:53:35 2014 +0000
+++ b/MODSERIAL.lib	Fri Aug 22 12:43:55 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/AjK/code/MODSERIAL/#ae0408ebdd68
+http://mbed.org/users/edodm85/code/MODSERIAL/#4213f9a7c3ad
--- a/main.cpp	Sat Apr 12 11:53:35 2014 +0000
+++ b/main.cpp	Fri Aug 22 12:43:55 2014 +0000
@@ -1,6 +1,6 @@
 /*
  * Author: Edoardo De Marchi
- * Date: 12-04-14
+ * Date: 22-08-14
  * Notes: Firmware for GPS U-Blox NEO-6M
 */
 
@@ -61,7 +61,6 @@
     {
         sscanf(cmd, "$GPGGA,%f,%f,%c,%f,%c,%d,%d,%*f,%f", &timefix, &latitude, &ns, &longitude, &ew, &fq, &nst, &altitude);
         pc.printf("GPGGA Fix taken at: %f, Latitude: %f %c, Longitude: %f %c, Fix quality: %d, Number of sat: %d, Altitude: %f M\n", timefix, latitude, ns, longitude, ew, fq, nst, altitude);
-        pc.printf("\n");
     }
     
     // Satellite status
@@ -69,7 +68,6 @@
     {
         sscanf(cmd, "$GPGSA,%c,%d,%d", &tf, &fix, &nst);
         pc.printf("GPGSA Type fix: %c, 3D fix: %d, number of sat: %d\r\n", tf, fix, nst);
-        pc.printf("\n");
     }
     
     // Geographic position, Latitude and Longitude
@@ -77,7 +75,6 @@
     {
         sscanf(cmd, "$GPGLL,%f,%c,%f,%c,%f", &latitude, &ns, &longitude, &ew, &timefix);
         pc.printf("GPGLL Latitude: %f %c, Longitude: %f %c, Fix taken at: %f\n", latitude, ns, longitude, ew, timefix);
-        pc.printf("\n");
     }
     
     // Geographic position, Latitude and Longitude
@@ -85,7 +82,6 @@
     {
         sscanf(cmd, "$GPRMC,%f,%c,%f,%c,%f,%c,%f,,%d", &timefix, &status, &latitude, &ns, &longitude, &ew, &speed, &date);
         pc.printf("GPRMC Fix taken at: %f, Status: %c, Latitude: %f %c, Longitude: %f %c, Speed: %f, Date: %d\n", timefix, status, latitude, ns, longitude, ew, speed, date);
-        pc.printf("\n");
     }
 }
 
--- a/main.h	Sat Apr 12 11:53:35 2014 +0000
+++ b/main.h	Fri Aug 22 12:43:55 2014 +0000
@@ -3,13 +3,12 @@
 #include "MODSERIAL.h"
 
 MODSERIAL pc(USBTX,USBRX);
-MODSERIAL gps(p13,p14);
 
-DigitalOut led1(LED1);
-DigitalOut led2(LED2);
-DigitalOut led3(LED3);
-DigitalOut led4(LED4);
-
+#if   defined(TARGET_LPC1768)
+MODSERIAL gps(p13, p14);
+#elif defined(TARGET_LPC4330_M4)
+MODSERIAL gps(UART0_TX, UART0_RX);
+#endif
 
 
 char cDataBuffer[500];
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-src.lib	Fri Aug 22 12:43:55 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-src/#ec1b66a3d094
--- a/mbed.bld	Sat Apr 12 11:53:35 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/6473597d706e
\ No newline at end of file