The TXS0108E is a bi-directional voltage level shifter that allows safe communication between devices operating at different voltage levels, such as 3.3V and 5V. It is commonly used to interface 5V microcontrollers (like Arduino) with 3.3V sensors or modules. This tutorial will guide you through using the TXS0108E with Arduino.
What You Will Need
- TXS0108E Voltage Level Shifter Module
- Arduino Board (e.g., Uno, Mega, Nano)
- 3.3V and 5V devices (e.g., sensors, modules)
- Breadboard and Jumper Wires
- A computer with the Arduino IDE installed
Step 1: Understanding the TXS0108E Module
The TXS0108E module has two power domains:
- VCCA: Power supply for the low-voltage side (1.2V - 3.6V, e.g., 3.3V devices).
- VCCB: Power supply for the high-voltage side (1.65V - 5.5V, e.g., 5V devices).
It can handle up to 8 bi-directional data lines, allowing communication in both directions.
TXS0108E Pinout
Pin | Function |
---|---|
VCCA | Low-voltage side power supply |
VCCB | High-voltage side power supply |
GND | Ground |
OE | Output Enable (active HIGH) |
Ax | Low-voltage side data lines (A1-A8) |
Bx | High-voltage side data lines (B1-B8) |
Step 2: Wiring the TXS0108E to Arduino
Below is an example of connecting the TXS0108E to an Arduino and a 3.3V I2C device (e.g., BMP280 sensor):
Connections
TXS0108E Pin | Arduino Pin | 3.3V Device Pin |
---|---|---|
VCCA | 3.3V | 3.3V |
VCCB | 5V | N/A |
GND | GND | GND |
A1 | A4 (SDA, low-voltage) | SDA |
A2 | A5 (SCL, low-voltage) | SCL |
B1 | Device SDA | N/A |
B2 | Device SCL | N/A |
OE | 5V | N/A |
Note: Ensure that both VCCA and VCCB are connected to their respective voltage supplies and that
OE
is tied to HIGH (5V) to enable the module.
Step 3: Upload the Arduino Code
Here’s an example sketch to communicate with a 3.3V I2C device (e.g., BMP280 sensor) through the TXS0108E:
Example Code
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp; // Create BMP280 object
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("Initializing BMP280...");
if (!bmp.begin(0x76)) { // Default I2C address for BMP280
Serial.println("Could not find a valid BMP280 sensor. Check wiring.");
while (1);
}
Serial.println("BMP280 initialized.");
}
void loop() {
Serial.print("Temperature: ");
Serial.print(bmp.readTemperature());
Serial.println(" °C");
Serial.print("Pressure: ");
Serial.print(bmp.readPressure());
Serial.println(" Pa");
delay(1000); // Wait for a second before the next reading
}
Step 4: Test the Setup
- Connect the Arduino to your computer via USB.
- Open the Arduino IDE and select the correct Board and Port under the Tools menu.
- Upload the code by clicking Upload.
- Open the Serial Monitor (Tools > Serial Monitor) and set the baud rate to
9600
. - Observe the temperature and pressure readings from the BMP280 sensor.
Applications of the TXS0108E
- Interfacing 5V microcontrollers with 3.3V sensors or modules.
- Level-shifting for SPI, I2C, UART, or other communication protocols.
- Enabling bi-directional communication between mixed-voltage devices.
Troubleshooting
- No communication: Verify wiring for VCCA, VCCB, and OE. Ensure the correct I2C address is used.
- Unstable data: Use short wires and check for stable power supplies.
- Device not responding: Ensure voltage compatibility and double-check connections on both sides.
Conclusion
You’ve successfully used the TXS0108E level shifter with Arduino to enable communication between devices operating at different voltage levels. This versatile module is essential for bridging voltage gaps in mixed-signal systems. Experiment further by connecting other devices and exploring its applications in your projects!