First: which direction is the problem?
This is the part that most explanations skip, and it decides everything.
A 5V signal going into a 3.3V input is the dangerous direction. The Raspberry Pi's GPIO pins are 3.3V and are not 5V tolerant. Feeding 5V in stresses the input every time the signal goes high, and will degrade or destroy the pin.
A 3.3V signal going into a 5V input is usually fine — but check. Many 5V parts treat anything above roughly 2V as a valid "high", so 3.3V is read correctly. Some don't, and the symptom is a device that never responds rather than a damaged one. The datasheet figure to look for is VIH (input high voltage): if it's below 3.3V, you're fine.
Option 1: A resistor voltage divider
Best for: a single, slow, one-directional signal — like that HC-SR04 Echo pin.
Two resistors in series between the 5V signal and ground, with your 3.3V board connected to the junction between them. A 1kΩ and 2kΩ pair gives you roughly 3.3V from a 5V input.
Cheap, uses parts you already own, and perfectly adequate for what it's designed for.
Option 2: A MOSFET bidirectional level shifter
Best for: I2C, and anything that needs to work in both directions.
These are the small four-channel boards built around BSS138 MOSFETs, sold everywhere for very little. Each channel handles traffic in either direction automatically, which is exactly what I2C needs.
This is the default answer for most hobby situations. If you're unsure which option to buy, buy a couple of these — they cost very little and solve the majority of cases.
Their limitation is speed: the MOSFET-plus-pull-up arrangement is fine for I2C and slower signals, but not for fast push-pull signals like SPI at high clock rates.
Option 3: A dedicated level-shifter IC
Best for: faster signals, or when you need several channels reliably.
Purpose-built translator chips (the TXB and TXS families are common on hobby breakouts) handle higher speeds than the simple MOSFET boards. Worth knowing that they aren't interchangeable: some variants are intended for push-pull signals like SPI, others for open-drain buses like I2C. Match the part to the bus rather than assuming any shifter does any job.
Option 4: Sidestep it entirely
Best for: almost everyone, most of the time.
The cheapest level shifter is the one you don't need. Before buying anything, check whether:
- A 3.3V version of the sensor exists. Many popular sensors come in both, and the 3.3V variant just works.
- Your breakout already has shifting built in. A lot of modern modules include a regulator and level shifting, and are marked as accepting 3–5V. If the board says that, you're done — wire it straight up.
- The module has a voltage select jumper. Some do. Check before you add hardware.
Reading the module's documentation for two minutes genuinely beats an evening of debugging.
Choosing quickly
| Situation | Use |
|---|---|
| One slow 5V output into a 3.3V input (e.g. HC-SR04 Echo) | Voltage divider |
| Any I2C device at a different voltage | MOSFET bidirectional shifter |
| Fast SPI, or several channels | Dedicated shifter IC matched to the bus type |
| 3.3V output into a 5V input | Usually nothing — check VIH in the datasheet |
| Module marked "3–5V" | Nothing. Wire it directly. |
The habit worth building
Before wiring any new module, find two numbers in its documentation: its supply voltage and its signal (logic) voltage. They are frequently different, and assuming they're the same is the root of most of these problems. Reading a datasheet covers where to find them.
If you're planning a multi-sensor build, run it through PinTinker first — it flags known voltage problems like the HC-SR04's Echo pin as you add each component.
Gear that helps
A 4-channel bidirectional logic level converter covers the majority of cases and costs very little — worth keeping a spare in the drawer. An assorted resistor kit covers the divider approach.