Why I cannot get GPS data correctly from pins 16, 17 on ESP32?
Posted: Wed Jul 03, 2024 11:09 am
I'm trying to simply get the GPS data using ESP32-WROOM and Quectel L80 module. I want to send GPS data to my PC using Serial Monitor. So I have 2 UART configurations; one for GPS module and one for the debug message. Problem is when I connect GPS module to pins 16 and 17 I cannot get the GPS data correctly but I'm able to send debug messages to my PC. When I connect GPS module to pins 1 and 3 I'm able to get raw data correctly but this time not able to send debug messages to my PC.
According to my researchs they interact with each other even though I set the HardwareSerial to 2 for GPS communication. So I tried to close and open one another when using each of them but as long as I initialize UART for GPS module I'm not able to read any debug message (when module's pins are 16 and 17). I tried to use UART1 and if I didn't understand wrong I cannot use pins 9 and 10, because they're interconnected to something else. So I used pins 12 and 13 but still no difference. I also tried the same code in two different ESP32-WROOM and one ESP32-C3 Mini but results are still the same. If I connect GPS module directly to my PC I'm able to get raw data so I have no problem with the module. From the examples on the net I've seen that they're using SoftwareSerial for configuration but I think that library is not available for ESP32. There's another library called ESPSoftwareSerial but couldn't manage to make it work either.
Arduino IDE version: 2.3.2
I tried so many kinds of code but this is the simplest form:
According to my researchs they interact with each other even though I set the HardwareSerial to 2 for GPS communication. So I tried to close and open one another when using each of them but as long as I initialize UART for GPS module I'm not able to read any debug message (when module's pins are 16 and 17). I tried to use UART1 and if I didn't understand wrong I cannot use pins 9 and 10, because they're interconnected to something else. So I used pins 12 and 13 but still no difference. I also tried the same code in two different ESP32-WROOM and one ESP32-C3 Mini but results are still the same. If I connect GPS module directly to my PC I'm able to get raw data so I have no problem with the module. From the examples on the net I've seen that they're using SoftwareSerial for configuration but I think that library is not available for ESP32. There's another library called ESPSoftwareSerial but couldn't manage to make it work either.
Arduino IDE version: 2.3.2
I tried so many kinds of code but this is the simplest form:
Code: Select all
#include "HardwareSerial.h"
// Define the GPIO pins you want to use for UART
#define UART_TX_PIN 17
#define UART_RX_PIN 16
// Create an instance of HardwareSerial
HardwareSerial mySerial(2);
void setup() {
// Begin serial communication at 115200 baud
Serial.begin(115200);
// Initialize UART2 with custom TX and RX pins
mySerial.begin(9600, SERIAL_8N1, UART_RX_PIN, UART_TX_PIN);
// Print a message to the default Serial (USB) console
Serial.println("UART2 configured on custom pins!");
}
void loop() {
// Send data via UART2
mySerial.println("Hello from UART2!");
delay(1000);
// Check for incoming data on UART2
if (mySerial.available()) {
String received = mySerial.readString();
Serial.print("Received on UART2: ");
Serial.println(received);
}
// Wait for a second
delay(1000);
}