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);
}