Is my ESP32 code correct to establish UART communication between Arduino uno?

So I'm trying this simple project to have serial communication between Arduino Uno and ESP32. There are no errors when uploading the code but there is no output in the serial monitor of ESP32. For reference, I have attached the schematic diagram that I have used in connecting the Uno and ESP32, as well as the code for Uno and the code for ESP32.


Code for Uno:

void setup() 
{
  Serial.begin(9600);
}
void loop() 
{
  Serial.print("Hello");
  delay(1000);
}

Code for ESP32: olehana germany

#define RXD2 16
#define TXD2 17

void setup() 
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
}
void loop() 
{
  while(Serial2.available()) 
  {
    Serial.print(Serial2.read());
  }
  delay(1000);
}

Hi,
Can you please note on your circuit, the pin numbers/labels on each controller please?

What are tx2 and rx2 pin labels on the UNO?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

#include <HardwareSerial.h>

HardwareSerial SerialTFMini( 1 );
HardwareSerial SerialBrain( 2 );
////// serial(1) = pin27=RX green, pin26=TX white
////// serial(2) = pin16=RXgreen , pin17=TX white

void setup() 
{
Serial.begin( SerialDataBits );
  SerialBrain.begin( SerialDataBits );
  SerialTFMini.begin(  SerialDataBits, SERIAL_8N1, 27, 26 );
  // Initialize the TFMini LIDAR
  tfmini.begin(&SerialTFMini);
}

There you can see 3 serial ports being setup and initialized on an ESP32.


Level shifter

2 Likes

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.