> ## Documentation Index
> Fetch the complete documentation index at: https://learn.pcbcupid.com/llms.txt
> Use this file to discover all available pages before exploring further.

> The Bi-Directional Voltage-Level Translator Module uses the TXB0104PW IC to provide seamless 4-bit auto-sensing level translation between 1.2V, 1.8V, 2.5V, 3.3V, and 5V logic domains.

# Bi-Directional Voltage-Level Translator

export const ShopHeader = ({title, url}) => <div style={{
  display: 'flex',
  justifyContent: 'flex-end',
  alignItems: 'center',
  width: '100%',
  marginBottom: '1rem',
  gap: '20px'
}}>
    <a href={url} target="_blank" rel="noopener noreferrer" style={{
  display: 'inline-flex',
  alignItems: 'center',
  backgroundColor: '#00b894',
  color: '#fff',
  padding: '8px 18px',
  borderRadius: '8px',
  textDecoration: 'none',
  fontSize: '0.95rem',
  fontWeight: 600,
  whiteSpace: 'nowrap',
  flexShrink: 0
}}>
      Shop now
    </a>
  </div>;

export const ImgGallery = ({images, modelUrl}) => {
  var [active, setActive] = useState(0);
  var [show3D, setShow3D] = useState(false);
  useEffect(function () {
    if (show3D || images.length <= 1) return;
    var t = setTimeout(function () {
      setActive(function (p) {
        return (p + 1) % images.length;
      });
    }, 3500);
    return function () {
      clearTimeout(t);
    };
  });
  var img = images[active];
  return <div style={{
    position: 'relative',
    background: 'linear-gradient(to bottom, #fff 0%, #fff 80%, #f8f8f8 100%)',
    borderRadius: '32px',
    border: '1px solid rgba(0,0,0,0.08)',
    overflow: 'hidden',
    marginTop: '0.75rem',
    marginBottom: '1.5rem'
  }}>
      <div style={{
    position: 'relative',
    height: '450px',
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'center',
    background: '#fff',
    padding: '1rem'
  }}>
        {show3D && modelUrl ? <div ref={function (el) {
    if (!el || el._mv) return;
    el._mv = true;
    function addMv() {
      var mv = document.createElement('model-viewer');
      mv.setAttribute('src', modelUrl);
      mv.setAttribute('camera-controls', '');
      mv.setAttribute('auto-rotate', '');
      mv.style.width = "100%";
      mv.style.height = "100%";
      mv.style.backgroundColor = "#f8f8f8";
      el.innerHTML = "";
      el.appendChild(mv);
    }
    if (window.customElements && window.customElements.get('model-viewer')) {
      addMv();
    } else {
      var s = document.createElement('script');
      s.src = "https://ajax.googleapis.com/ajax/libs/model-viewer/4.2.0/model-viewer.min.js";
      s.type = "module";
      s.onload = addMv;
      document.head.appendChild(s);
    }
  }} style={{
    width: "100%",
    height: "100%"
  }} /> : <img src={img && img.url} alt={img && img.label} loading="lazy" style={{
    maxWidth: '100%',
    maxHeight: '100%',
    objectFit: 'contain',
    borderRadius: '8px'
  }} />}
      </div>
      <div style={{
    display: 'flex',
    justifyContent: 'center',
    gap: '12px',
    padding: '1rem',
    background: '#eee',
    borderTop: '1px solid rgba(0,0,0,0.08)'
  }}>
        {images.map(function (img, idx) {
    return <button key={img.id || idx} onClick={function () {
      setActive(idx);
      setShow3D(false);
    }} style={{
      padding: '0.6rem 1.5rem',
      borderRadius: '12px',
      border: !show3D && idx === active ? '1px solid #00b894' : '1px solid rgba(0,184,148,0.4)',
      background: !show3D && idx === active ? '#00b894' : '#fff',
      color: !show3D && idx === active ? '#fff' : '#000',
      cursor: 'pointer',
      fontSize: '0.75rem',
      fontWeight: 700,
      textTransform: 'uppercase',
      fontFamily: 'inherit'
    }}>
              {img.label}
            </button>;
  })}
        {modelUrl ? <button onClick={function () {
    setShow3D(true);
  }} style={{
    padding: '0.6rem 1.5rem',
    borderRadius: '12px',
    border: show3D ? '1px solid #00b894' : '1px solid rgba(0,184,148,0.4)',
    background: show3D ? '#00b894' : '#fff',
    color: show3D ? '#fff' : '#000',
    cursor: 'pointer',
    fontSize: '0.75rem',
    fontWeight: 700,
    textTransform: 'uppercase',
    fontFamily: 'inherit'
  }}>
            3D VIEW
          </button> : null}
      </div>
    </div>;
};

