I am new in GPS modules and I need to get the NMEA data from my GPS module but when I execute my code all the NMEA sentences are Invalid.

I am using the same example from instructables Tiny GPS Tracker https://www.instructables.com/Tiny-GPS-Tracker/ and it does not work. So I found other code examples and changed them a little bit.

My code is below. I have the GPS_RX wired with Arduino TX and the same logic for GPS_TX-Arduino RX and Baud is 9600, all these details are inside GPS.h.

If I change the wiring between TX and RX or gps baud the system does not work at all, so I strongly believe that these values are correct.

#include "GPS.h"
#include <SD.h>

#if defined (ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#include <SoftwareSerial.h>
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB
#include "SoftwareSerialZero.h"

const int chipSelect = 10;
int cardPresent;

// The GPS connection is attached with a software serial port
SoftwareSerial softSerial(GPS_RXPin, GPS_TXPin);

#define Gps_serial softSerial

void setup()
  while (!SerialMonitorInterface && millis() < 5000); //On TinyScreen+, this will wait until the Serial Monitor is opened or until 5 seconds has passed

  SerialMonitorInterface.print("Attempting to wake GPS module.. ");

  //Enable and set interval or disable, per NMEA sentence type
  Gps_serial.print(gpsConfig(NMEA_GGA_SENTENCE, 0));
  Gps_serial.print(gpsConfig(NMEA_GLL_SENTENCE, 0));
  Gps_serial.print(gpsConfig(NMEA_GSA_SENTENCE, 0));
  Gps_serial.print(gpsConfig(NMEA_GSV_SENTENCE, 0));
  Gps_serial.print(gpsConfig(NMEA_RMC_SENTENCE, 1));
  Gps_serial.print(gpsConfig(NMEA_VTG_SENTENCE, 0));
  Gps_serial.print(gpsConfig(NMEA_GNS_SENTENCE, 0));

  SerialMonitorInterface.print("Initializing SD card...");

  // see if the card is present and can be initialized:
  if (SD.begin(chipSelect)) {
    SerialMonitorInterface.println("card initialized.");
    cardPresent = true;
  } else {
    SerialMonitorInterface.println("Card failed, or not present- continuing with serial output");
    cardPresent = false;

void loop() {

char waitForCharacter() {
  while (!Gps_serial.available());
  return Gps_serial.read();

void handleGPS() {
  while (Gps_serial.read() != '$') {
  int counter = 1;
  char c = 0;
  char buffer[100];
  buffer[0] = '$';
  c = waitForCharacter();
  while (c != '*') {
    buffer[counter++] = c;
    if(c=='$'){//new start
    c = waitForCharacter();
  buffer[counter++] = c;
  buffer[counter++] = waitForCharacter();
  buffer[counter++] = waitForCharacter();
  buffer[counter++] = '\r';
  buffer[counter++] = '\n';
  buffer[counter] = '\0';

  buffer[1] = 'G';
  buffer[2] = 'P';


  if (cardPresent) {
    File dataFile = SD.open("gps.txt", FILE_WRITE);
    // if the file is available, write to it:
    if (dataFile) {
      dataFile.write(buffer, counter);
    } else {
      SerialMonitorInterface.println("error opening gps.txt");
      cardPresent = false;
  } else {
    SerialMonitorInterface.print((char *)buffer);

After I wait aprox. 30 seconds which is the cold start of the gps I still receive invalid NMEA sentences. (I tested it outdoors and indoors)

$GPRMC,181341.901,V,,,,,,,211020,,,N4B $GPRMC,181342.901,V,,,,,,,211020,,,N48 $GPRMC,181343.901,V,,,,,,,211020,,,N49 $GPRMC,181344.901,V,,,,,,,211020,,,N4E $GPRMC,181345.901,V,,,,,,,211020,,,N*4F

Can someone explain to me what is going on?

  • V stands for invalid sentence, I can't find a way to generate valid sentences Oct 21 '20 at 18:52
  • looks like the module is not able to determine location .... maybe not enough satellites are being received .... perhaps the GPS module has a setting for sensitivity level ... maybe the antenna is bad, or badly connected ... this does not appear to be an Arduino problem .... just a note: your code is overly complicated for debugging ... all that is required, is to copy the received characters to SerialMonitor .... see the SoftwareSerial example in the Arduino IDE
    – jsotola
    Oct 21 '20 at 19:13
  • 1
    Do you know if there is a way to print the number of satellites connected to the GPS module? Oct 21 '20 at 19:32
  • 1
    Using example sketches give invalid results also haha Oct 21 '20 at 19:44
  • 1
    So you say that i need to check those sentences in order to understand if the gps is fixed or not.. Oct 21 '20 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.