BME280 I2C won't work

Hello everyone,

just as in this post: https://forum.arduino.cc/index.php?topic=575571.0
I don’t seem to get my BLE280 working I2C. I wired VIN to 5V, GND to GND, SCL to A5 and SDA to A4 of my arduino uno and used the following code:

#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(0x76);
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();
}

When I use the I2C Scanner I receive the same address 0x76. However, inserting bme.begin(0x76) doesn’t seem to help. Can anybody give me any suggestions?

If you post your code as described in the Read this before posting a programming question, more people will read it.

“Won’t work” is not a very useful description of your problem. Try again using a complete sentence.

Let me guess, you are getting the same values all the time?

Hello everyone,

just as in this post: https://forum.arduino.cc/index.php?topic=575571.0
I don’t seem to get my BLE280 working I2C. I wired VIN to 5V, GND to GND, SCL to A5 and SDA to A4 of my arduino uno and used the following code:

#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(0x76);
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();
}

When I use the I2C Scanner I receive the same address 0x76. However, inserting bme.begin(0x76) doesn’t seem to help. Can anybody give me any suggestions?

Thank you . You are right. I think I should have made it more clear within the title.

I gave it a new try within a new post.

I have executed your posted sketch unchanged. The following (Fig-1) is the response of my 5V_I2C_BME280 Module (bme280P2.jpg.
smnb.png).
Figure-1:

smnb.png

bme280P2.jpg

Post a link to where you got the exact module that you are using.

The first thing that I do when I have trouble with an I2C device is to run an I2C scanner to confirm the I2C address and communication with the bus.

// I2C scanner by Nick Gammon.  Thanks Nick.

#include <Wire.h>

void setup() {
  Serial.begin (115200); //*****  make sure serial monitor baud matches *****

  // Leonardo: wait for serial port to connect
  while (!Serial) 
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 1; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

What is the output in serial monitor?

First: Edit your post and insert code tags!

When I use the I2C Scanner I receive the same address 0x76. However, inserting bme.begin(0x76) doesn't seem to help.

Does mean? What output do you get if you run that code?

What exact hardware are you using (I doubt you use the chip directly)? Post a link to the board's schematics!

How long are the wires between the Arduino and the sensor board?

Duplicate topics merged ?

Why did you start a second one ?

What is the output in serial monitor?

@groundFungus: I used your code which you already had posted within another chat. I receive the address 0x76. However, when inserting it into the begin() method I keep on getting the following error/message:

14:22:26.768 → BME280 test
14:22:26.768 → Could not find a valid BME280 sensor, check wiring!

My Wiring is the following:

VCC → 3.3V
GND → GND
SCL → A1
SDA → A5

On an UNO SDA=A4 and SCL=A5.

Thank you for your response but I still keep on getting the same error message.
I changed the wiring though....

The BME280 is a 3.3V device. Some modules have hardware on board to make them useful at 5V, some do not. If you apply 5V to 3.3V device, you will kill it. That is why we have asked (more than once) which exact module that you have.

The BME280 is a 3.3V device. Some modules have hardware on board to make them useful at 5V, some do not. If you apply 5V to 3.3V device, you will kill it. That is why we have asked (more than once) which exact module that you have

I applied 3.3V to the device. Sorry for replying so late...
The module I applied is the shown by GolamMostafa. However, I cannot remember where I bought it.

I tried the same on another module - same issue.

This is the exact module I bought. Sorry I noticed above I wrote 5V. To sum it up: For the new module I applied
VCC -> 3.3 V
GND -> GND
SCL -> A5
SDA -> A4

Okey problem solved. Probably a lose cable... :o :confused:

Thank you for your effort :slight_smile:

I had the same problem, with the same module, but using a Teensy 3.2 instead of an Arduino. I noticed that the problem started when I updated the Adafruit_BME280 library to the 2.1.0 version, because was working fine with the 1.1.0 version, so I just simply did a downgrade to that version, and voila! problem solved. I don't know why that happened but as long as it works I'm sticking to the 1.1.0 version.

are you sure you have the correct I2C address?
I ran an I2C scan and found

I2C scanner. Scanning ...
 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x3A 0x3B 0x3C 0x3D 0x3E 0x3F 0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5A 0x5B 0x5C 0x5D 0x5E 0x5F 0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6A 0x6B 0x6C 0x6D 0x6E 0x6F 0x70 0x71 0x72 0x73 0x74 0x75 0x76
Found address: 118 (0x76)
 0x77Done.
Found 1 device(s).

looking in Adafruit_BMP280.h I found

#define BMP280_ADDRESS (0x77) /**< The default I2C address for the sensor. */

running Examples> Adafruit BMP280 Library > bmp280test I changed

void setup() {
  Serial.begin(115200);
  Serial.println(F("BMP280 test"));
  if (!bme.begin(0x76)) {     //  <<<<  CHANGED from 0x77
    Serial.println("Could not find a valid BMP280 sensor, check wiring!");
    while (1);
  }
}

a run then gives

BMP280 test
Temperature = 24.08 *C
Pressure = 101478.22 Pa
Approx altitude = -12.75 m

Temperature = 24.25 *C
Pressure = 101479.55 Pa
Approx altitude = -12.86 m

Temperature = 24.27 *C
Pressure = 101474.50 Pa
Approx altitude = -12.44 m

I am running on an Arduino Due as the Bosch BMP280 states maximum Vdd is 4.25V (similar at interface pin) - the Due is a 3.3V device