<ShopHeader title="Bi-Directional Voltage-Level Translator" url="https://shop.pcbcupid.com/" />

<ImgGallery
  modelUrl="https://library.pcbcupid.com/api/3d-model/GM017-BI-VOLTAGE-LEVEL-TRANSLATOR/file/glb/GM017-BI-VOLTAGE-LEVEL-TRANSLATOR.glb"
  images={[
{ url: 'https://library.pcbcupid.com/api/repo/pcbcupid/pcbcupid-board-illustrations/file/illustrations/GM017-BI-VOLTAGE-LEVEL-TRANSLATOR/GM017-BI-VOLTAGE-LEVEL-TRANSLATOR-FB-o.svg', label: 'ILLUSTRATION VIEW', id: 'illustration' },
]}
/>

The **Bi-Directional Voltage-Level Translator Module** is a 4-bit non-inverting voltage converter designed to bridge communication between devices operating at different logic voltage levels. Powered by the Texas Instruments **TXB0104PW** IC, this module features automatic direction sensing, eliminating the need for a direction control pin (`DIR`) and simplifying hardware connections.

Whether interfacing a 3.3V microcontroller (e.g., GLYPH, ESP32, STM32, Raspberry Pi) with legacy 5V sensors and modules, or communicating with modern 1.8V low-power components, this module enables reliable bidirectional signal transmission for SPI, UART, and general GPIO lines.

***

## Pin Configuration

The module is arranged with two independent voltage domains on opposing sides:

### Side A (Port A - Lower Voltage Side)

| Pin      | Type   | Description                                                   |
| :------- | :----- | :------------------------------------------------------------ |
| **VCCA** | Power  | Supply voltage for Port A (1.2V to 3.6V). Must be $\le$ VCCB. |
| **A1**   | I/O    | Channel 1 Data Input / Output (referenced to VCCA)            |
| **A2**   | I/O    | Channel 2 Data Input / Output (referenced to VCCA)            |
| **A3**   | I/O    | Channel 3 Data Input / Output (referenced to VCCA)            |
| **A4**   | I/O    | Channel 4 Data Input / Output (referenced to VCCA)            |
| **GND**  | Ground | Common Ground Reference                                       |

### Side B (Port B - Higher Voltage Side)

| Pin      | Type   | Description                                                    |
| :------- | :----- | :------------------------------------------------------------- |
| **VCCB** | Power  | Supply voltage for Port B (1.65V to 5.5V). Must be $\ge$ VCCA. |
| **B1**   | I/O    | Channel 1 Data Input / Output (referenced to VCCB)             |
| **B2**   | I/O    | Channel 2 Data Input / Output (referenced to VCCB)             |
| **B3**   | I/O    | Channel 3 Data Input / Output (referenced to VCCB)             |
| **B4**   | I/O    | Channel 4 Data Input / Output (referenced to VCCB)             |
| **GND**  | Ground | Common Ground Reference                                        |

<Info>
  **Important Voltage Rule**: According to the TXB0104PW specification, **VCCA must always be less than or equal to VCCB** ($V_{CCA} \le V_{CCB}$). For example, connect your 3.3V supply to VCCA and your 5V supply to VCCB.
</Info>

***

## Key Features

* **TXB0104PW Core**: Advanced 4-bit non-inverting translator with automatic direction sensing.
* **Auto-Direction Sensing**: Eliminates the need for external direction-control signals, enabling plug-and-play communication.
* **Wide Voltage Translation**:
  * **Port A**: 1.2V to 3.6V
  * **Port B**: 1.65V to 5.5V
* **High Speed Capability**:
  * Up to **100 Mbps** for push-pull drivers (SPI, UART, standard GPIO)
  * Up to **20 Mbps** for open-drain configurations
* **Low Power Consumption**: $4\,\mu\text{A}$ maximum static current ($I_{CC}$).
* **Built-in ESD Protection**: $\pm 15\text{-kV}$ Human Body Model (HBM) ESD protection on B-port lines.
* **4 Independent Channels**: Capable of converting up to 4 parallel data or control lines simultaneously.

***

## Applications

* Bridging 3.3V microcontrollers (GLYPH, ESP32, RP2040) with 5V logic sensors and displays.
* Interfacing 1.8V ultra-low-power sensors with standard 3.3V systems.
* High-speed level shifting for SPI buses (SCK, MOSI, MISO, CS).
* UART level translation (TX, RX, RTS, CTS).
* Mixed-voltage prototyping and industrial control interface modules.

