A logic level adapter is a circuit that translates signals between different voltage domains without exceeding the input limits or losing logic margin.
Boards operating at 5 V coexist with microcontrollers and sensors running at 3.3 V. Before connecting them, we need to check both the maximum allowable voltage and the input thresholds.
What happens if you connect the TX pin of an Arduino (5V) to the RX pin of a Raspberry Pi (3.3V)? You can damage the Raspberry Pi because its GPIOs do not directly accept 5 V.
To avoid this, we need to adapt the logic level with a topology suitable for the signal’s direction and speed.
The problem: “1” is not always equal to “1”
In the digital world, a logic “1” is a high voltage. But how high exactly?
- 5 V logic: a high level falls within a range defined by the receiver; it doesn’t have to measure exactly 5 V.
- 3.3 V logic: the same applies; we must compare the transmitter’s
and with the receiver’s and .
The problem is unidirectional but serious:
- 3.3 V
5 V: it might work if the minimum high output exceeds the maximum high threshold required by the input. You must check both datasheets. - 5 V
3.3 V: this can only be connected directly if the input is declared 5V-tolerant. Otherwise, exceeding its maximum can damage it.
Solution A: the voltage divider
If you only need to send a signal from 5V to 3.3V (unidirectional) and the signal is not very fast (like a slow UART or a relay control signal), you don’t need to buy anything. Two resistors are enough.
We want to step down from Vin = 5V to Vout = 3.3V. Using the formula:
If we choose:
- R1 (top):
- R2 (bottom, to ground):
Perfect! With a
Limitations: This does NOT work for I2C (which needs to go back and forth). Also, if the resistors are too large, the signal will be distorted at high speeds due to parasitic capacitance (low-pass filter effect).
Solution B: the converter module (the standard option)
You’ve surely seen those tiny red or blue boards sold for very little money. They have pins labeled HV (High Voltage) and LV (Low Voltage).
These modules are primarily designed for open-drain lines, such as I2C.
- HV: Connect your 5V power and 5V signals here.
- LV: Connect your 3.3V power and 3.3V signals here.
- GND: You MUST connect the grounds of both systems here!
Advantage: they are bidirectional on open-drain buses. For fast push-pull signals, SPI, or some UARTs, a buffer or transceiver designed for that specific direction and speed is usually better.
How bidirectional conversion works
Inside the board, there is an N-channel MOSFET and two pull-up resistors (one for each domain) per channel.
It’s an ingenious circuit that uses the MOSFET not as an amplifier, but as a smart pass gate.
The operation is based on comparing voltages:
- Idle state (no one talking): The pull-up resistors keep both sides high (3.3V on one side, 5V on the other). The MOSFET is cut off. All quiet.
- The 3.3V side pulls low to 0V (sends a “0”): The MOSFET’s internal diode conducts and pulls the 5V side low. Additionally, the MOSFET turns on and connects both sides to ground.
- The 5V side pulls low to 0V (sends a “0”): The MOSFET’s diode blocks, but the Gate voltage makes the MOSFET conduct, pulling the 3.3V side to ground.
Basically, if anyone puts a 0 on either side, that 0 is transmitted to the other side. If no one pulls low, both sides stay at their respective high voltages.
Which one should I choose?
- If you’re going from 3.3V to 5V, generally you don’t need anything (or a simple buffer).
- If you’re going from 5V to 3.3V (slow signal): voltage divider.
- If it’s I2C or fast signals: level shifter module.