Hi there,
Try this and I will post what I see…
#include <TinyGPSPlus.h>
#include <HardwareSerial.h>
// Create a TinyGPSPlus instance to parse the GPS data.
TinyGPSPlus gps;
// Use HardwareSerial for the GPS. On the ESP32-C3, UART0 is usually used for USB serial,
// so we can use UART1 for the GPS.
HardwareSerial SerialGPS(1);
// Define the pins for the GPS.
const int gpsRXPin = 9; // GPS TX goes to ESP32 RX (pin 9)
const int gpsTXPin = 10; // GPS RX goes to ESP32 TX (pin 10)
const uint32_t gpsBaud = 9600;
void setup() {
// Start the primary hardware Serial (for USB debugging) at 115200 baud.
Serial.begin(115200);
while (!Serial) {
; // Wait for Serial connection.
}
Serial.println("Starting GPS example using HardwareSerial on ESP32-C3");
// Begin HardwareSerial on UART1 for GPS.
// The constructor for begin() is: begin(baud, config, rxPin, txPin)
SerialGPS.begin(gpsBaud, SERIAL_8N1, gpsRXPin, gpsTXPin);
Serial.println("GPS HardwareSerial initialized.");
}
void loop() {
// Feed any available GPS data from SerialGPS to TinyGPSPlus.
while (SerialGPS.available() > 0) {
char c = SerialGPS.read();
gps.encode(c);
}
// Print some parsed GPS data every second.
static unsigned long lastPrint = 0;
if (millis() - lastPrint > 1000) {
lastPrint = millis();
Serial.print("Satellites: ");
Serial.print(gps.satellites.value());
Serial.print(" Latitude: ");
Serial.print(gps.location.lat(), 6);
Serial.print(" Longitude: ");
Serial.println(gps.location.lng(), 6);
}
}
HTH
GL PJ
example that uses HardwareSerial instead of SoftwareSerial for the GPS on pins 9 (RX) and 10 (TX):
- HardwareSerial Instance:
We create a HardwareSerial instance namedSerialGPS
on UART1. On the ESP32-C3, you generally have at least two UARTs available (UART0 is used for USB serial, so UART1 is free for your peripheral). - Pin Assignment:
We assigngpsRXPin
(9) andgpsTXPin
(10) for the GPS. Make sure your wiring matches this (i.e., the GPS module’s TX should connect to ESP32’s RX and vice versa). - Reading and Parsing Data:
The loop reads available data fromSerialGPS
and feeds it into TinyGPSPlus for parsing.
Check the serial monitor for startup and data , LMK
Starting GPS example using HardwareSerial on ESP32-C3
GPS HardwareSerial initialized.
Satellites: 0 Latitude: 0.000000 Longitude: 0.000000
Satellites: 0 Latitude: 0.000000 Longitude: 0.000000
Satellites: 0 Latitude: 0.000000 Longitude: 0.000000
Satellites: 0 Latitude: 0.000000 Longitude: 0.000000