Go Down

Topic: BME280 can't be found, but I2C-Scanner recognises it (Read 189 times) previous topic - next topic


Jul 19, 2019, 08:43 pm Last Edit: Jul 19, 2019, 08:44 pm by itssimsch
Hello there,
I've got a problem with my BME280.
When I try to run the example code for it, I constantly get the error message, that no valid BME280 Sensor was found, no matter what I2C adress I tried (0x77, 0x76). However, when I run a I2C Scanner, the sensor is recognised.
Code: [Select]
  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() {
    while(!Serial);    // time to get serial running
    Serial.println(F("BME280 test"));

    unsigned status;
    // default settings
    // (you can also pass in a Wire library object like &Wire2)
    status = bme.begin(0x76); 
    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);
    Serial.println("-- Default Test --");
    delayTime = 1000;


void loop() {

void printValues() {
    Serial.print("Temperature = ");
    Serial.println(" *C");

    Serial.print("Pressure = ");

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

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

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


Code: [Select]
BME280 test
Could not find a valid BME280 sensor, check wiring, address, sensor ID!
SensorID was: 0xFF
        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085
   ID of 0x56-0x58 represents a BMP 280,
        ID of 0x60 represents a BME 280.
        ID of 0x61 represents a BME 680.

I2C Scanner code:
Code: [Select]
// --------------------------------------
// i2c_scanner
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    https://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
#include <Wire.h>
void setup()
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
void loop()
  byte error, address;
  int nDevices;
  nDevices = 0;
  for(address = 1; address < 127; address++ )
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    error = Wire.endTransmission();
    if (error == 0)
      Serial.print("I2C device found at address 0x");
      if (address<16)
      Serial.println("  !");
    else if (error==4)
      Serial.print("Unknown error at address 0x");
      if (address<16)
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  delay(5000);           // wait 5 seconds for next scan

I2C scanner output:
Code: [Select]

I2C Scanner
I2C device found at address 0x76  !

I'm using an Ardunio Mega 2560
VIN  <----> 3.3V
GND <----> GND
SCL  <----> 21/SCL
SDA  <----> 20/SDA

Thank you in advance


As the output says...
ID of 0xFF probably means a bad address, a BMP 180 or BMP 085
maybe you have a BMP180.
Try a BMP180 library example to see if it works.
Don't PM me for help as I will ignore it.


Unfortunately, that didn't work either. I also tried a BMP280 and a different BME280 library.


Jul 20, 2019, 10:15 am Last Edit: Jul 20, 2019, 07:00 pm by GolamMostafa
I2C scanner finds the sensor -- a fact that establishes that the sensor has been connected with the I2C Bus of Arduino; but, your codes indicate that you are trying to operate the sensor using SPI-based sketch.

Are you using this BME280 Module? If not, post a picture.


Jul 20, 2019, 01:11 pm Last Edit: Jul 20, 2019, 01:40 pm by itssimsch
Yes, I am using the one shown in the image.


This will most likely answer all your questions

you need to use the Hookup Diagram for Adafruit BME280 breakout board using I2C examples since youare using the i2c version of the sensor....




Jul 20, 2019, 06:17 pm Last Edit: Jul 20, 2019, 06:26 pm by WattsThat Reason: Added model number of board
The BME280 module pictured in post #3 is a 5 volt module. Connecting it to a 3.3 volt source will result in erratic behavior, it should be powered by the 5V pin of the Arduino.

GYBMEP schematic:

Vacuum tube guy in a solid state world


Thank you all very much,
the cactus.io library works for me.

Go Up