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
- GND to the header's GND.
- 5V to the header's 5V. That is the TK97's supply, and through its regulator the block's too.
- A4 (SDA) to H1.
- 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.
/*
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.11The same scan in MicroPython, for a 3.3 V board on the socket's side and a 5 V I2C part on the header: SDA to L1, SCL to L2, the part on H1 and H2.
"""
Logic Level Converter - I2C scan, MicroPython TK97 / /p/tk97
A 3.3 V board and a 5 V I2C part through the TK97. Socket at the
top, both rows start at GND at the left. The board goes on the OUT
side, the part on the IN side:
GND -> GND
5V -> 5V (VBUS on a Pico), and the part's VCC to 5V too.
3V3 -> nothing. It is the TK97's output, never your 3V3.
L1 -> SDA: GPIO 21 on an ESP32, GPIO 8 on an S3, GP4
L2 -> SCL: GPIO 22 on an ESP32, GPIO 9 on an S3, GP5
H1, H2 -> the part's SDA and SCL.
The TK97's 10 kOhm pull-ups are the bus's pull-ups on both sides.
Thonny
Run > Configure interpreter MicroPython (ESP32) or
MicroPython (Raspberry Pi Pico)
"""
import time
from machine import I2C, Pin
# GPIO numbers. ESP32: 21 and 22. ESP32-S3: 8 and 9. Pico: 4 and 5.
SDA_PIN = 8
SCL_PIN = 9
i2c = I2C(0, sda=Pin(SDA_PIN), scl=Pin(SCL_PIN), freq=100000)
while True:
found = i2c.scan()
if not found:
print("nothing answered: 5V, GND, then SDA and SCL")
for addr in found:
print("found 0x%02X" % addr)
time.sleep(3)SDA_PIN and SCL_PIN are GPIO numbers: 21 and 22 on an ESP32, 8 and 9 on an ESP32-S3, 4 and 5 on a Pico. The bus runs at 100 kHz, well inside what the TK97 carries. Stop it with Ctrl-C.
View on GitHub · blocks/tk97-logic-level-converter/micropython/llc_i2c_scan.py @ v1.11When it does not work
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.
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.
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.
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.
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
Questions about this product
See what other owners have asked, and read their solutions.
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.