Logic Level Shifter: 5 Proven Methods for Safe 3.3 V Links

Share:
Digital Electronics
Logic Level Shifter: 5 Proven Methods for Safe 3.3 V Links

A 3.3 V sensor wired straight to a 5 V board can be damaged, while a 3.3 V output may not look high enough to a 5 V input. The right translation method protects both sides and keeps every bit readable.

3.3 V to 5 V BSS138 MOSFET TXS0108E TXB0108 VIH and VIL

Mixed voltage boards are now normal, with 3.3 V microcontrollers talking to 5 V displays, relays and sensors. A logic level shifter chosen for the bus type and speed keeps both sides safe and every bit valid.

Hello everyone, today we are going to learn what a logic level shifter is, how the BSS138 MOSFET circuit works on I2C, when to choose TXS0108E or TXB0108 and how to check VIH and VIL margins.
logic level shifter

What Is a Logic Level Shifter?

A logic level shifter is a circuit that translates digital signals between two supply voltages, such as 3.3 V and 5 V, so that a high on one side is read as a valid high on the other without overstressing any pin. It is needed whenever a modern microcontroller talks to an older 5 V module.

The problem has two halves. A 5 V output driving a 3.3 V input pushes current through the input protection diodes, and a 3.3 V output driving a 5 V input may sit below the high threshold described in TTL vs CMOS logic families.

TXS0108 eight channel bidirectional voltage translator module used between 3.3 V and 5 V logic
Image credit: Big Mess o Wires. Photo courtesy of Big Mess o Wires, shown here for educational reference.

A logic level shifter can be one way, such as a sensor output feeding a controller, or two way, such as an I2C data line shared by many devices.

Do You Know?

Philips, now NXP, published the two resistor, one MOSFET bidirectional shifter for I2C in application note AN97055. The same circuit is still on most low cost blue level shifter boards sold today.

Advertisement

Understanding VIH, VIL and Noise Margins

Every logic input has a minimum voltage it accepts as high, called VIH, and a maximum voltage it accepts as low, called VIL. Every output has a guaranteed high, VOH, and a guaranteed low, VOL, at a stated load current.

Family at SupplyVIH minVIL maxNotes
5 V TTL and 74HCT2.0 V0.8 VAccepts 3.3 V outputs directly
5 V CMOS 74HC3.5 V1.5 V0.7 and 0.3 of VCC, rejects 3.3 V
ATmega328P at 5 V3.0 V1.5 V0.6 and 0.3 of VCC, thin margin
3.3 V LVCMOS2.0 V0.8 VUsually not 5 V tolerant

This table explains the most common surprise. A 3.3 V output easily satisfies a 74HCT or TTL input at 2.0 V, but a 74HC gate at 5 V needs 3.5 V and may read the same signal as undefined, a zone explained in digital logic gates.

Quick Tip

Before buying any converter, check the receiver datasheet for VIH and the absolute maximum input voltage. Many 3.3 V to 5 V links need no translator at all, only a 74HCT buffer or a 5 V tolerant input.

5 Proven Logic Level Shifter Methods

Resistor Divider

Two resistors scale a 5 V output down to about 3.3 V.

Best for: one way, 5 V into 3.3 V, slow signals
Cheapest
BSS138 MOSFET Shifter

One N channel MOSFET and two pull ups per line, as in NXP AN97055.

Best for: I2C, SMBus and other open drain buses
Bidirectional
TXS0108E Auto Direction

Pass transistor with one shot edge accelerators and internal pull ups.

Best for: I2C, MDIO and mixed open drain lines
8 channels
TXB0108 Buffered

Active buffers with weak 4 kΩ series resistors and edge detection.

Best for: push pull SPI, UART and GPIO
Up to 100 Mbps
Direction Controlled Buffer

74LVC245 or 74HCT family gates with a fixed or controlled direction.

Best for: fast one way buses and data buses
Robust

A voltage divider is fine for a 5 V output entering a 3.3 V input at modest speed.

The MOSFET circuit and the TXS family suit open drain buses, while the TXB family and dedicated buffers suit push pull links such as SPI and UART. Matching the logic level shifter to the bus is the main design rule.

How the BSS138 Logic Level Shifter Works on I2C

In the classic logic level shifter, the gate of an N channel MOSFET goes to the low supply, the source goes to the low side line with its own pull up, and the drain goes to the high side line with a pull up to 5 V. NXP AN97055 lists three states that make it bidirectional without any direction pin.

Both Sides HighGate and source both at 3.3 V, so VGS is zero and the MOSFET is off.
Low Side Pulls LowSource falls, VGS becomes 3.3 V, MOSFET turns on and pulls the 5 V side low.
High Side Pulls LowBody diode drags the source to about 0.7 V, VGS rises above threshold and the channel turns on.
Line ReleasedPull ups restore each side to its own high level independently.

