# BME280 sensor problem

**URL:** <https://community.particle.io/t/bme280-sensor-problem/49627>\
**Category:** Troubleshooting\
**Created:** [May 8, 2019, 1:06pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627 "2019-05-08T13:06:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [May 8, 2019, 1:06pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/1 "2019-05-08T13:06:31Z")

</div>

Hi there 🙂

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

---

<div class="post-metadata">

**Author:** ![not103](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@not103](https://community.particle.io/u/not103)\
**Post date:** [May 8, 2019, 1:34pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/2 "2019-05-08T13:34:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)\
**Post date:** [May 8, 2019, 1:53pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/3 "2019-05-08T13:53:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [May 8, 2019, 2:10pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/4 "2019-05-08T14:10:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [May 8, 2019, 2:11pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/5 "2019-05-08T14:11:36Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [May 8, 2019, 2:11pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/6 "2019-05-08T14:11:52Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [May 8, 2019, 2:26pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/7 "2019-05-08T14:26:45Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [May 8, 2019, 2:41pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/8 "2019-05-08T14:41:39Z")

</div>

> [@electronweather](#):
>
> but it only works with “hardreset” (unplug power source)

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.

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [May 8, 2019, 2:45pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/9 "2019-05-08T14:45:04Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [May 8, 2019, 2:50pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/10 "2019-05-08T14:50:32Z")

</div>

@electronweather, have you tried the [online docs](https://docs.particle.io/)? Which Particle device and which BME280 sensor board are you using?

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [May 8, 2019, 2:52pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/11 "2019-05-08T14:52:15Z")

</div>

Particle Photon, BME280 from China

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [May 8, 2019, 3:56pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/12 "2019-05-08T15:56:22Z")

</div>

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

```auto
/ ***************************************************************************
  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);
}

```

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [May 8, 2019, 6:17pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/13 "2019-05-08T18:17:22Z")

</div>

Ok, thank you 🙂

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

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [May 8, 2019, 7:15pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/14 "2019-05-08T19:15:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Pheatus](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/pheatus/32/19800_2.png) [@Pheatus](https://community.particle.io/u/Pheatus)\
**Post date:** [October 24, 2019, 9:05am UTC](https://community.particle.io/t/bme280-sensor-problem/49627/15 "2019-10-24T09:05:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [October 29, 2019, 5:11pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/16 "2019-10-29T17:11:12Z")

</div>

Hi Sebastien

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

Best regards

Gabriel

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [October 29, 2019, 5:21pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/17 "2019-10-29T17:21:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Pheatus](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/pheatus/32/19800_2.png) [@Pheatus](https://community.particle.io/u/Pheatus)\
**Post date:** [November 6, 2019, 3:36pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/18 "2019-11-06T15:36:08Z")

</div>

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

 ![Annotation%202019-11-06%20162710](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/4/d/4dd1151e36daca3905bbf484c2a7ae0e50092663.jpeg)  
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](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? 🙃

---

<div class="post-metadata">

**Author:** ![claursen](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@claursen](https://community.particle.io/u/claursen)\
**Post date:** [November 11, 2019, 1:10pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/19 "2019-11-11T13:10:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [November 11, 2019, 4:56pm UTC](https://community.particle.io/t/bme280-sensor-problem/49627/20 "2019-11-11T16:56:58Z")

</div>

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

[Next page](https://community.particle.io/t/bme280-sensor-problem/49627.md?page=2)
