59. Multi-Slave I2C Communication

We need to interface three I²C slave devices with a master microcontroller:

  • BMP180 Sensor – Measures pressure, temperature, and altitude (operates at 3.3 V).
  • DS1307 RTC – Provides real-time clock and calendar functions (operates at 5V).
  • OLED Display – Displays acquired data (operates at 3.3 V to 5 V).

The I²C communication frequency is set to 100 kHz, which is supported by all slave devices.

Voltage Level Compatibility

Before establishing connections, ensure that all devices operate within their safe voltage levels to prevent potential damage.

The diagram below (referenced from the datasheet) illustrates how a voltage level translator can be used to connect devices operating at different voltage domains.

I2C-voltage-level-shifter-interfacing
  • BMP180 includes an inbuilt voltage regulator (662k), allowing its SDA and SCL lines to be connected directly to the microcontroller without an external level shifter.
  • Supply the BMP180 module with 3.3 V to ensure correct operation.
  • So, when interfacing I²C devices operating at different voltages (e.g., 5 V ↔ 3.3 V), always use a voltage level shifter to ensure safe logic levels and reliable communication.

Interfacing I²C Buses Across Voltage Domains

When mixing I²C devices and microcontrollers operating at different logic voltages, two common scenarios arise. Careful bus-level management is necessary because I²C relies on open-drain lines pulled up to a defined voltage level.

1) Interfacing 5 V I²C Peripherals with a 3.3 V-Only Microcontroller

Challenge

  • The microcontroller’s I/O pins are not 5V-tolerant.
  • If pulled up to 5 V, the MCU inputs could be damaged.

Solutions

  • Pull-Ups to 3.3 V Only
    • Connect SDA and SCL pull-ups to 3.3 V.
    • 3.3 V idle high level is safe for the MCU and usually recognized by 5 V peripherals as a valid logic “1.”
    • No extra hardware needed if the 5 V devices are 3.3 V-tolerant on their I/O pins.
  • Bidirectional Level Shifter
    • Use a MOSFET-based or integrated I²C level translator (e.g., using BSS138).
    • MCU side pull-up to 3.3 V, peripheral side pull-up to 5 V.
    • Ensures safe voltage domains while maintaining open-drain operation.

2) Interfacing 3.3 V I²C Peripherals with a 5 V-Only Microcontroller

Challenge

  • The 5 V MCU’s SDA/SCL lines are pulled up to 5 V, which may overstress the 3.3 V device’s pins.

Solutions

  • Pull-Ups to 3.3 V Only + Verify Logic Recognition
    • Tie pull-ups to 3.3 V.
    • Ensure the 5 V MCU recognizes 3.3 V as logic “1” (check MCU datasheet for V_IH ≤ 3.3 V).
    • No extra hardware needed if this condition is met.
  • Bidirectional Level Shifter
    • Insert a level shifter between the MCU and the peripheral.
    • High-side pull-ups to 5 V, low-side to 3.3 V.
    • Prevents voltage overstress and ensures reliable communication.

Best Practices for Mixed-Voltage I²C Systems

  • Use Open-Drain Configuration – All devices should only pull the lines low, never drive them high.
  • Select Proper Pull-Up Resistors – Typical values are 4.7 kΩ to 10 kΩ. Place them near the master or mid-bus.
  • Verify Voltage Tolerances – Check device datasheets for V_IH, V_IL, and V_MAX on SDA/SCL pins.
  • Use a Logic Analyzer – Verify idle high voltage, clean rising edges, and correct ACK/NACK responses at the chosen bus speed. 

By selecting the correct pull-up voltage or integrating a bidirectional level translator when required, 3.3 V and 5 V I²C devices can safely coexist on the same bus without communication issues or damage.

Hardware Connections

Step-by-step:

  1. Connect 3.3 V and GND from the master MCU to the BMP180 sensor module, the OLED display and DS1307 RTC module.
  2. Connect the SDA and SCL lines of all devices.
  3. Use appropriate pull-up resistors on SDA and SCL lines (as per voltage domain).
  4. Ensure all devices share a common ground.
  5. Confirm total current draw is within the MCU’s sourcing/sinking limits to prevent overloading.

Final Implementation

Once the master and slave devices are connected and the I²C bus is configured, the task can be implemented using various platforms:

  1. STM32
  2. ESP32
  3. Arduino UNO

Submit Your Solution

Note: Once submitted, your solution goes public, helping others learn from your approach!