NXP states that the gate threshold should be between 0.1 V and 2 V, and that the circuit works down to about 2 V on the lower side and up to 10 V or more on the higher side. The BSS138 has a typical threshold near 1.3 V, which suits a 3.3 V gate drive.

Because rising edges come only from the pull up resistors, the speed of this logic level shifter is set by resistor value and bus capacitance. It is ideal for 100 kHz and 400 kHz I2C, as compared in SPI vs I2C, but weak for fast SPI clocks.

Do You Know?

In the MOSFET shifter, the low supply must stay at or below the high supply. If the 3.3 V rail powers up after the 5 V rail, the bus can see odd levels for a moment, so power sequencing still matters.

Divider Formula and Margin Check

Vout = Vin × R2 ÷ (R1 + R2)
VIH = 0.7 × VDD of receiver
Margin = Vout minus VIH

Example:
Vin = 5 V, R1 = 1 kΩ, R2 = 2 kΩ, VDD = 3.3 V
Vout = 5 × 2 ÷ 3 = 3.33 V
VIH = 0.7 × 3.3 = 2.31 V
Margin = 3.33 minus 2.31 = 1.02 V, safe

Vout must also stay below the receiver absolute maximum, usually VDD plus 0.3 V. Here 3.33 V is below 3.6 V, so the input is protected.

Voltage Divider Level Shift Calculator

Divider Output and High Level Margin
Result
Vout 3.33 V, VIH 2.31 V, margin 1.02 V, safe

Second Worked Example: Divider Speed Limit

Suppose you use 10 kΩ and 20 kΩ to save current, and the receiving pin plus wiring adds 10 pF. The source sees the two resistors in parallel, 6.67 kΩ, so the time constant is 6.67 kΩ × 10 pF = 66.7 ns.

The 10 to 90 percent rise time is about 2.2 times that, or 147 ns, which is acceptable for a 115200 baud UART but rounds off a fast SPI clock badly. The same RC behaviour is explained in RC low pass filters.

Advertisement

TXS0108E vs TXB0108: Choosing the IC

Texas Instruments rates the TXS0108E for 1.4 V to 3.6 V on the A port and 1.65 V to 5.5 V on the B port, with VCCA never above VCCB. Its datasheet quotes 110 Mbps push pull and 1.2 Mbps open drain at 3.3 V to 5 V.

The TXS0108E has dynamic internal pull ups of 40 kΩ while a line is low and 4 kΩ while it is high, plus one shot circuits that speed up edges.

The TXB0108 uses active buffers behind roughly 4 kΩ series resistors and can reach 100 Mbps. TI states clearly that it should not be used where an open drain driver is connected, such as I2C or 1 Wire.

TXS0108E Strengths
  • Works with open drain I2C and MDIO lines.
  • Internal pull ups save parts.
  • OE pin gives clean power sequencing.
  • B port ESD rated to 8 kV contact.
TXB0108 Strengths
  • Strong push pull edges up to 100 Mbps.
  • No pull up current in steady state.
  • Good for SPI, UART and parallel GPIO.
  • Small footprint for eight lines.

Big Mess o Wires tested the TXS0108 and found that even a 6 inch wire could trigger oscillation, because its one shot of about 30 ns reacts to reflections. The same author found that the TXB0104 needs drivers able to supply at least 2 mA.

Quick Tip

When a TXS0108E board misbehaves on jumper wires, shorten the wires, add a small series resistor of about 22 to 33 Ω near the driver, or move to a MOSFET shifter for slow lines.

Selecting the Right Translator

1
Identify Bus Type
Open drain such as I2C, or push pull such as SPI and UART.
2
Check Direction
One way lines allow simple dividers or buffers.
3
Confirm Speed
Compare clock rate with RC rise time or IC data rate.
4
Check Supplies
Keep VCCA at or below VCCB and plan power up order.
5
Verify Margins
Calculate VOH minus VIH and VIL minus VOL on both sides.

For a single 5 V HC SR04 ultrasonic sensor echo pin into a 3.3 V board, a divider is enough. For an I2C display shared by several 3.3 V and 5 V devices, the MOSFET logic level shifter is the safer and cheaper choice.

Myth: Every 3.3 V to 5 V link needs a level shifter.
Fact: Many 5 V inputs, such as 74HCT and TTL, read 3.3 V as a valid high.
Myth: A blue MOSFET board works for SPI at any speed.
Fact: Rising edges depend on pull ups, so fast clocks get rounded and fail.
Myth: The TXB0108 is an upgraded TXS0108E for I2C.
Fact: TI says the TXB0108 must not be used on open drain buses such as I2C.
Myth: A series resistor alone makes a 3.3 V pin 5 V safe.
Fact: It only limits clamp current, and the injected current can still upset the chip.
Do You Know?

