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

A 5 V board and a 3.3 V block

An Uno on the header and a 3.3 V block in the socket: 5V and GND from the Uno, its signals on H1 to H6, and the block powered by the TK97's own 3.3 V. With a TK42 in the first four places of the socket and A4 and A5 on H1 and H2, an I2C scan finds it at 0x48.

Four wires from the Uno

A 5 V board and a 3.3 V block
In the socket
Wires from the Uno
4
Channels used
2 of 6
Block's 3.3 V
from the TK97
The TK42 plugs into the socket's first four places, GND on GND, so its VCC meets the TK97's 3V3 and its SDA and SCL meet L1 and L2. The Uno sends 5V and GND, and its I2C pins, A4 and A5, to H1 and H2. The scan finds the TK42 at 0x48.
  1. GND to the header's GND.
  2. 5V to the header's 5V. That is the TK97's supply, and through its regulator the block's too.
  3. A4 (SDA) to H1.
  4. A5 (SCL) to H2.

Then the block. A TK42 temperature sensor's header reads GND, VCC, SDA, SCL, and it plugs straight into the socket's first four places: its GND on GND, VCC on 3V3, SDA on L1, SCL on L2. Check that GND meets GND before you power up; one place along puts VCC on GND.

The Uno's own 3.3V pin is not used. The block runs on the TK97's regulator, and the Uno only gives 5V.

The scan

The sketch asks every I2C address in turn and prints the ones that answer. It needs no library but Wire, so it works with any I2C block, and it is the quickest way to prove the wiring before a block's own library is involved.

At 115200 the serial monitor prints found 0x48 and 1 device(s). A TK42 answers at 0x48. every three seconds. A different block prints its own address.

Pull-ups

Nothing to add. Each of L1 and L2 has 10 kΩ up to 3.3 V on the TK97, and each of H1 and H2 has 10 kΩ up to 5 V: those are the bus's pull-ups on both sides. A block with its own pull-ups adds to them, which only makes the edges faster.

The TK89 display

Pick the TK89 in the figure. It takes all eight places in the socket and all six channels, and the Uno drives it from D10, D11, D13, D9, D8 and D7. The TK89 book has the wiring diagram and the sketch.

The code

No library beyond Wire. The sketch asks every address from 1 to 126 and prints the ones that answer, every three seconds. On an Uno Wire uses A4 and A5; on an ESP32, an ESP32-S3 or a Pico it uses that board's default SDA and SCL.

llc_i2c_scan.ino
/*
  Logic Level Converter - I2C scan                      TK97 / /p/tk97

  A 5 V Uno and a 3.3 V I2C block, such as the TK42, through the
  TK97. Socket at the top, both rows start at GND at the left.

    GND    -> GND
    5V     -> 5V. The TK97 makes the block's 3.3 V from it.
    H1     -> SDA: A4 on an Uno
    H2     -> SCL: A5 on an Uno
    3V3       nothing to wire: the block in the socket takes it.

  The block plugs into the socket's first four places, its GND on
  GND: GND, VCC, SDA, SCL meet GND, 3V3, L1, L2. The TK97's 10 kOhm
  pull-ups are the bus's pull-ups on both sides.

  A 3.3 V board (ESP32 GPIO 21/22, ESP32-S3 GPIO 8/9, Pico GP4/GP5)
  goes on the OUT side instead: SDA to L1, SCL to L2, GND to GND,
  its 5V (VBUS on a Pico) to 5V and its 3V3 to nothing, with a 5 V
  I2C part on H1 and H2.

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

#include <Wire.h>

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10);
  // Each board's default SDA and SCL, so nothing names them here.
  Wire.begin();
#if defined(ARDUINO_ARCH_AVR)
  // A bus held LOW (5V or GND missing) must not hang the Uno.
  Wire.setWireTimeout(25000, true);
#endif
}

void loop() {
  int found = 0;
  for (byte addr = 1; addr < 127; addr++) {
    Wire.beginTransmission(addr);
    if (Wire.endTransmission() == 0) {
      Serial.print("found 0x");
      if (addr < 16) Serial.print('0');
      Serial.println(addr, HEX);
      found++;
    }
  }
  if (found == 0) {
    Serial.println("nothing answered: 5V, GND, then SDA and SCL");
  } else {
    Serial.print(found);
    Serial.println(" device(s). A TK42 answers at 0x48.");
  }
  delay(3000);
}

On the Uno a 25 ms timeout keeps a bus held LOW from stalling the sketch. The comment at the top lists the wiring for a 3.3 V board on the socket's side as well. The sketch compiles for an Uno, an ESP32 and an ESP32-S3.

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

When it does not work

The scan says nothing answered.

Check the Uno's 5V and GND wires to the header first: without 5V the TK97 makes no 3.3 V and the block is off. Then that A4 is on H1 and A5 on H2, and that the block's GND is in the socket's GND place, not one along.

The scan finds the block, then stops finding it.

A loose socket contact or a wire that moved. The sketch scans every three seconds, so wiggle one wire at a time and watch which one makes it come and go.

The Uno hangs instead of printing.

An I2C bus held LOW can stall the Uno's Wire library. The sketch sets a 25 ms timeout for that; if yours does not, add Wire.setWireTimeout(25000, true) after Wire.begin(). A bus held LOW usually means 5V is missing.

My block is not a TK42. Will it plug in?

If its header reads GND, VCC, SDA, SCL like the TK42's, yes: it takes the socket's first four places and runs on 3V3. Another order needs jumper wires from its pins to the right socket holes.

Where this goes next

The other way round: an ESP32 or a Pico on the socket's side, and a loopback that checks two channels.

A 3.3 V board and a 5 V part →

Edit this page — content/books/logic-level-converter/a-5v-board-and-a-3v3-block.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 →