[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.



Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »
Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »

Recommended Resources

Build a Home Automation System from Scratch » With Raspberry Pi, ESP8266, Arduino, and Node-RED.

Home Automation using ESP8266 eBook and video course » Build IoT and home automation projects.

Arduino Step-by-Step Projects » Build 25 Arduino projects with our course, even with no prior experience!

What to Read Next…


Enjoyed this project? Stay updated by subscribing our newsletter!

24 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
    • Alternatively, you can connect SD0 to Gnd to flip the device address to 0x77.
      I can get my devices to work perfectly on ESP8266 but not on ESP32.
      Wiring is OK, double checked with a CRO!
      I will investigate other libraries, mentioned further down this page.

      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
  7. Be warned. I received a batch of these sensors and have been banging my head trying to figure out why this simple little board does NOT work.
    I took a closer look and found that the sensor chip is soldered backwards. The manufacturer of this board is sloppy. Sometimes you get what you pay for.

    Reply
    • I think I’m facing the same problem, judging by the date it might even be the same batch haha. I ordered two BMP280 sensors from a chinese supplier on aliexpress and i’ve spent 2 days trying to make them work but they don’t even show up in the i2c scanner. Looking at my sensors and the ones online, I think they might indeed have been soldered backwards…
      I’m almost sure it is also backwards in the shop page, you can clearly see that the pin soldered to the i2c address selector is 1-GND (the one next to the vent hole) instead of 5-SDO (the opposite pin), which according to the datasheet must be pulled down to ground or to vcc to select the last I2C address bit.

      Reply
  8. Hi,
    I can’t get the version to run.
    When compiling, various error messages come up. What am I doing wrong?
    Can you help a (beginner) a little further?
    Thanks!

    Excerpt from error messages:
    C:\Users\Florian\Documents\Arduino\I2C_scanner\I2C_Scanner.ino:129:31: note: in expansion of macro ‘HDC10xx_Device_ID’
    uint16_t chip_id = Read16(HDC10xx_Device_ID, address); // get chip ID
    ^~~~~~~~~~~~~~~~~
    I2C_Scanner:129:14: error: unused variable ‘chip_id’ [-Werror=unused-variable]
    uint16_t chip_id = Read16(HDC10xx_Device_ID, address); // get chip ID
    ^~~~~~~
    cc1plus.exe: some warnings being treated as errors
    Bibliothek Wire in Version 2.0.0 im Ordner: C:\Users\Florian\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.4\libraries\Wire wird verwendet
    exit status 1
    unused variable ‘chip_id’ [-Werror=unused-variable]

    Reply
  9. I got caught out with the fake BME280. It was a BMP280 clearly marked as a BME280.
    If the AdafruitBME280 library is used, the sketch will NOT find a BMP280, whereas some of the other BMP280 libraries will.
    In the ESP32 gauges sketch changing to the BMP280 library , the fake BME280(BMP280) was found OK.

    Reply
  10. I have found that some bmp 280 boards do not have the required 4k7 pullup resistors on board. Particularly ones from AZ-Delivery! I have a couple of these and wondered why they worked with a raspberry pi pico dev board and not my ESP32 boards. It turned out the pico board had the built in pull ups.

    Reply
  11. I found I had a problem getting reliable humidity readings (Kept returning 82%). It turned out the fix for me was to lower the I2C bus speed . Originally I had it set to 400K, I dropped it to 20K and things worked normally. I was connecting to a Pico W and using micropython.

    i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=20000)

    Cheers David

    Reply
  12. I have used the solution provided by Ralph McCleery above, meaning editing the “Adafruit_BMP280.h” file in order to twist the (0x77) and (0x76) addresses, and it worls perfectly !

    If someone could test other(s) librairy(ies) that would work without any modification, it would be simpler in case we use different sensors (originals and clones) with the same program…

    Amongst the possible alternatives to the “Adafruit_BMP280” library, I have been told that the “cactus.io” and the “Sparkfun” (it works with a BME280, but does it work with a BMP280 ??) have a better reputation than the Adafruit_BMP280.

    Thank for sharing,
    Michel

    Reply

Leave a Reply to David 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.