A 5 V signal into a 3.3 V pin may appear to work because current flows through the input clamp diode into the 3.3 V rail. That hidden current can raise the rail itself when the board draws little load.

Troubleshooting a Logic Level Shifter

  • Confirm the low supply goes to LV and the high supply to HV.
  • Measure both supplies and confirm VCCA is not above VCCB.
  • Check that OE is pulled high on TXS and TXB boards.
  • Look at rising edges on a scope for slow rounding or ringing.
  • Count pull ups on I2C, since modules often add their own.
  • Confirm a common ground between both boards.
  • Remove external pull ups below 50 kΩ when using a TXB0108.

If an I2C scan finds nothing, swap SDA and SCL first, then measure the idle level on each side, which should sit at its own supply. A stuck low line usually means a device is holding the bus or a pull up is missing; compare this with how pull ups behave on RS485 biasing resistors.

For noisy industrial wiring where ground potential differs between panels, use a digital isolator or an optocoupler rather than a plain shifter. A plain logic level shifter has no isolation barrier at all.

Advertisement

Where a Logic Level Shifter Is Used

Raspberry Pi and ESP32 Projects
3.3 V boards driving 5 V relays, LCDs and LED strips.
I2C Sensor Buses
Mixing 3.3 V and 5 V sensors on one bus.
SD Cards and Flash
3.3 V memories connected to 5 V controllers.
Industrial Interface Boards
Translating between FPGA banks and legacy logic.
Programming Headers
ISP and JTAG adapters supporting many target voltages.

NXP AN97055 Bidirectional Level Shifter Note

PDF
AN97055 Bi Directional Level Shifter for I2C Bus and Other Systems
Philips Semiconductors application note on the MOSFET shifter

Voltage Level Shifting Video Tutorial

Logic Level Shifter FAQ

What does a logic level shifter do?

It translates digital signals between two supply voltages, such as 3.3 volts and 5 volts. A high on one side then appears as a valid high on the other side.

It also protects lower voltage pins from damaging current. Without it, a 5 volt output can push current into a 3.3 volt input through its clamp diodes.

Can I connect 3.3 V outputs directly to 5 V inputs?

Sometimes yes, if the 5 volt input has a TTL style threshold of about 2 volts. Parts in the 74HCT family and many TTL compatible chips accept 3.3 volt highs easily.

A 74HC gate at 5 volts needs about 3.5 volts for a high, so it may fail. Always compare the driver output high with the receiver input high in the datasheets.

Why is the BSS138 used for I2C level shifting?

It is a small N channel MOSFET with a low gate threshold near 1.3 volts. A 3.3 volt gate supply therefore turns it fully on when either side pulls low.

Its body diode lets the 5 volt side pull the 3.3 volt side down first. That behaviour gives true bidirectional operation without any direction control pin.

Should I choose TXS0108E or TXB0108?

Choose the TXS0108E for open drain buses such as I2C, because it has internal pull ups and one shot edge accelerators. It also handles mixed open drain and push pull lines.

Choose the TXB0108 for push pull links such as SPI and UART that need speed. Texas Instruments warns that the TXB0108 should not be used with open drain drivers.

Is a resistor divider good enough?

A divider works well for one way signals from a 5 volt output into a 3.3 volt input. Values such as 1 kilohm and 2 kilohm give about 3.33 volts.

It cannot raise a 3.3 volt signal to 5 volts or work in both directions. Large resistor values also slow the edges because of input capacitance.

How fast can a MOSFET shifter run?

Its rising edges come only from the pull up resistors charging the bus capacitance. That makes it suitable for standard and fast mode I2C at 100 and 400 kilohertz.

For faster signals, lower the pull up values or move to a buffered translator. Always check the edge shape on an oscilloscope after making the change.

Do I need a common ground with a level shifter?

Yes, both boards must share the same ground reference for the voltage levels to mean anything. A missing ground often shows as random bits or no communication at all.

If the grounds cannot be joined safely, use a digital isolator or optocoupler instead. These devices pass the signal across an insulation barrier without a shared ground.

Advertisement

Related Articles

External References

What We Learn Today

  • A logic level shifter translates signals between supplies such as 3.3 V and 5 V while keeping VIH and VIL margins positive on both sides of the link.
  • The BSS138 MOSFET circuit from NXP AN97055 gives true bidirectional translation for I2C, using only one transistor and two pull up resistors per line.
  • Choose the TXS0108E for open drain buses and the TXB0108 for fast push pull SPI or UART, because TI warns the TXB0108 must not drive I2C.
I hope you like above blog. There is no cost associated in sharing the article in your social media. Thanks for reading!! Happy Learning!!

Leave a Reply

Your email address will not be published. Required fields are marked *