Qwiic micro pressure sensors Address Problem with ESP32.

Hello , I am new to ESP32 . I am facing issue with qwiic micro pressure sensor address.

I am following " SparkFun Qwiic MicroPressure Hookup Guide". when I want to get the pressure reading from one sensor. it works properly. when I connected the second sensor and update the code for double sensors. it didnt give me readings on serial monitor. I tried it to change the address of sensor with it also not working. I tried it with same address change the pins but it also not working. I am sharing the code which I am using with ESP32 DEVKITV1. Your help will be appriciated.thank you an adavance.

#include <Wire.h>

#include <SparkFun_MicroPressure.h>

// Define pins for I2C communication for sensor 1

#define SDA_PIN1 21

#define SCL_PIN1 22

// Define pins for I2C communication for sensor 2

#define SDA_PIN2 19

#define SCL_PIN2 18

// Create TwoWire instances for each I2C bus

TwoWire I2C1 = TwoWire(0);

TwoWire I2C2 = TwoWire(1);

// Initialize the MicroPressure sensors with different I2C addresses

SparkFun_MicroPressure mpr1;

SparkFun_MicroPressure mpr2;

#define LOOP_TIME 1000

unsigned long timer;

void setup() {

Serial.begin(115200); // Start the serial port for debugging

// Initialize I2C for the first sensor

I2C1.begin(SDA_PIN1, SCL_PIN1);

// Initialize the first micropressure sensor

if (!mpr1.begin(0x18, I2C1)) { // Assuming 0x18 is the address for sensor 1

Serial.println(“Cannot connect to MicroPressure sensor 1.”);

while (1);

}

// Initialize I2C for the second sensor

I2C2.begin(SDA_PIN2, SCL_PIN2);

// Initialize the second micropressure sensor

if (!mpr2.begin(0x18, I2C2)) { // Assuming 0x18 is the address for sensor 2

Serial.println(“Cannot connect to MicroPressure sensor 2.”);

while (1);

}

}

void loop() {

if ((millis() - timer) > LOOP_TIME) {

readPressureValues();

timer = millis();

}

}

void readPressureValues() {

// Read the pressure values from each sensor

float pressurePsi1 = mpr1.readPressure(); // Pressure in PSI for sensor 1

float pressurePa1 = mpr1.readPressure¶; // Pressure in Pascals for sensor 1

float pressureKpa1 = mpr1.readPressure(KPA); // Pressure in Kilopascals for sensor 1

float pressureTorr1 = mpr1.readPressure(TORR); // Pressure in Torr for sensor 1

float pressureInHg1 = mpr1.readPressure(INHG); // Pressure in Inches of Mercury for sensor 1

float pressureAtm1 = mpr1.readPressure(ATM); // Pressure in Atmospheres for sensor 1

float pressureBar1 = mpr1.readPressure(BAR); // Pressure in Bar for sensor 1

float pressurePsi2 = mpr2.readPressure(); // Pressure in PSI for sensor 2

float pressurePa2 = mpr2.readPressure¶; // Pressure in Pascals for sensor 2

float pressureKpa2 = mpr2.readPressure(KPA); // Pressure in Kilopascals for sensor 2

float pressureTorr2 = mpr2.readPressure(TORR); // Pressure in Torr for sensor 2

float pressureInHg2 = mpr2.readPressure(INHG); // Pressure in Inches of Mercury for sensor 2

float pressureAtm2 = mpr2.readPressure(ATM); // Pressure in Atmospheres for sensor 2

float pressureBar2 = mpr2.readPressure(BAR); // Pressure in Bar for sensor 2

// Convert pressure from Pascals to millibar (1 Pa = 0.01 mbar)

float pressureMbar1 = pressurePa1 * 0.01; // Pressure in millibar for sensor 1

float pressureMbar2 = pressurePa2 * 0.01; // Pressure in millibar for sensor 2

// Print the pressure values to the serial monitor for each sensor

Serial.println(“Sensor 1:”);

Serial.print("Pressure: ");

Serial.print(pressurePsi1, 4);

Serial.println(" PSI");

Serial.print(pressurePa1, 1);

Serial.println(" Pa");

Serial.print(pressureKpa1, 4);

Serial.println(" kPa");

Serial.print(pressureTorr1, 3);

Serial.println(" torr");

Serial.print(pressureInHg1, 4);

Serial.println(" inHg");

Serial.print(pressureAtm1, 6);

Serial.println(" atm");

Serial.print(pressureBar1, 6);

Serial.println(" bar");

Serial.print(pressureMbar1, 2);

Serial.println(" mbar");

Serial.println();

Serial.println(“Sensor 2:”);

Serial.print("Pressure: ");

Serial.print(pressurePsi2, 4);

Serial.println(" PSI");

Serial.print(pressurePa2, 1);

Serial.println(" Pa");

Serial.print(pressureKpa2, 4);

Serial.println(" kPa");

Serial.print(pressureTorr2, 3);

Serial.println(" torr");

Serial.print(pressureInHg2, 4);

Serial.println(" inHg");

Serial.print(pressureAtm2, 6);

Serial.println(" atm");

Serial.print(pressureBar2, 6);

Serial.println(" bar");

Serial.print(pressureMbar2, 2);

Serial.println(" mbar");

Serial.println();

}

To confirm the addresses and ensure no address conflicts, run an I2C scanner sketch.