[SOLVED] Could not find a valid BME280 sensor, check wiring!

This is a troubleshooting guide for the BME280 temperature, humidity, and pressure sensor when using ESP32, ESP8266, Arduino, or similar boards.

If you get an error message in your Serial Monitor when trying to initialize the BME280 sensor, go through the following steps to understand what might be causing the issue and how to fix it.

BME280 Sensor Troubleshooting Could not find a valid BME280 sensor check wiring

If you get the following error Could not find a valid BME280 sensor, check wiring! when trying to initialize the BME280 sensor, it might be one of the following issues:

1. Check Wiring

BME280 sensor modules are available in different formats—with 4 pins and with 6 pins.

4-pin model BME280

The models with 4 pins only allow I2C communication protocol like the module shown in the picture below.

BME280 module 4 pin

You must wire the SDA and SCL pins to your microcontrollers’ I2C pins. The following table shows the default I2C pins for the ESP32, ESP8266, and Arduino Uno boards:

BME280ESP32ESP8266Arduino Uno
SCLGPIO 22GPIO 5 (D1)*A5
SDAGPIO 21GPIO 4 (D2)*A4

* in most ESP8266 development boards, GPIO 5 is labeled on the board as D1 and GPIO 4 as D2. For more information check the ESP8266 pinout guide.

Besides the I2C pins, you should connect the VIN pin (also labeled VCC on some modules) to 3.3V and GND to the microcontroller’s GND pin.

6-pin model BME280

There are models with 6 pins that support both I2C and SPI communication protocol.

BME280 module 6 pin

If you want to use I2C communication protocol with these models, you need to wire the sensor’s I2C pins to your microcontroller’s I2C pins. In this case, the SDI label corresponds to the SDA pin and the SCK to the SCL pin.

BME280ESP32ESP8266Arduino Uno
SCL (SCK)GPIO 22GPIO 5 (D1)*A5
SDA (SDI)GPIO 21GPIO 4 (D2)*A4

Besides the I2C pins, you should connect the VIN pin (also labeled VCC on some modules) to 3.3V and GND to the microcontroller’s GND pin.

If you want to use SPI communication protocol, you need to connect the sensor’s SPI pins to your microcontroller’s SPI pins. The following table shows the connection to the default SPI pins.

BME280ESP32ESP8266Arduino Uno
SCK (SPI Clock)GPIO 18GPIO 14 (D5)Pin 13
SDO (MISO)GPIO 19GPIO 12 (D6)Pin 12
SDI (MOSI)GPIO 23GPIO 13 (D7)Pin 11
CS (Chip Select)GPIO 5GPIO 15 (D8)Pin 10

Besides the I2C pins, you should connect the VIN pin (also labeled VCC on some modules) to 3.3V and GND to the microcontroller’s GND pin.

2. Check I2C Address

If you’re using I2C communication protocol, and your board can’t find the BME280 sensor, it might be the case that you’re not using the correct I2C address. Usually, the BME280 I2C sensor is 0x76, but it might be different. So, we recommend running an I2C scanner sketch to find the sensor’s I2C address.

/*********
  Rui Santos
  Complete project details at https://randomnerdtutorials.com  
*********/

#include <Wire.h>
 
void setup() {
  Wire.begin();
  Serial.begin(115200);
  Serial.println("\nI2C Scanner");
}
 
