logic level converter/Using it/08. A 3.3 V board and a 5 V part
Using it · 08 of 9

A 3.3 V board and a 5 V part

An ESP32, an ESP32-S3 or a Pico goes on the socket's side: GND and its signals into the socket, its 5V pin (VBUS on a Pico) round to the header's 5V, and its 3V3 pin nowhere. A loopback with one jumper from H1 to H2 proves two channels both ways before a 5 V part goes on.

Four wires, a jumper, and one left off

A 3.3 V board and a 5 V part
Your board
On the 5 V side
Into the socket
GND, GPIO 4, GPIO 5
To the header
5V
Your 3V3
nothing
GPIO 4 goes out through channel 1, over the jumper from H1 to H2, and back through channel 2 to GPIO 5. Your 5V feeds the header's 5V, and the TK97 makes its own 3.3 V from it: your 3V3 pin is not wired to anything. If the sketch sees HIGH come back HIGH and LOW come back LOW, both channels work both ways.
  1. GND into the socket's GND.
  2. 5V (VBUS on a Pico) to the header's 5V, round the side of the board. This is the TK97's only supply.
  3. Your 3V3: nothing. The socket's 3V3 is the TK97's own regulator.
  4. OUT_PIN into L1: GPIO 4 on an ESP32-S3, GPIO 25 on an ESP32, GP14 on a Pico.
  5. BACK_PIN into L2: GPIO 5, GPIO 26 or GP15.
  6. One jumper from H1 to H2 on the header.

Jumper wires push straight into the socket. The header's pins take a female-to-female jumper for the loop.

What the loop proves

A HIGH goes out on L1, crosses to H1 at 5 V, runs over the jumper to H2, and crosses back to L2 at 3.3 V. A LOW does the same. So one run checks the 5V wire, GND, two channels and both directions, with no 5 V part on the bench yet.

At 115200 the serial monitor prints HIGH came back HIGH, LOW came back LOW: ok once a second. "always HIGH" means the jumper, "always LOW" means 5V or GND; the troubleshooting below has both.

None of the three boards' pins here is a strapping pin, a flash pin or a USB pin, so the loop cannot upset a boot.

Then the 5 V part

Take the jumper off and put the part on the header: its GND and VCC on the header's GND and 5V, its signals on H1 to H6. Your board's side does not change. For an I2C part, the scan from the previous page has a MicroPython version for exactly this wiring: SDA on L1, SCL on L2.

The code

No library. OUT_PIN goes out through channel 1, over the jumper and back through channel 2 to BACK_PIN; the sketch sends HIGH, reads, sends LOW, reads, and says what came back, once a second. Change the two pin numbers to the ones you wired.

llc_loopback.ino
/*
  Logic Level Converter - loopback check                TK97 / /p/tk97

  Two channels, both ways, with one jumper and no other part. Socket
  at the top, both rows start at GND at the left.

  A 3.3 V board (ESP32, ESP32-S3, Pico) goes on the OUT side:

    GND    -> GND
    5V     -> 5V (VBUS on a Pico). The TK97 makes its own 3.3 V.
    3V3    -> nothing. It is the TK97's output, never your 3V3.
    L1     -> OUT_PIN
    L2     -> BACK_PIN
    H1, H2    joined to each other with one jumper.

  An Uno goes on the IN side: GND and 5V the same, H1 -> OUT_PIN,
  H2 -> BACK_PIN, and one jumper from L1 to L2 in the socket.

  OUT_PIN goes out through channel 1, over the jumper and back
  through channel 2 to BACK_PIN.

  Arduino IDE
    Tools > Board                 your board, e.g. ESP32S3 Dev Module
    Tools > Port                  the one that appears when you plug in
    Tools > USB CDC On Boot       Enabled   (ESP32-S3 only)
    No library needed.
    Serial Monitor                115200
*/

// The pin wired to L1 (H1 on an Uno).
// Uno: 2. ESP32: 25. ESP32-S3: 4. Pico: 14.
const int OUT_PIN = 4;
// The pin wired to L2 (H2 on an Uno).
// Uno: 3. ESP32: 26. ESP32-S3: 5. Pico: 15.
const int BACK_PIN = 5;

// Time for a level to cross twice before it is read. Microseconds
// would do; a millisecond keeps it obvious.
const int SETTLE_MS = 1;

int sendAndRead(int level) {
  digitalWrite(OUT_PIN, level);
  delay(SETTLE_MS);
  return digitalRead(BACK_PIN);
}

void setup() {
  Serial.begin(115200);
  pinMode(OUT_PIN, OUTPUT);
  // No pull-up here: the TK97's own 10 kOhm holds the line.
  pinMode(BACK_PIN, INPUT);
}

void loop() {
  int high = sendAndRead(HIGH);
  int low = sendAndRead(LOW);

  if (high == HIGH && low == LOW) {
    Serial.println("HIGH came back HIGH, LOW came back LOW: ok");
  } else if (high == HIGH && low == HIGH) {
    Serial.println("always HIGH: check the jumper, and BACK_PIN");
  } else if (high == LOW && low == LOW) {
    Serial.println("always LOW: check 5V and GND, then OUT_PIN");
  } else {
    Serial.println("backwards: check every wire against the list");
  }
  delay(1000);
}

BACK_PIN is a plain input: the TK97's own 10 kΩ holds its line, so no pull-up is set in the sketch. The comment at the top also gives the Uno's wiring, which is the same loop from the header's side. The sketch compiles for an ESP32-S3, an ESP32 and an Uno.

View on GitHub · blocks/tk97-logic-level-converter/arduino/llc_loopback/llc_loopback.ino @ v1.11

When it does not work

The loopback prints always HIGH.

The level goes out and never comes back LOW. The jumper from H1 to H2 is missing or loose, or BACK_PIN is not the pin wired to L2. The sketch cannot tell those apart; check the jumper first.

The loopback prints always LOW.

Nothing is pulling up, which means no 3.3 V on the board: check that your 5V pin, or VBUS on a Pico, reaches the header's 5V, and that GND is wired. Then that OUT_PIN is the pin on L1.

The serial monitor stays empty on my ESP32-S3.

Set Tools > USB CDC On Boot to Enabled and upload again. Without it the S3's USB port brings up no serial port, so the sketch runs with nowhere to print.

Where is 5V on my board?

Most ESP32 and ESP32-S3 boards have a 5V or VIN pin that carries the USB's 5 V while the board is on USB. On a Pico it is VBUS. Check your board's pinout before you wire it.

Where this goes next

Four readings with a meter that tell the usual faults apart.

When nothing crosses →

Edit this page — content/books/logic-level-converter/a-3v3-board-and-a-5v-part.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Logic Level Converter

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum →