Connecting Arduino Uno to Esp32 for serial communication using a logic level shifter

Hi everyone, I'm very new to using arduino so I got this logic level shifter:


so that i can safely connect my arduino and esp32 for serial communication. It was working fine just connecting the wires together but I was told that it has potential to short circuit :frowning:

this is how I have connected it so far:

Arduino Uno:

  • 5V pin -> HV (VCC)
  • GND pin -> HV (GND)
  • TX pin -> LV (TXI)
  • RX pin -> HV (RXI)

ESP32:

  • 3.3V pin -> LV (VCC)
  • GND pin -> LV (GND)
  • TX pin -> LV (RXI)
  • RX pin -> HV (TXI)

not sure what im doing wrong :frowning: need helppp

Might help if you told us if the device works or not! Does the documentation show any inversion of signal. + on input becomes 0 on output, or something like that.

the logic level shifter looks like this https://www.jaycar.com.au/arduino-compatible-logic-level-converter-module/p/XC4486?gclid=CjwKCAjw04yjBhApEiwAJcvNoUnKydsR3x6WFkoETZ6HGZo98ZLt01u442Al9J8JcKuzH3z0324v3BoCF-oQAvD_Bw

doesnt really have a light to signal if it is working or not.

my arduino uno and esp32 lights do come on though

It looks like you've got them reversed (or maybe I'm looking at it wrong). HV side connects to the arduino and LV side connects to the ESP. So on the LV side TXI is received from the ESP and snd sent to the arduino at 5v through TXO, and RXO on the LV side is 3v received from the RXI from the arduinos 5v output. TXO is OUTPUT / TXI is INPUT

just tried reversing it but it doesnt seem to work either. :frowning:

Hmmmm. I hope you haven't killed the esp with 5v in. Do you have a multimeter to test the system?

Yes I do! Just checked and it is showing up correctly

can you do a simple Serial.println ("Hello"); on the esp to show its receiving the signal from the arduino

it is not receiving signal at all :frowning:

it is showing up the gibberish though

Sorry for the delay. Supper and an hour long ham radio emergency net.
Did you download the data sheet for the device you linked to? It shows exactly what to connect to on the 5 volt, Arduino side of the board and what to connect to on the ESP32 side.

5 volt side 3.3 volt side
RX1 TX1
TX0 RX0

Thats okay hahaha! Yes I did but I'm honestly not too sure what the connections are still. This is what I've been trialling:

uno 5v —> LLS (logic level shifter) HV
Uno GND —> LLS HV GND
Uno TX —> LV RXO
Uno RX —> HV TXO

ESP 3.3v —> LLS LV
ESP GND —> LLS LV GND
ESP TX —> HV RX1
ESP RX —> LV TX1

& the uno is communicating but the esp is giving out gibberish but not saying it received anything

Look at from the boards point of view. I mean in and O means out. Arduino's tx goes to the board's RXI. Arduino RX goes to boards TXO. Same for the 3.3 volt side. ESP TX goes to boards TXI and ESP RX goes to board's RXO.

My take, anyway. Need a schematic!

https://learn.sparkfun.com/tutorials/retired---using-the-logic-level-converter

Just had another going doing this connection and still didnt have any luck :frowning:

for reference here is my code for my arduino uno:

#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#include <RTClib.h>

RTC_DS1307 rtc;
int SensorPin = 3;

#define PIXEL_PIN 6
#define PIXEL_COUNT 24
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

char auth[] = "--";  // Replace with your Blynk auth token

unsigned long startTime = 0;
unsigned long endTime = 0;

void setup() {
  pinMode(SensorPin, INPUT);
  pixels.begin();
  Serial.begin(9600);
  Wire.begin();
  rtc.begin();
  if (!rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
}

void loop() {

  DateTime now = rtc.now();
  int SensorValue = digitalRead(SensorPin);

  if (SensorValue == LOW && startTime == 0) { // Object Detected and timer not started
    startTime = millis(); // Start the timer
    for(int i = 0; i < pixels.numPixels(); i++){
      pixels.setPixelColor(i, pixels.Color(255, 200, 100));
      pixels.show();
      delay(166.67);
    }
    delay(7000);
    for(int i = pixels.numPixels()-1; i >= 0; i--){
      pixels.setPixelColor(i, 0, 0, 0, 0);
      pixels.show();
      delay(80);
    }
  }
  else if (SensorValue == LOW && startTime != 0) { // Object Detected and timer started
    endTime = millis(); // Update the end time
    for(int i = 0; i < pixels.numPixels(); i++){
      pixels.setPixelColor(i, pixels.Color(255, 200, 100));
      pixels.show();
      delay(166.67);
    }
    delay(7000);
    for(int i = pixels.numPixels()-1; i >= 0; i--){
      pixels.setPixelColor(i, 0, 0, 0, 0);
      pixels.show();
      delay(80);
    }
  }
  else if (SensorValue == HIGH && startTime != 0) { // Object not detected and timer started
    endTime = millis(); // Update the end time
    unsigned long duration = endTime - startTime; // Calculate the duration
    startTime = 0; // Reset the timer
    Serial.print("object used for: ");
    Serial.print(duration/1000);
    Serial.println(" seconds.");

  }
  else { // Object not detected and timer not started
    for(int i = 0; i < pixels.numPixels(); i++) {
      pixels.setPixelColor(i, pixels.Color(0, 0, 0));
    }
    pixels.show();
  }
}

and here is my code for my esp32:

#include <BlynkSimpleEsp32.h>  // Blynk library
// #include <WiFi.h>
// #include <WiFiClient.h>
#define RXpO 34
#define TXpO 35
#define BLYNK_TEMPLATE_ID           "--"
#define BLYNK_TEMPLATE_NAME         "--"
#define BLYNK_AUTH_TOKEN            "--"

char auth[] = "--";  // Blynk auth token
//char ssid[] = "--";
//char pass[] = "--";

void setup() {
  Serial.begin(9600);
  Blynk.begin//(auth, "--", "--");

void loop() {
  Blynk.run();  // Run the Blynk background tasks

  if (Serial.available()) {
    String message = Serial.readString();
    Serial.print("Received: ");
    Serial.println(message);

    // Send the message to Blynk for display
    Blynk.virtualWrite(V1, message);  // Use Virtual Pin V1
   
    int lastMessageSpace = message.lastIndexOf(" ");
    int value = message.substring(21,lastMessageSpace).toInt(); // take numerical data
    Blynk.virtualWrite (V2, value); // V2 pin for superchart
  }
}

I also don't think my code is the issue since it works if i connect tx and rx directly from the boards, but I don't really want to continue doing that since esp32 works on 3.3v logic

tried doing it this way, no luck :frowning:

When you say gibberish what do you mean? like jumbled characters or a bunch of numbers?

Do some static signal testing.

Make UNO TX, HIGH then LOW; does the RX on the ESP32 go 3v3 then 0v ?

Make ESP32 TX, HIGH then LOW; does the RX on the UNO go 5v then 0v ?

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