A level shifter is a circuit that translates digital (or sometimes analog) signals between two voltage domains, allowing devices that operate at different logic voltages to communicate reliably. Common translations include 5V-to-3.3V, 3.3V-to-1.8V, and 1.2V-to-3.3V.
In practice
Level shifters appear wherever two ICs with mismatched supply voltages need to exchange signals. A typical embedded example is connecting a legacy 5V AVR or PIC to a 3.3V sensor or wireless module: driving a 3.3V input directly from a 5V GPIO can exceed the absolute maximum ratings of the lower-voltage device and damage it over time. On the receive side, a 3.3V logic-high output may fall below the VIH threshold of a 5V device that expects at least 3.5V, causing unreliable reads.
For unidirectional signals (UART TX, SPI MOSI/CLK, chip-selects), a simple resistor divider is often sufficient on the high-to-low direction. Integrated unidirectional level-shifter ICs such as the 74LVC245 (used with a 3.3V supply and 5V-tolerant inputs) or 74AHCT125 (used with a 5V supply to accept 3.3V-compatible inputs and drive 5V outputs) handle multiple lines at once and are widely used in practice, though they rely on specific supply and logic-compatibility conditions rather than being dedicated dual-supply translators. Bidirectional buses like I2C require a circuit that can pull in both directions; the classic approach uses a small-signal N-channel MOSFET (e.g., BSS138) with pull-up resistors on each voltage rail, a design detailed in the blog post "A simple working I2C (TWI) level shifter." Dedicated bidirectional level-shifter ICs such as the TXB0108 or PCA9306 are also common alternatives.
A frequent pitfall is assuming that a simple resistor divider is fast enough for all signals. RC time constants formed by the divider resistors and bus capacitance limit rise times, which becomes a problem at SPI clock rates above a few hundred kHz or on long PCB traces. Another pitfall is using voltage-translator ICs that specify a fixed direction per channel on a bus that is actually bidirectional (such as SMBus alert lines or I2C in multi-master mode), which can cause bus contention. Always check the datasheet for output-enable polarity, propagation delay, and the permitted voltage range on each port -- some devices allow a wide supply range on one side but not the other.
Discussed on EmbeddedRelated
Frequently asked
Can I always use a resistor divider to shift from 5V down to 3.3V?
For slow, unidirectional signals it is often adequate. A two-resistor divider (e.g., 1k and 2k) scales 5V to ~3.3V, but the output impedance limits speed: at a few hundred kHz and typical PCB capacitance the signal edges can become rounded. For
SPI or other faster interfaces, a buffer IC like the 74LVC1G17 or a
MOSFET-based shifter is a better choice. Resistor dividers also cannot drive a low-impedance input without loading effects.
Why does I2C level shifting need a special bidirectional circuit?
I2C is an
open-drain bus where either master or slave can pull the line low. A unidirectional shifter would block the low-side device from asserting the line seen by the high-side device, breaking acknowledgment and data transfers. The BSS138
MOSFET circuit (covered in 'A simple working I2C (TWI) level shifter') allows either side to pull the line low while the body
diode and gate biasing handle the opposite transition. Dedicated ICs like the PCA9306 implement the same principle in a single package.
What is the difference between the TXB0108 and the TXS0108E?
Both are Texas Instruments 8-bit bidirectional level translators. The TXB0108 uses
push-pull outputs and relies on an internal one-shot circuit to boost edge speed; it does not tolerate external
pull-up or
pull-down resistors, which makes it unsuitable for
open-drain buses like
I2C. The TXS0108E is also an auto-bidirectional translator but is designed to work with open-drain signals; it senses data direction automatically and is compatible with buses that use external pull-ups. Always check whether your bus topology is push-pull or open-drain before selecting a translator.
Do I need a level shifter if the lower-voltage device is 5V-tolerant?
Not necessarily for the input direction. Many 3.3V MCUs (for example, some STM32 and LPC families) mark certain
GPIO pins as 5V-tolerant in their datasheet, meaning they can safely accept 5V signals on those pins. However, the output of a 3.3V GPIO still swings to 3.3V, which may or may not meet the VIH threshold of a 5V receiver. Check both the tolerance of inputs and the drive level of outputs independently before omitting the shifter.
How do I choose between a discrete MOSFET circuit and an integrated level-shifter IC?
Discrete
MOSFET circuits (BSS138 or 2N7002) are inexpensive, easy to source, and work well at
I2C speeds (up to 400 kHz standard, sometimes 1 MHz fast-mode-plus with careful layout). Integrated ICs offer higher channel counts per package, tighter propagation delay specs, wider frequency support, and simpler layout. For a two- or four-line interface on a cost-sensitive design, discrete components are common. For high-speed
SPI, parallel buses, or volume production where board space matters, an integrated translator is usually preferred.
Differentiators vs similar concepts
Level shifters are sometimes confused with logic buffers and bus transceivers. A standard buffer (e.g., 74HC244) drives and reshapes signals but operates at a single voltage rail -- it does not translate between voltage domains. A bus transceiver like the 74LVC245 can act as a level shifter when its
VCC is lower than the signal being received on its input side, but only because the 74LVC family is specified for 5V-tolerant inputs with a 3.3V supply; this is a special-case property, not a general feature of all transceivers. True level-shifter ICs (TXB0108, PCA9306, NXP GTL2003) are explicitly designed with separate VCCA and VCCB rails and guaranteed translation across a range of voltage combinations. Separately, a logic-level converter is a marketing term used by module vendors (common on hobbyist breakout boards) that typically refers to the same BSS138-based bidirectional
MOSFET circuit, not a distinct technology.