void loop() {
  byte error, address;
  int nDevices;
  Serial.println("Scanning...");
  nDevices = 0;
  for(address = 1; address < 127; address++ ) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0) {
      Serial.print("I2C device found at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
      nDevices++;
    }
    else if (error==4) {
      Serial.print("Unknow error at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0) {
    Serial.println("No I2C devices found\n");
  }
  else {
    Serial.println("done\n");
  }
  delay(5000);          
}

View raw code

After getting the I2C sensor address, make sure you use the right address in your code. For example, in most of our projects, we use the Adafruit BME280 library. In that case, we must pass the address to the begin() method as follows:

bme.begin(YOUR_SENSOR_I2C_ADDRESS)

If the I2C scanner sketch returns 0x76 or any other address and you still can’t get it working, go to issue 4.

3. Broken/fried Sensor

If your microcontroller can’t find the sensor’s I2C address and you’re sure the wiring is correct, you probably have a hardware problem:

  • your sensor might be broken;
  • faulty wires;
  • insufficient power supply;

We recommend checking all the wiring again.

4. Fake BME280 Sensor (BMP280)

Some vendors sell BMP280 sensor modules as BME280. It is very difficult to tell the difference between them when buying because they are very similar. BME280 sensors are usually more expensive than BMP280 sensors. The downside of having a BMP280 is that it doesn’t measure humidity, it only measures temperature and pressure.

How to tell if you got a BMP280 sensor? In the following picture, you can see that the BME280 sensor chip is square-shaped, while the BMP280 is more like a rectangle shape.

BMP280 vs BME280

To be sure that you have a BMP280 sensor, you can install a library compatible with the BMP280 sensor and run an example sketch.

I usually recommend installing the Adafruit BMP280 library and running the bmp280test sketch that you can find here.

You can use the sketch straight away if you’re using I2C communication protocol, or if you want to use SPI, you need to modify the sketch to use the right SPI pins.

If you got it working with the BMP280 test sketch, it means you have a BMP280 and not a BME280.

Wrapping Up

In this article, we’ve described the most common issues that might cause the “Could not find a valid BME280 sensor, check wiring!” error when using a BME280 sensor with the ESP32, ESP8266, Arduino, or other development boards.

We hope you were able to solve your issue with our tips.

We have many BME280 sensor guides that you might find useful:

Thanks for reading.



Build Web Server projects with the ESP32 and ESP8266 boards to control outputs and monitor sensors remotely. Learn HTML, CSS, JavaScript and client-server communication protocols DOWNLOAD »

Build Web Server projects with the ESP32 and ESP8266 boards to control outputs and monitor sensors remotely. Learn HTML, CSS, JavaScript and client-server communication protocols DOWNLOAD »


Enjoyed this project? Stay updated by subscribing our newsletter!

13 thoughts on “[SOLVED] Could not find a valid BME280 sensor, check wiring!”

  1. Very timely Sara, I have several of these things lying around that I couldn’t get to work. Perhaps now I can make use of them 🙂 thanks.

    Reply
  2. I remember when I first tried this sensor and the BME280 it was all a bit confusing what with the clones having what looked like a dual description but once you figure that out and can identify which one you have there is still going to be a problem which I’d say Adafruit have created purposely and you can’t really blame them for as if you’re using their library you should use their sensor.

    Anyway, most of us don’t and all you need to remember is the Adafruit versions will use 0x77 as the I2C default address but the clones use 0x76. So if you have a clone just open the libraries header file and a few line down is the “#define BMP280_ADDRESS (0x77) ” & “#define BMP280_ADDRESS_ALT \ (0x76)”. Just swap these address’s round and problem is solved. Remember to also do this after the libraries have been updated also (chased my tail on that a few times).

    Cheers

    Reply
  3. As I vaguely recall, there is another issue with the internal control on some of the clone BME280’s and the Adafruit library doesn’t access these controls properly regardless of the I2C address. I have experienced this issue in the past. There is an alternative library called cactus.io and that has worked perfectly for me with all BME280 devices I have tested.
    The alternative library is a very good option to add to the BME device check tool kit. Personally once I have checked the wiring I run the I2C scanner. In fact I put the code into a routine that I can load in all my projects that use multiple I2C devices. I then call that routine to test I2C communication and then disable it once the devices are all recognised.

    Reply
  4. Hi,
    In i2c specs, a 4k7 ohms on the data lines are mandatory.
    Does it mean that these resistors are embedded in the PCB sensor?
    Cheers

    Reply
  5. The Adafruit BME280 library is rather inefficient. When it calls the humidity or pressure, it first makes a call to the temperature. This call in fact returns all 3 values, but only one is selected.
    So if you need al 3 values, you need to make 3 calls, where only one call would be sufficient.

    Reply
  6. Recommend alternative BME280 library; BME280 by Tyler Glenn, it does dew point and heat index calculations and more, plus it allows calibration.

    “Ensure your pressure sensor or barometer readings are correct by using a METAR station, these are highly accurate weather stations provided for aircraft altimeter adjustments. There are 1000’s around the world for nearly all known locations.” –G6EJD – David

    G6EJD – David BME29- calibration video: https://www.youtube.com/embed/Wq-Kb7D8eQ4

    Reply

Leave a Reply to William Lucid Cancel reply

Download our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.