Help to connect Arduino Nano esp32 to a Arduino Mega

Hi,
Today I’m working on an IoT solution using Azure IoT, an Arduino Mega, and an Arduino Nano ESP32. The Arduino Mega has five sensors connected to it, which generate a JSON. I want to use serial communication to send the JSON from the Arduino Mega to the Arduino Nano ESP32, and then have the Nano send it to Azure.

However, I’m not sure how to properly connect and establish communication between the two Arduinos. I’ve tried using TX and RX (TX2 and RX2 from the Arduino Mega to RX0 and TX1 on the Arduino Nano), and also using I2C by connecting the SDA and SCL pins on each board, with a common ground.

I know the Arduino Nano ESP32 works at 3.3V logic levels, so I’m trying to use a TXS0108E level shifter to handle the logic level conversion.

My questions are:

  1. How should I correctly connect the two Arduinos?
  2. Is the level shifter really necessary?
  3. Is it better to use I2C or UART for communication between the two Arduinos?

Thanks in advance for your help!

Logic level shifters are required whenever connecting 5V outputs to 3.3V inputs. It is also a good idea to use shifters when connecting 3.3V outputs to 5V inputs.

UART serial communications work well over long distances. I2C does not. Use the alternative serial ports on both the Mega and the Nano ESP32 for the connection.

1 Like