***

## Step 1: Hardware Required

1. **Glyph Board** (e.g., Glyph ESP32-C3) or compatible 3.3V development board
2. **G-MOD Bi-Voltage Level Translator Module (TXB0104PW)**
3. **5V Device or Target Peripheral** (e.g., 5V Arduino, 5V sensor, or 5V logic source)
4. Jumper wires and breadboard

***

## Step 2: Circuit Connections

Connect the lower-voltage side (Side A) to your GLYPH board and the higher-voltage side (Side B) to your 5V system:

| Translator Pin   | Glyph / Controller (3.3V Side) | Target System (5V Side)       | Description                    |
| :--------------- | :----------------------------- | :---------------------------- | :----------------------------- |
| **VCCA**         | **3.3V**                       | —                             | Port A supply reference (3.3V) |
| **GND (Side A)** | **GND**                        | —                             | Common ground                  |
| **A1**           | **GPIO 4** (TX / Output)       | —                             | 3.3V logic signal line 1       |
| **A2**           | **GPIO 5** (RX / Input)        | —                             | 3.3V logic signal line 2       |
| **VCCB**         | —                              | **5V**                        | Port B supply reference (5.0V) |
| **GND (Side B)** | —                              | **GND**                       | Common ground reference        |
| **B1**           | —                              | **5V Peripheral RX / Input**  | Translated 5V signal line 1    |
| **B2**           | —                              | **5V Peripheral TX / Output** | Translated 5V signal line 2    |

<Warning>
  Ensure both grounds (`GND` on Side A and `GND` on Side B) share a common ground reference with both connected systems for stable signal translation.
</Warning>

***

## Step 3: Arduino Code Setup

The following example demonstrates transmitting and receiving data across voltage domains using hardware serial (UART) through the TXB0104 level translator.

1. **Open Arduino IDE.**
2. **Copy and paste the following code into the Arduino IDE:**

```cpp theme={null}
// UART Bidirectional Level Shifting Example using TXB0104
// Connect A1 to GPIO 4 (TX), A2 to GPIO 5 (RX)

#define TX_PIN 4
#define RX_PIN 5

HardwareSerial LevelShiftSerial(1);

void setup() {
  // Initialize primary serial monitor communication
  Serial.begin(115200);
  delay(1000);

  Serial.println("--- TXB0104 Voltage Level Translator Test ---");

  // Initialize secondary serial port on GPIO 4 & 5 at 9600 baud
  LevelShiftSerial.begin(9600, SERIAL_8N1, RX_PIN, TX_PIN);
  Serial.println("UART port initialized on GPIO 4 (TX) & GPIO 5 (RX).");
}

void loop() {
  // Send data from 3.3V GLYPH to 5V peripheral through TXB0104 (A1 -> B1)
  LevelShiftSerial.println("PING from 3.3V GLYPH");
  Serial.println("Sent: 'PING from 3.3V GLYPH' -> Shifted to 5V (B1)");

  // Read response from 5V peripheral shifted to 3.3V (B2 -> A2)
  unsigned long timeout = millis() + 500;
  while (millis() < timeout) {
    if (LevelShiftSerial.available()) {
      String response = LevelShiftSerial.readStringUntil('\n');
      Serial.print("Received shifted response: ");
      Serial.println(response);
      break;
    }
  }

  delay(2000);
}
```

***

## Step 4: Upload the Code

1. **Connect the Board**
   * Connect your GLYPH board to your computer using a USB-C cable.

2. **Select the Board and Port**
   * In Arduino IDE, go to `Tools > Board > esp32 > Pcbcupid GLYPH C3`.

<Warning>
  For the `Pcbcupid Glyph C3` to appear under `Tools > Board > esp32`, the esp32 board version installed in the Arduino IDE should be greater than or equal to 3.1.0.
</Warning>

* Go to `Tools > Port` and select the serial port assigned to your GLYPH.
* Set `Tools > USB CDC on Boot` to **Enabled**.

<Warning>
  If **USB CDC on Boot** is not enabled, you will not see serial output in the Arduino IDE Serial Monitor.
</Warning>

3. **Upload the Code**
   * Click the **Upload** button (➡️ icon) or press `Ctrl + U` to compile and flash the firmware.

***

## Step 5: Observe Output on Serial Monitor

1. Open the Arduino IDE Serial Monitor (`Ctrl + Shift + M`).
2. Set the baud rate to **115200**.
3. Verify that outbound 3.3V signals are shifted to 5V on Port B, and incoming 5V signals from the peripheral are translated safely to 3.3V on Port A without distortion.
