Go Down

Topic: TinyGPS++ library (Read 447 times) previous topic - next topic

alphacat92

Hello, I'm having a lot of trouble using the TinyGPS++ library with the MKR GSM 1400. I understand that the MKR does not have software serial capabilities so I've been trying to get the library to work using hardware serial. Here is my code, but when I connect it properly I don't get output. I tested it with a Nano and it worked:
Code: [Select]

#include <TinyGPS++.h>

//Initialize TinyGPS++ object
TinyGPSPlus gps;

void setup() {
  //while (!Serial);
  Serial.begin(115200);
}

void loop() {
  while (Serial.available() > 0)
    if (gps.encode(Serial.read()))
      if (gps.location.isValid())
      {
        Serial.print(gps.location.lat(), 6);
        Serial.print(", ");
        Serial.print(gps.location.lng(), 6);
        Serial.println("");
        delay (1000);
      }
}

sandeepmistry

If you are using the TX/RX pins on the headers, you must use Serial1 instead of Serial. Serial is for the USB serial.

Go Up