3.3 V vs 5 V Logic: When You Need a Voltage Divider
Updated
Why a 5 V sensor output can damage an ESP32 or Pico, and how to fix it with two resistors or a level shifter.
Two logic families
An Arduino Uno runs at 5 V: a HIGH output is about 5 V and its inputs accept up to 5 V. ESP32, ESP32-C3 and Raspberry Pi Pico boards run at 3.3 V and their GPIO pins are not 5 V tolerant.
Feeding 5 V into a 3.3 V pin may appear to work for a while, but it stresses the chip's protection diodes and can permanently damage the pin or the whole microcontroller.
Which direction is the problem?
- 3.3 V board → 5 V module input (e.g. HC-SR04 TRIG, relay IN): usually fine, because most 5 V inputs treat about 2–3 V as HIGH. Check the module.
- 5 V module output → 3.3 V board input (e.g. HC-SR04 ECHO, MQ-2 DO/AO): needs level shifting.
- I2C modules with pull-ups to 5 V (e.g. many 16×2 LCD backpacks): the bus idles at 5 V; use an I2C level shifter for 3.3 V boards.
The voltage divider fix
For a one-way signal, two resistors are enough. Vout = Vin × R2 / (R1 + R2). With R1 = 1 kΩ (from the 5 V output) and R2 = 2 kΩ (to ground), 5 V becomes about 3.33 V.
Dividers are fine for slow signals like ECHO or a digital sensor output. For fast or bidirectional lines (I2C, SPI at high speed), use a dedicated level shifter module.
How Circuits Playground checks this
The circuit builder knows each module's output voltage and each board's logic voltage. If a 5 V output is wired directly to a 3.3 V-only pin, the checker reports an error (E_LOGIC_LEVEL) next to the wire.