Arduino BME280 – Could not find a valid BME280 sensor – SOLVED

Hi, if you facing the same problem as me :

BME280 test
Could not find a valid BME280 sensor, check wiring!

I found a solution for this problem.

  1. First, check your BME280 address by this sketch 
    1. if your address is 0x77 you do not have to change anything
    2. if your address is different change your library
      1. open library file Adafruit_BME280.h – normally is saved at C:\Users\USERinfo\Documents\Arduino\libraries\Adafruit_BME280_Library-master
      2. find  #define BME280_ADDRESS (0x76) and change to your scanned address
  2. If you still have the same problem open file Adafruit_BME280.cpp – normally is saved at C:\Users\info\Documents\Arduino\libraries\Adafruit_BME280_Library-master
    1. find
      if (read8(BME280_REGISTER_CHIPID) != 0x60)
          return false;
    2. change to
      if (read8(BME280_REGISTER_CHIPID) != 0x60)
          //return false;

      EDIT: if you just comment the return false; statement, there should be problem with compilation because the if statement is in one-line statement type(there are missing curly brackets). So you got two options.

      1) change the if statement, adds curly brackets so it should look like this :
      if (read8 (BME280_REGISTER_CHIPID)! = 0x60)  {
      //return false;
      2) just delete the whole if statement with the return value. That if just check if the chip came from adafruit production.

Problem is because adafruit library check CHIPID and your chipid is different than what adafruit sell.