0

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.

5
  • Did you check the wiring? Commented Dec 5, 2024 at 23:43
  • On Arduino IDE, what Board you selected (Tools->Board) for your configuration? Commented Dec 6, 2024 at 2:37
  • Did you try address 0x77? Commented Dec 6, 2024 at 3:35
  • 1
    if I2CScanner doesn't see the device then why do you show your sketch and its output? Commented Dec 6, 2024 at 7:40
  • I have the same issue. Connected all the relevant pins on my 6 pin BME280. I checked with a multimeter, there is power and variable voltage when measured over the SCL and SDA pins. Tested with 0x76 & 0x77 addresses and I keep getting a ESP_ERR_NOT_FOUND when using i2c_master_probe. I don't know why it's not working... Commented Jan 2 at 22:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.