TwoWire rtcDS3231 on ESP32

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);
  }

}

Read this discussion:

Seems to be a few #include missing...no???

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.

Connect one sensor at a time. Check its functionality and then put all three together. This is called SSS (Small Start Strategy) Strategy.

Are you using the following modules:
image
Fig-1: DS3231 RTC Module

image

Sketch that works with my ESP32:

#include <Wire.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp280;

void setup()
{
  Serial.begin(9600);
  Serial.println("Initializing BMP280");
  boolean status = bmp280.begin(0x76);
  if (!status) 
  {
    Serial.println("Not connected");
  }
}

void loop()
{
  float temp = bmp280.readTemperature();
  Serial.println("Temperature:");
  Serial.println(temp);
  delay(1000);
}

Figure-2: BME280 PTH Sensor

image
Figure-3: Light Sensor

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.