TXRXTXRXESP323.3 V logic1 kΩ2k10kUNO5 V · ATmega328PSDG10k3.3 V5 V5 V3.33 V2.64 V3.3 V0 V
Left: an ESP32 (3.3 V). Right: an Arduino Uno's ATmega328P (5 V)Back line: a divider steps 5 V down. Front line: a MOSFET with pull-ups steps 3.3 V upTokens: the voltage on a line, and how the circuit changes itA 5 V Arduino Uno (ATmega328P) and a 3.3 V ESP32 joined by two lines. Line 1 steps 5 V down with a 1 kΩ / 2 kΩ divider to 3.33 V, above the ESP32's 2.48 V HIGH threshold and below its 3.6 V limit. Line 2 steps 3.3 V up with a BSS138 MOSFET and two 10 kΩ pull-ups: off, the 5 V pull-up gives the Uno a full HIGH; on, both sides go LOW together, in either direction.

Two voltages

  1. An Arduino Uno runs on 5 volts, so its HIGH is about 5 V. An ESP32 runs on 3.3 volts, so its HIGH is about 3.3 V. We want to wire a pin of one to a pin of the other, both ways.

Stepping down

Stepping up

What happens

;; step 1/10 · two-voltages
Uno R3   ATmega328P, supply 5 V   HIGH ≈ 5 V
ESP32    supply 3.3 V              HIGH ≈ 3.3 V
LOW is about 0 V on both

line 1  Uno TX   -> ESP32 RX
line 2  ESP32 TX -> Uno RX

Thresholds are datasheet guarantees, not exact switch points. ATmega328P (Table 30-1): LOW up to 0.3 × VCC, HIGH from 0.6 × VCC, for VCC from 2.4 V to 5.5 V. ESP32 (Table 5-3, at 3.3 V and 25 °C): LOW up to 0.25 × VDD, HIGH from 0.75 × VDD, and at most VDD + 0.3 V. The datasheets give 2.48 V as 2.475 V and 0.82 V as 0.825 V; the figure rounds them to the safe side. The BSS138's gate threshold is 0.8 V to 1.5 V (typically 1.3 V), so with its gate on 3.3 V it is surely off at 0 V and surely on at 3.3 V. The three cases are NXP's application note AN10441 on I2C level shifting. Ready-made boards put four of these, each with two 10 kΩ pull-ups, on one breakout.