Arduino Forum

Products => MKR Boards => MKRGSM1400 => Topic started by: alphacat92 on Mar 23, 2019, 01:20 pm

Title: TinyGPS++ library
Post by: alphacat92 on Mar 23, 2019, 01:20 pm
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);
      }
}
Title: Re: TinyGPS++ library
Post by: sandeepmistry on Mar 25, 2019, 01:07 pm
If you are using the TX/RX pins on the headers, you must use Serial1 instead of Serial. Serial is for the USB serial.