Learn how you can use bi-directional logic level converters to connect MCUs and modules with different maximum voltages.
When you use a few sensors with development boards, such as an Arduino, you'll likely encounter the following problem: your board outputs digital logic signals with a voltage of 5V (for a high state) but the breakout board only works with a maximum voltage of 3.3V. How do you adjust so nothing gets fried?
While there are several techniques for overcoming the difficulties, the most simple one is using a logic level converter. This article will teach you how to connect and use one of these devices.
How Does a Logic Level Converter Work?
While there are many different versions of logic level converters, most (if not all) of them use a very simple circuit to achieve the desired voltage shifting. Most converter breakout boards have four independent channels and each channel consists of a transistor and the necessary resistors.
The basic circuit diagram of a logic level converter.
We won't be going into the deep details of this circuit's specific characteristics, as it's not the main goal of this article. I recommend you refer to the converter's specific application note (PDF) for further details.
A Logic Level Converter Pinout
Usually, these voltage converter boards have the same input and output:
The pinout for a level converter.
The higher voltage supply (labeled 5V) and the lower voltage supply (labeled 3V3), together with their respective ground pins, need to be connected to the corresponding pins of your devices. These pins are only used for supplying a voltage to the voltage shifting circuit, these are not the data lines.
This device has four independent data channels labeled HVx and LVx, where x is the channel number between one and four. HV1 (higher voltage channel 1) connects to LV1 (lower voltage channel 1) and so on.
This particular device is called a bi-directional level shifter, which means that a signal can be shifted from low-voltage to high-voltage side and vice-versa. A unidirectional shifter allows the conversion of the signal in only one direction (low to high or high to low).
Make sure to consult your breakout board’s manual for its ratings (low voltage, high voltage, and maximum frequency).
Connecting an Arduino to a Module With a Logic Level Converter
Many makers will want to use this (or a similar device) for connecting an MCU to a sensor or a breakout board. In this simple example, I’ll connect an Arduino Uno to an ESP8266 WIFI module.
Even though the ESP8266 breakout board works just fine with 5V signals, others might not and it’s always better to be safe if you’re not sure what logic level your device uses.
Instead of directly connecting the ESP8266’s TX and RX lines to the Arduino’s GPIO pins, I connected them with the logic level converter in between:
Logic Level Converters: Small but Mighty
A logic level converter is a small but very useful device to always have around. It’s helpful for connecting devices that use different voltage levels for logic signals. Just keep in mind that there are both bidirectional and unidirectional converters available and always make sure to check your converter’s manual for its ratings.