I am pretty sure that code below was working a year ago, but now it does not. I tried it on several different ESP32-C3 with BME280 connected via I2C. My guess is that there was some update in library/Arduino IDE and I cant find a way to run it succesfully:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
// Define I2C pins for ESP32-C3-12F
#define I2C_SDA 19
#define I2C_SCL 18
Adafruit_BME280 bme; // I2C
void setup() {
// Initialize Serial Monitor
Serial.begin(115200);
delay(100); // Let the Serial Monitor settle
// Initialize I2C communication with custom SDA and SCL pins
Wire.begin(I2C_SDA, I2C_SCL);
// Initialize BME280 sensor
if (!bme.begin(0x76)) { // Try 0x76 or 0x77 depending on your sensor address
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
void loop() {
// Read values from BME280 sensor
float temperature = bme.readTemperature();
float humidity = bme.readHumidity();
float pressure = bme.readPressure() / 100.0F;
// Display the values on the Serial Monitor
Serial.println("Temperature: " + String(temperature) + " °C");
Serial.println("Humidity: " + String(humidity) + " %");
Serial.println("Pressure: " + String(pressure) + " hPa");
Serial.println("-------------------------");
// Wait for a while before reading again
delay(2000); // Delay in milliseconds
}
respond is:
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x1058
load:0x403cc710,len:0x8a8
load:0x403ce710,len:0x2fac
entry 0x403cc710
*wm:AutoConnect
*wm:Connecting to SAVED AP: OPS
*wm:connectTimeout not set, ESP waitForConnectResult...
*wm:AutoConnect: SUCCESS
*wm:STA IP Address: 192.168.88.24
Could not find a valid BME280 sensor, check wiring!
I tried to run generic I2C finder, nothing found. Tried on 3 different ESPs and BME280s.