I'm using an ESP32 WROOM 32 on a custom board. This board takes three 4-20mA inputs and writes the results onto an LCD.

It's set up to have an I2C 20x4 LCD on the I2C0 and an ADC(ADS1115) on I2C1. There is a BSS138 based level shifter on both buses to ensure the ESP32 side stays at 3.3v, the circuitry is identical to the adafruit product here:


I'm running into an issue where I cannot access both I2C buses simultaneously. I can access the LCD and ADC separately which leads me to believe there is nothing wrong with the circuitry.

My current workaround is to initialize the I2C (using Wire.begin) with the SCL and SDA pins for the ADC, perform the ADC read, then re-initialize I2C for the LCD pins when writing values to the LCD.

I've included the code for review:

#include <Wire.h>
#include "ADS1X15.h"
#include <LiquidCrystal_I2C.h>

//define I2C address......
LiquidCrystal_I2C lcd(0x27,20,4);

ADS1115 ADS(0x48);

#define I2C0_SDA 21
#define I2C0_SCL 22

#define I2C1_SDA 16
#define I2C1_SCL 17

  int16_t val_0 = 0;
  int16_t val_1 = 0;
  int16_t val_2 = 0;

void setup() {
  Serial.println("ADS1115 Readings");

void loop() {


void ADCroutine() {

  val_0 = ADS.readADC(0);  
  val_1 = ADS.readADC(1);  
  val_2 = ADS.readADC(2);    

  float f = ADS.toVoltage(1);  //  voltage factor

  Serial.print("\tAnalog0: "); Serial.print(val_0); Serial.print('\t'); Serial.println(val_0 * f, 3);
  Serial.print("\tAnalog1: "); Serial.print(val_1); Serial.print('\t'); Serial.println(val_1 * f, 3);
  Serial.print("\tAnalog2: "); Serial.print(val_2); Serial.print('\t'); Serial.println(val_2 * f, 3);

void LCDroutine(){
  lcd.setCursor(0,0);   //Set cursor to character 2 on line 0
  lcd.setCursor(0,1);   //Set cursor to character 2 on line 0
  lcd.setCursor(0,2);   //Set cursor to character 2 on line 0

This is not ideal since I'm trying to achieve more real-time readings which require simultaneous access to both I2C buses.

I've attempted to access I2C1 using wire1.begin() however this does not work.

Any thoughts?

  • 1
    You could just use a single I2C bus for both sensors. I don't see why you need two I2C buses. If you really want to, You need to have two Wire instances. Like Wire wireADC; and Wire wireOled;.
    – hcheung
    Commented May 3 at 0:08
  • You can't use Wire.begin() and Wire1.begin() to manage two different buses.
    – tepalia
    Commented May 5 at 13:28
  • @tepalia What is your recommendation for managing two separate I2C buses?
    – dave_pp
    Commented May 6 at 20:29
  • The ESP32 has two I2C bus interfaces that can serve as I2C master or slave.This tutorial shows I2C communication protocol with the ESP32 using Arduino IDE: how to choose I2C pins, connect multiple I2C devices to the same bus and how to use the two I2C bus interfaces. randomnerdtutorials.com/esp32-i2c-communication-arduino-ide
    – tepalia
    Commented May 7 at 13:36
  • why not use Wire1already prepared by the library?
    – Juraj
    Commented Jun 9 at 15:13


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.