BME280 I2C won't work

Hey,

I can’t get my BME280 sensor working. It is I2C only. I wired VIN to 5V, GND to GND, SCL to A5 and SDA to A4 of my arduino uno.

I used the following sketch, in the Serial Monitor I get: “Could not find a valid BME280 sensor, check wiring!”. Does anyone know what’s wrong?

/***************************************************************************
  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
 ***************************************************************************/

#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);
    Serial.println(F("BME280 test"));

    bool status;
    
    // default settings
    // (you can also pass in a Wire library object like &Wire2)
    status = bme.begin();  
    if (!status) {
        Serial.println("Could not find a valid BME280 sensor, check wiring!");
        while (1);
    }
    
    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();
}

Link to your sensor? (The ones I know support either SPI or I2C interface. Also the the default address is 0x77 if SDO not connected to ground, otherwise it’s 0x76 and you need to let the library know)

—> use an I2C scanner code to see if the module is seen on the bus

It's this one:

I2C Scanner says:

I2C Scanner
Scanning...
I2C device found at address 0x76 !
done

phytopia:
I2C Scanner says:

I2C Scanner
Scanning...
I2C device found at address 0x76 !
done

Now replace the bool status = bme.begin(); with bool status = bme.begin(0x76); and it should work.

That did it, thanks!

cool :slight_smile:

phytopia:
That did it, thanks!

Glad you got it working okay.
Is it me or does there seem to be a spike of BME280 problems on here in the last few weeks?