NEW PROBLEM(edit) Please help, i got problem with rtc DS3231 on my project. there is im using 3 i2c, BH1750,BME280, and RTC DS3231, but there is error says
"Could not find a valid BME280 sensor, check wiring!'"
i have been change the TwoWire(number) and change the define number, but still get stuck on bme280
#define SDA_BME 19
#define SCL_BME 18
#define SDA_BH 17
#define SCL_BH 16
#define SDA_RTC 4
#define SCL_RTC 0
TwoWire I2Cbme = TwoWire(0);
TwoWire I2Cbh = TwoWire(1);
TwoWire I2Crtc = TwoWire(2);
Adafruit_BME280 bme;
BH1750 bh;
RTC_DS3231 rtc;
void cek_i2c() {
Serial.println(F("Sensor test"));
I2Crtc.begin(SDA_RTC, SCL_RTC, 100000);
if (!rtc.begin(&I2Crtc)) {
Serial.println("Could not find a valid RTCDS3231, check wiring!");
Serial.flush();
while (1);
}
I2Cbh.begin(SDA_BH, SCL_BH, 100000);
if (!bh.begin(BH1750::CONTINUOUS_HIGH_RES_MODE, 0x23, &I2Cbh)) {
Serial.println("Could not find a valid BH1750 sensor, check wiring!");
while (1);
}
I2Cbme.begin(SDA_BME, SCL_BME, 100000);
if (!bme.begin(0x76, &I2Cbme)) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
All the sensors can be connected to the same I2C bus.
Can you use "Wire" and nothing else ?
If there is a special reason for a second I2C bus, then you can use "Wire" and "Wire1". They are already created for you. But only if you can explain to us why you need another I2C bus.
The TwoWire object = TwoWire(number); is something from the past, although it is still valid, I think.
Can you give a link to your BME280 ? A link to where you bought it. It might be one of those modules with a voltage regulator that has a voltage drop of 1V. Your BME280 might be running at 2.3V.