BME280 sensor problem


#1

Hi there :slight_smile:

I’ve currently a problem reading my BME280 sensor: Sometimes, randomly the sensor starts to send “wrong” values, f.e -140 degrees for temperature. If I press the Reset button my photon, it doesnt solve the issue. Only if I un- and replug the power connection, it’s working again… Does anybody else has this problem? If yes, how did you solve it?

My idea was to reinitiate the sensor if the temperature falls below -50 degress (which will never happen normally in my region xD). I’m using the Adafruit BME280 library. How can I reinitiate the sensor properly?

Best regards


#2

How is connected power to the BMP280? 3v3?
I’ve got the same issue, the only way to solve it was to power the sensor by a pin and powercycle it every time.


#3

I have a few BME280s and have not run into that problem in the few years they’ve been running. They on Photons, connected by I2C with 10K pull-ups. They’re on a custom circuit board, so the traces are short. There’s also a 0.1uF capacitor on the BME280 3V3 connection, right next to the chip. I’d guess you have a power issue that is causing the sensor to crash, essentially, and not respond to I2C/SPI.


#4

I have a BME280, not a BMP280. Power is connected to 3v3 pin. Is there a possibility to reset it by software?


#5

I don’t use any resistors with I2C. Do you mean a power issue in the meaning of a bad connection (soldering) or that the particle doesnt provide enough power for the sensor?


#6

@electronweather, I had similar issues with a Photon that wakes, takes a reading and goes to deep sleep. Because of the low power consumption of the BME280, I ended up powering it via a GPIO pin so it gets powered off in deep sleep. Doing this, I haven’t had ANY reading reliability issues. I use the Adafruit_BME280 library and power up the BME280 and delay 50ms before calling begin() for the device.


#7

So there isn’t any possibility to restart the sensor only by software? I’ve tried it with pressing the RESET button (AFAIK this forces the Photon to restart =re-do the Setup process where bme.begin(); is called but it only works with “hardreset” (unplug power source)


#8

Exactly why I power off a GPIO pin. Otherwise the BME280 is always powered and I found the only way to get it working again was to cycle its power.


#9

Ok, so I will use a GPIO pin. Do you know where I can get a list of the GPIO pins? And could you also post the part of your code which you’re using :slight_smile:


#10

@electronweather, have you tried the online docs? Which Particle device and which BME280 sensor board are you using?


#11

Particle Photon, BME280 from China


#12

@electronweather, here is my code (minus the Blynk stuff I use):

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

  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

  This file was modified by Markus Haack (https://github.com/mhaack)
  in order to work with Particle Photon & Core.
 ***************************************************************************/

#include <Adafruit_BME280.h>

SYSTEM_THREAD(ENABLED);

void startRGB() {
    RGB.control(true);
    RGB.color(0,0,0);
}

STARTUP( startRGB() );


#define BME_SCK D4
#define BME_MISO D3
#define BME_MOSI D2
#define BME_CS D5
#define BME_PWR D3

#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);

double temperature, pressure, altitude, humidity;
char buff[100];
unsigned long wait;


void setup() {
    bool BMEstarted = false;
    
    Serial.begin(9600);

    // If WiFi takes more than 10secs to reconnect, reset and try again
    if (!waitFor(Particle.connected, 10*1000))
        System.reset();
    
    // Power ON the BME280 board
    pinMode(BME_PWR, OUTPUT);
    digitalWrite(BME_PWR, HIGH);
    delay(50);
    
    do {
        if (!bme.begin()) {
            // Cycle power on BME280 board to reset it and try to initialize it again
            digitalWrite(BME_PWR, LOW);
            delay(50);
            digitalWrite(BME_PWR, HIGH);
        }
        else
            BMEstarted = true;
    } while (!BMEstarted);

    wait = millis();
}

void loop() {
    
    // Update data from BME80
    updateData();
 
    while (millis() - wait < 5U*1000U) {     // flush data from Blynk and TCP for 5 secs
        Particle.process();
    }
    
    System.sleep(SLEEP_MODE_DEEP, 30*60);
}

void updateData() {
        temperature = bme.readTemperature();
        pressure = bme.readPressure() / 100.0F;
        altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
        humidity = bme.readHumidity();

        sprintf(buff,"{\"temperature\":%.2f,\"pressure\":%.0f,\"altitude\":%.2f,\"humidity\":%.2f}",temperature, pressure, altitude, humidity);
        Particle.publish("BME280", buff, 60, PRIVATE);
        //Serial.println(buff);
}

#13

Ok, thank you :slight_smile:

Basically I can just check the temperature and when there is not normal value (like -140 degrees) I can set the pin low and high again


#14

@electronweather, or turn it on only when you need to take a reading.


#15

Hi guys,

I’m having the same issue but rewiring our setup to use a GPIO for power is (almost) impossible.
Anyone who actually knows what the underlying problem is? Is it a power issue?

We use the DFrobot version of the BME280 sensor but with the library of Adafruit.
Maybe it’s something in their library?

Thank you for the update.

Kind regards,
Sebastien


#16

Hi Sebastien

The only solution which works for me is powering the sensor off with GPIO. I did not find another solution :frowning:

Best regards

Gabriel


#17

I was never able to find a software-only solution either. It seems the sensor stops responding on the I2C bus and will only work again after its power is cycled.


#18

We just found that the BME280 Bosch datasheet states that CSB and Vddio must be connected! See the ‘notes’ in this screenshot:


But most (if not all?) breakouts (like DFRobot and Adafruit) leave it floating (see https://learn.adafruit.com/adafruit-bme280-humidity-barometric-pressure-temperature-sensor-breakout/downloads)

We are testing it out but this could be the issue which causes it to be unreliable… or am I missing something? :upside_down_face:


#19

We’ve had this problem for almost a year and a half. We typically see that the sensor crashes (the Adafruit does a NaN check in order to check if the sensor crashed). We’ve talked with another company who had same issue, they “hotfix” it by sending the configuration again in order to make it work. However, we’ve been unsuccessful at using BME280 in a robust setup, so we’re switching to standalone sensors for humidity, pressure and temperature with more accuracy.

I’m following this thread in order to finally be able to pinpoint the fault and sleep at night.


#20

@claursen, using the GPIO-as-power method, I have had zero problems with the BME280. When it acts up, I simple reset it.