Four-channel level shifter board
The BSS138 logic level converter board between 3.3 V and 5 V: pull a channel low on either side and the other side follows. There is no microcontroller in it: the simulator solves the 5 parts as a circuit, so it runs the moment you press Run, and nothing needs compiling.
Teaching? Assign it to your class in one click.
Beginner About 15 minutes to build and run. Runs in your browser. Free, and no account needed.
The parts retail for about $1.80. On Mokxi they're free.
What you'll learn
- Why 3.3 V and 5 V parts need a level shifter
- A BSS138 MOSFET as a two-way switch
- Pull-up resistors on both sides
- Reading voltages with a multimeter
- Difficulty: Beginner
- Time: About 15 minutes
- Parts: 5
How it works
This circuit has no microcontroller. A four-channel BSS138 logic level converter sits between a 3.3 V side (LV) and a 5 V side (HV). Each channel has a pull-up on each side, so with nothing pulling, each LV pin sits at 3.3 V and each HV pin at 5 V. Two multimeters read the voltages.
Switch the left rocker on and it pulls LV1 low. The MOSFET turns on and HV1 follows it down, so the right meter drops. Switch the right rocker on and it pulls HV2 low. The MOSFET's body diode drags LV2 down until the channel turns on, so the left meter drops. It works both ways, as an I2C bus needs.
Parts list
5 parts, plus the jumper wires and 2 bench instruments. The parts retail for about $1.80; on Mokxi they're free, and so are the instruments.
- 1 × Power, 3.3 V
- 1 × Power, 5 V
- 1 × Logic level converter, 4-channel BSS138
- 2 × Rocker switch, SPST
- 2 × Multimeter
Wiring table
Every connection, pin by pin, read from the circuit itself. Each row joins the pin on the left to the pin on the right, by a jumper wire or a breadboard strip.
| Part and pin | Connects to |
|---|---|
| Logic level converter, 4-channel BSS138 pin LV | 3.3 V |
| Logic level converter, 4-channel BSS138 pin HV | 5 V |
| Rocker switch, SPST (1) pin 1 | Logic level converter, 4-channel BSS138 pin LV1 |
| Multimeter (1) pin V | Logic level converter, 4-channel BSS138 pin LV2 |
| Logic level converter, 4-channel BSS138 pin GND | Ground |
| Multimeter (2) pin V | Logic level converter, 4-channel BSS138 pin HV1 |
| Rocker switch, SPST (2) pin 1 | Logic level converter, 4-channel BSS138 pin HV2 |
| Logic level converter, 4-channel BSS138 pin GND2 | Ground |
| Rocker switch, SPST (1) pin 2 | Ground |
| Rocker switch, SPST (2) pin 2 | Ground |
| Multimeter (1) pin COM | Ground |
| Multimeter (2) pin COM | Ground |
The notes that come with it
There is no microcontroller in this one, so nothing is compiled: the simulator solves the circuit itself. The file in the editor is the notes that come with it.
// The four-channel BSS138 logic level converter board.
//
// LV takes 3.3 V and HV takes 5 V. Each channel is one BSS138 with a 10k
// pull-up on each side, so with nothing pulling, each LV pin sits at 3.3 V
// and each HV pin at 5 V. Switch the left rocker on to pull LV1 low: the
// MOSFET turns on and HV1 (the right meter) follows it down. Switch the right
// one on to pull HV2 low: the body diode drags LV2 (the left meter) down until
// the channel turns on, so it works both ways, which is what an I2C bus needs
// between a 5 V Uno and a 3.3 V sensor.
Troubleshooting
The usual mistakes with this circuit, and the fix for each.
- Nothing follows when you flip a switch This project
Check that LV has 3.3 V, HV has 5 V, and that both grounds are tied together. - The voltages read near zero This project
Check that the meters are set to volts and that a switch is not already pulling the channel low. - Signals do not pass or the voltage is wrong on one side. Logic level converter
Connect LV to the 3.3 V supply and HV to the 5 V supply, and join all grounds. Both references must be present. Each channel is LV side to HV side, so wire the correct pins. - I2C works badly through the shifter. Logic level converter
The BSS138 board has pull-ups on both sides, so do not add stronger pull-ups. Do not use it for fast signals or for high power. Pick the right channels for SDA and SCL. - The switch never turns the load on or off. Rocker switch
An SPST rocker just opens or closes two legs. Wire it in series with the load on the live side. The side marked I closes the circuit. - The input reads random values when off. Rocker switch
An open switch leaves a pin floating. Add a pull-up or pull-down resistor, or use INPUT_PULLUP and read LOW as on. - The reading is zero, negative or nonsense when measuring voltage. Multimeter
Set the dial to volts first, then touch the probes across the part, in parallel. Red goes to the more positive point. A negative number just means the probes are swapped. - Measuring current gives zero or blows the meter's fuse. Multimeter
Current must flow through the meter, so break the circuit and put the meter in series. Never put an amps setting straight across a supply. Start with the highest current range.
Change it and keep it
Open it in the editor, change the circuit or the code, and keep your version in a free account.