TinyGPS++ MKR 1010 and MKR GPS shield?

I would like to use TinyGPS++ with my MKR1010 and MKR GPS shield. However, SoftwareSerial is disabled for MKR 1010, so I am in over my head on how to tell TinyGPS++ to find the GPS unit. RX on the MKR1010/GPS is pin 13, TX is 14 as a default, and I think it is Serial1. Running the code below compiles but I do not connect to the GPS unit (triggers the “No GPS detected: check wiring”). I assume this is because of the serial communications, since the HW setup works with the MKR GPS example.

#include <TinyGPS++.h>
#include "wiring_private.h"
#include <Arduino.h>
// #include <SoftwareSeria.h>
 
/*
   This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
// static const int RXPin = 13, TXPin = 14;
static const uint32_t GPSBaud = 4800;
 
// The TinyGPS++ object
TinyGPSPlus gps;
 
void setup()
{
  Serial.begin(115200);
  Serial1.begin(GPSBaud);
}
 
void loop()
{
  // This sketch displays information every time a new sentence is correctly encoded.
  while (Serial1.available() > 0)
    if (gps.encode(Serial1.read()))
      displayInfo();
 
  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }
}
 
void displayInfo()
{
  Serial.print(F("Location: ")); 
  if (gps.location.isValid())
  {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  }
  else
  {
    Serial.print(F("INVALID"));
  }
  Serial.println();
}

Solved! It turns out the MKR GPS Shield is a 9600 baud device, not a 4800 baud device. Just needed to change GPSBaud value.

I'm glad to hear it's working now. Thank you for taking the time to post an update. I was interested in the subject but the GPS is one of the few MKR shields I don't own so I was not equiped to properly investigate.

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