Consider the microcontrollers, sensors, and communications modules that you work with when building a project. Some boards, like the Arduino Uno and Nano, operate at 5V, while others operate at 3.3V, like the Arduino MKR WIFI 1010, the ESP8266-based Wemos D1 Mini, and one variation of the Pro Micro.
The HC-05 Bluetooth module, for example, operates at 3.3V, but many sensors can operate at either 5V or 3.3V. Voltage dividers can be helpful when you need to mix signal types, but what if you'd like a component to shift things around in a more elegant manner? The answer, of course, is the aptly named level shifter.
What Does a Level Shifter Do?
A level shifter translates logic signals from one level to another. Usually, this shift takes place between 5V and 3.3V, but you can use other voltages as needed, such as 2.5V or 1.8V. Important specs to look for include:
- How much the shift may introduce time delay.
- What voltages are available.
- Whether shifts take place in one direction or are bi-directional, allowing signals to travel back and forth as needed.
Let's discuss a few shift dividers you might consider in your future designs or experiments.
Uni-Directional Level Shifting with the 74LVC245
One basic level-shifter is the 74LVC245 chip from Texas Instruments. This shifter can convert logic levels from inputs up to 5.5V down to between 3.6V and 1.65V, depending on the Voltage (VCC) powering the device. The direction-control (DIR) pin selects the shift's direction from one or more of the eight A or B input or output pins to its counterpart on the other side of the chip.
You can see this setup in the image below, where 5V powers a sensor module. The output in blue feeds to the A3 pin, which then passes to pin B3, set at a 3.3V level. Two important items to note:
1. The 3.3V supplied from the Wemos D1 mini board to the chip's VCC pinout dictates the output level and could theoretically be as low as 1.65V, depending on the needs of your circuit.
2. The output-enable (OE) pin is pulled to ground, while the DIR pin is connected to VCC, allowing shifts to occur from A to B pins.
74LVC245 in action
The shifter converts the 5V output from the sensor to a 3.3V signal to the Wemos board, causing the LED to light up in response (per a simple example program), while averting the danger of frying things from non-approved voltage levels. As noted on its datasheet, 3.3V or 5V devices can drive inputs, allowing it to resolve a mixed signal environment into a consistent output voltage. This particular chip only passes signals one way — or one way at a time depending on the state of the DIR pin — so if you need translation in both directions simultaneously, you'll want a different solution.
Bi-Directional Level Shifting
You have several shifter options when you need data to travel back and forth between different voltage levels. One such device is the TI TXB0108 chip. This shifter features banks of both A and B voltage level pins, similar to the 74LVC245. However, the TXB0108 doesn't have a DIR pin, as each input and output can detect and shift signals in either direction independently and automatically.
An OE pin is available to enable or stop data transmission, and VCCA and VCCB pins specify the voltage levels of both input and output banks. Notably, VCCA's maximum recommended voltage is 3.6V, while VCCB is 5.5V. Finally, VCCA is not designed to exceed VCCB.
BSS138 breakout subbed in for 74LVC245. Note object in sensor activating Wemos D1 mini ESP8266 board through this breakout.
While the TXB0108 is great for many applications, it doesn't work well with I2C, which uses an unusual pull-up arrangement to transfer data back and forth. For this specific job, you might instead turn to Adafruit's BSS138 MOSFET breakout with 10K pull-ups. The board features four bi-directional data lines, and unlike the other two shifters on this list that top out a little over 5V, this one can work with 10V on the high side. While most traditional level shifter applications wouldn't call for 10V, it's something to keep in mind for that oddball project that might not mesh well with the more "normal" components you have in your toolbox.
Level Shifters: Helping Components Work Together
While it would be great if every component played nicely with every other device without accommodations, level shifting is necessary for many situations. Whether this means a simple voltage divider or one of the more refined solutions, accommodating different signal level needs into your design is possible, though it may require an extra component or two.