0

Lately I've been struggling with Serial communication between Uno and ESP32. I'm trying to send a simple string (In my case "100") from my Uno to my ESP32. I made a voltage divider and I'm using HardwareSerial Serial2(1) for the Serial reading on the ESP32's side. On my Uno's side, I use Pin 9 for sending data a.k.a Pin 9 goes to the voltage divider and links with RX2 (GPIO16) on my ESP32, like in the picture below. picture

My Uno code is:

void setup() {
Serial.begin(9600);
}

void loop() {
Serial.print("100");
delay(2000);
}

and on the other side, ESP32's code:

#define RXD2 16
#define TXD2 -1

HardwareSerial Serial2(1); // Use UART channel 1

void setup() {
Serial.begin(9600);
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
}

void loop() {
if(Serial2.available() >= 1){
Serial.print(Serial2.read());
}
else {
Serial.print("Not sending");
}
delay(2000);
}

I'm not receiving the data and I get "Not sending" all the time. My question is: Should I use TX pin from my Uno instead of pin 9? Or there's something wrong with my code?

Thank you in advance

  • 1
    Need to use serial pin TX 1 in Arduino – Avon97 Aug 13 at 13:59
  • As I suspected, this fixed the issue. Thank you so much :) – anthino12 Aug 13 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.