Hi,
I have a project where I need DS3231 and two BME280. My code is as follows. I get message "Couldn't find RTC". Any ideas what is wrong? When I test only RTC with Arduino example codes, it works well, so the problem is assumed to be in code with BME's.
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include "RTClib.h"
Adafruit_BME280 bme;
#define SDA_1 27
#define SCL_1 26
#define SDA_2 13
#define SCL_2 14
TwoWire I2Cone = TwoWire(0);
TwoWire I2Ctwo = TwoWire(1);
Adafruit_BME280 bme1;
Adafruit_BME280 bme2;
RTC_DS3231 rtc;
void setup() {
Serial.begin(115200);
delay(500);
Serial.println(F("BME280 and Ds3231 test"));
delay(1000);
I2Cone.begin(SDA_1, SCL_1, 100000);
I2Ctwo.begin(SDA_2, SCL_2, 100000);
Wire.begin();
delay(1000);
bool status1 = bme1.begin(0x76, &I2Cone);
if (!status1) {
Serial.println("Could not find a valid BME280_1 sensor, check wiring!");
digitalWrite(32, HIGH);
return;
} else {
Serial.println("BME1 sensor found");
digitalWrite(32, LOW);
}
bool status2 = bme2.begin(0x76, &I2Ctwo);
if (!status2) {
Serial.println("Could not find a valid BME280_2 sensor, check wiring!");
digitalWrite(32, HIGH);
return;
} else {
Serial.println("BME2 sensor found");
digitalWrite(32, LOW);
}
if (!rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
while (1) delay(10);
}
else {
Serial.println("RTC found");
}
delay(2000);
}
void loop() {
}
