#include <TinyGPSPlus.h>
#include <SoftwareSerial.h>
/*
This sample sketch demonstrates the normal use of a TinyGPSPlus (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 = A3, TXPin = A2;
static const uint32_t GPSBaud = 9600;
// The TinyGPSPlus object
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
void setup()
{
Serial.begin(9600);
ss.begin(GPSBaud);
Serial.println(F("DeviceExample.ino"));
Serial.println(F("A simple demonstration of TinyGPSPlus with an attached GPS module"));
Serial.print(F("Testing TinyGPSPlus library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
Serial.println(F("by Mikal Hart"));
Serial.println();
}
void loop()
{
// This sketch displays information every time a new sentence is correctly encoded.
while (ss.available() > 0)
if (gps.encode(ss.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.print(F(" Date/Time: "));
if (gps.date.isValid())
{
Serial.print(gps.date.month());
Serial.print(F("/"));
Serial.print(gps.date.day());
Serial.print(F("/"));
Serial.print(gps.date.year());
}
else
{
Serial.print(F("INVALID"));
}
Serial.print(F(" "));
if (gps.time.isValid())
{
if (gps.time.hour() < 10) Serial.print(F("0"));
Serial.print(gps.time.hour());
Serial.print(F(":"));
if (gps.time.minute() < 10) Serial.print(F("0"));
Serial.print(gps.time.minute());
Serial.print(F(":"));
if (gps.time.second() < 10) Serial.print(F("0"));
Serial.print(gps.time.second());
Serial.print(F("."));
if (gps.time.centisecond() < 10) Serial.print(F("0"));
Serial.print(gps.time.centisecond());
}
else
{
Serial.print(F("INVALID"));
}
Serial.println();
}``
Are you trying this indoors ? If so then it is not unusual for satellite reception to be bad or non existent
What happens if you apply power to the GPS unit and no other connections and leave the powered unit with a clear view of the sky outdoors ? Does the GPS get a satellite lock and flash its LED ?
No LED flashes even if we connect it to a power supply, and it does not satellite lock even if we leave it outdoors with the clear view of sky. We have tried it for around 2-3 hours, and still nothing lights up.
The GPS unit should get a satellite lock, indicated by its LED flashing with a period of 1 second whether the comms are set up correctly to read the data or not
Try this simple program, it copies GPS output to the serial monitor. The GPS should send GPS sentences to the serial port regardless of whether it has a fix or not. If you see no ouput try and swap RX and TX.
#define RXpin A3 //this is the pin that the Arduino will use to receive data from the GPS
#define TXpin A2 //this is the pin that the Arduino can use to send data (commands) to the GPS - not used
#include <SoftwareSerial.h>
SoftwareSerial GPS(RXpin, TXpin);
void loop()
{
while (GPS.available())
{
Serial.write(GPS.read());
}
}
void setup()
{
GPS.begin(9600);
Serial.begin(115200);
Serial.println("GPS_Echo Starting");
}
BEWARE: bought AGAIN the same module (1pc only) from the same shop (November 2023). this shop does not test their products before sending to customers. probably FACTORY DEFECT since ONLY one (1) out of the three gps modules i bought from them back in 2019 WORKED.