BME280 found in I2C scanner but not working

I would like some help on my simple project: i wanted to test a BME280 sensor i got from Aliexpress. I verified that the chip is a BME280 and not a BMP280.

The problem is that I can find the sensor when running an I2C scan, but using the example sketch i get the error message: ```
"Could not find a valid BME280 sensor, check wiring!"

The tutorial i am following is here: ESP32 with BME280 using Arduino IDE (Pressure, Temperature, Humidity) | Random Nerd Tutorials
The sensor I have and the ESP board are the same, and i checked every connection, even with a multimeter.

As you can see from the image i uploaded, the scanner finds the sensor ad the address 0x76, but when running the example scketch i get the error.

I have also tried both 3.3V and 5V to power the breakout (instructions from aliexpress page state that it is a 5V board) and there seems to be a voltage regulator on the backside

Any help is appreciated, thanks!

Please don't post images of code or serial monitor.

Post the complete code, in code tags.

Post the serial monitor output, in more code tags.

Also post details of how you installed any necessary libraries (library manager, download zip file etc) so that others can reproduce your problem.

Then maybe someone will test your code for you with their components to see if they get same result.

1 Like

@PaulRB thanks! code (as mentioned it is the example code from the Adafuit library):

/***************************************************************************
  This is a library for the BME280 humidity, temperature & pressure sensor

  Designed specifically to work with the Adafruit BME280 Breakout
  ----> http://www.adafruit.com/products/2650

  These sensors use I2C or SPI to communicate, 2 or 4 pins are required
  to interface. The device's I2C address is either 0x76 or 0x77.

  Adafruit invests time and resources providing this open source code,
  please support Adafruit andopen-source hardware by purchasing products
  from Adafruit!

  Written by Limor Fried & Kevin Townsend for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
  See the LICENSE file for details.
 ***************************************************************************/

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI

unsigned long delayTime;

void setup() {
    Serial.begin(9600);
    while(!Serial);    // time to get serial running
    Serial.println(F("BME280 test"));

    unsigned status;
    
    // default settings
    status = bme.begin();  
    // You can also pass in a Wire library object like &Wire2
    // status = bme.begin(0x76, &Wire2)
    if (!status) {
        Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
        Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16);
        Serial.print("        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
        Serial.print("   ID of 0x56-0x58 represents a BMP 280,\n");
        Serial.print("        ID of 0x60 represents a BME 280.\n");
        Serial.print("        ID of 0x61 represents a BME 680.\n");
        while (1) delay(10);
    }
    
    Serial.println("-- Default Test --");
    delayTime = 1000;

    Serial.println();
}


void loop() { 
    printValues();
    delay(delayTime);
}


void printValues() {
    Serial.print("Temperature = ");
    Serial.print(bme.readTemperature());
    Serial.println(" °C");

    Serial.print("Pressure = ");

    Serial.print(bme.readPressure() / 100.0F);
    Serial.println(" hPa");

    Serial.print("Approx. Altitude = ");
    Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
    Serial.println(" m");

    Serial.print("Humidity = ");
    Serial.print(bme.readHumidity());
    Serial.println(" %");

    Serial.println();
}

which only gets me this error:

BME280 test

20:56:59.055 -> Could not find a valid BME280 sensor, check wiring, address, sensor ID!

20:56:59.119 -> SensorID was: 0x0

20:56:59.151 -> ID of 0xFF probably means a bad address, a BMP 180 or BMP 085

20:56:59.215 -> ID of 0x56-0x58 represents a BMP 280,

20:56:59.247 -> ID of 0x60 represents a BME 280.

20:56:59.311 -> ID of 0x61 represents a BME 680.

Ln 90, Col 2

ALKS ESP32

on COM15

2

the library was installed with the Arduino IDE library manager.

1 Like

btw these are the pictures of the sensor

i have checked online and it seems that the BMP280 has a rectangular sensor, while the BME280 is squared, and so is the one i have.

also this is the configuration i am tryng right now with the I2C address scanner:

and what i get from the console is:

21:26:03.759 -> Scanning...

21:26:03.759 -> I2C device found at address 0x3C

21:26:03.821 -> I2C device found at address 0x76

21:26:03.821 -> done

so it sees correctly the display at 0x3c and the sensor at 0x76. Which should mean that at least the electrical connections are working

i have also tested the same connection without the display and I've changed my ESP32 board for another one, and also tried changing the default I2C pins but i always get the same result: device found by scanner but not recognised from library

Hi! Welcome to the Forum!

Considering that you've already tested the connections and showed the I2C found at 0x76, the only suggestion I have is related to the sensor initialization. Try this version of the code:

/***************************************************************************
  This is a library for the BME280 humidity, temperature & pressure sensor

  Designed specifically to work with the Adafruit BME280 Breakout
  ----> http://www.adafruit.com/products/2650

  These sensors use I2C or SPI to communicate, 2 or 4 pins are required
  to interface. The device's I2C address is either 0x76 or 0x77.

  Adafruit invests time and resources providing this open source code,
  please support Adafruit andopen-source hardware by purchasing products
  from Adafruit!

  Written by Limor Fried & Kevin Townsend for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
  See the LICENSE file for details.
 ***************************************************************************/

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI

unsigned long delayTime;

void setup() {
    Serial.begin(9600);
    while(!Serial);    // time to get serial running
    Serial.println(F("BME280 test"));

    unsigned status;
    
    // default settings
    status = bme.begin(0x76);    //<--changed this line
    // You can also pass in a Wire library object like &Wire2
    // status = bme.begin(0x76, &Wire2)
    if (!status) {
        Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
        Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16);
        Serial.print("        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
        Serial.print("   ID of 0x56-0x58 represents a BMP 280,\n");
        Serial.print("        ID of 0x60 represents a BME 280.\n");
        Serial.print("        ID of 0x61 represents a BME 680.\n");
        while (1) delay(10);
    }
    
    Serial.println("-- Default Test --");
    delayTime = 1000;

    Serial.println();
}


void loop() { 
    printValues();
    delay(delayTime);
}


void printValues() {
    Serial.print("Temperature = ");
    Serial.print(bme.readTemperature());
    Serial.println(" °C");

    Serial.print("Pressure = ");

    Serial.print(bme.readPressure() / 100.0F);
    Serial.println(" hPa");

    Serial.print("Approx. Altitude = ");
    Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
    Serial.println(" m");

    Serial.print("Humidity = ");
    Serial.print(bme.readHumidity());
    Serial.println(" %");

    Serial.println();
}
1 Like

@Brazilino thanks! yeah Sorry i forgot to mention that I have also tried changing the initialization as you kindly mentioned, in fact you can see in the first image that I posted (with which I learned that is not ideal to screenshot code) that the code already had that change (the begin with the 0x76 address). I'm starting to think the chip is broken, maybe the soldering process killed it, don't know. I just find it weird that the scanner finds it.

I am open to other suggestions if anybody has ideas, thanks

1 Like

I have 2 BME280 sensors and I remember having some trouble as well. I'm using the exact same sensors as in your picture btw.

Currently they are working, I'm using:


#include <Bme280.h>

Bme280TwoWire bme1;
Bme280TwoWire bme2;

// in setup:
bme1.begin(Bme280TwoWireAddress::Primary);
bme2.begin(Bme280TwoWireAddress::Secondary);

I ended up with this library for my Arduino Giga, the other one didn't work. Hope this helps!

1 Like

Either damaged, or counterfeit.

1 Like

If no-one else has tested your code with their hardware by tomorrow evening, I'll test it for you.

If the code works for others, that would seem to indicate you have a faulty sensor.

1 Like

Thank you so much @arneko ! This solved the problem! I installed this library and the example code worked instantly, i was near to throwing it in the trash :sweat_smile:.

the code i tested is:

#include <Arduino.h>
#include <Bme280.h>

Bme280TwoWire sensor;

void setup() {
  Serial.begin(9600);
  Wire.begin(21, 22);

  Serial.println();

  sensor.begin(Bme280TwoWireAddress::Primary);
  sensor.setSettings(Bme280Settings::indoor());
}

void loop() {
  auto temperature = String(sensor.getTemperature()) + " °C";
  auto pressure = String(sensor.getPressure() / 100.0) + " hPa";
  auto humidity = String(sensor.getHumidity()) + " %";

  String measurements = temperature + ", " + pressure + ", " + humidity;
  Serial.println(measurements);

  delay(10000);
}

and i finally get this
10:16:25.306 -> 25.48 °C, 1010.58 hPa, 58.68 %

Connection:
3.3V -> Vin
GND -> GND
21 -> SDA
22 -> SCL

board: ESP WROOM 32

1 Like