Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BME680 stops working #2421

Open
ikomhoog opened this issue Sep 14, 2021 · 22 comments
Open

BME680 stops working #2421

ikomhoog opened this issue Sep 14, 2021 · 22 comments

Comments

@ikomhoog
Copy link

ikomhoog commented Sep 14, 2021

The problem

my BME680 sometimes stops working, the BH1750 that is on the exact same wires keeps working however.
Their pins on these sensors are exact reverse so the wires and sda-scl resistor can sit between the sensors on the breadboard.
The issue is resolved when I unplug the USB and plug it back in to restart the ESP.

Which version of ESPHome has the issue?

2021.8.2

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2021.9.5, but also had this while esphome was running in docker

What platform are you using?

ESP32

Board

nodemcu-32s (it states ESP32-WROOM-32 on the chip)

Component causing the issue

I2C

Example YAML snippet

esphome:
  name: bme680
  platform: ESP32
  board: nodemcu-32s

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: ""

wifi:
  ssid: ""
  password: ""

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Bme680 Fallback Hotspot"
    password: ""

captive_portal:


i2c:
  scl: 33
  sda: 13
  scan: true
  frequency: 100000
  
bme680_bsec:

sensor:
  - platform: bme680_bsec
    temperature:
      name: "BME680 Temperature"
    pressure:
      name: "BME680 Pressure"
    humidity:
      name: "BME680 Humidity"
    iaq:
      name: "BME680 IAQ"
    co2_equivalent:
      name: "BME680 CO2 Equivalent"
    breath_voc_equivalent:
      name: "BME680 Breath VOC Equivalent"

  - platform: bh1750
    name: "BH1750 Illuminance"
    address: 0x23
    measurement_duration: 69
    update_interval: 1s

text_sensor:
  - platform: bme680_bsec
    iaq_accuracy:
      name: "BME680 IAQ Accuracy"

Anything in the logs that might be useful for us?

It just crashed again this morning, this just repeats in the logs:

[12:07:42][D][bh1750.sensor:081]: 'BH1750 Illuminance': Got illuminance=56.7lx
[12:07:42][D][sensor:131]: 'BH1750 Illuminance': Sending state 56.66666 lx with 1 decimals of accuracy
[12:07:43][D][bh1750.sensor:081]: 'BH1750 Illuminance': Got illuminance=55.8lx
[12:07:43][D][sensor:131]: 'BH1750 Illuminance': Sending state 55.83333 lx with 1 decimals of accuracy
[12:07:44][D][bh1750.sensor:081]: 'BH1750 Illuminance': Got illuminance=55.8lx
[12:07:44][D][sensor:131]: 'BH1750 Illuminance': Sending state 55.83333 lx with 1 decimals of accuracy
[12:07:45][W][i2c:070]: Received NACK on transmit of address 0x76
[12:07:45][W][i2c:070]: Received NACK on transmit of address 0x76
[12:07:45][W][i2c:070]: Received NACK on transmit of address 0x76
[12:07:45][W][i2c:070]: Received NACK on transmit of address 0x76
[12:07:45][W][bme680_bsec.sensor:201]: Failed to set sensor settings (BME680 Error Code -2)
[12:07:45][D][bh1750.sensor:081]: 'BH1750 Illuminance': Got illuminance=55.0lx
[12:07:45][D][sensor:131]: 'BH1750 Illuminance': Sending state 55.00000 lx with 1 decimals of accuracy
[12:07:46][D][bh1750.sensor:081]: 'BH1750 Illuminance': Got illuminance=55.0lx
[12:07:46][D][sensor:131]: 'BH1750 Illuminance': Sending state 55.00000 lx with 1 decimals of accuracy
[12:07:47][D][bh1750.sensor:081]: 'BH1750 Illuminance': Got illuminance=55.0lx
[12:07:47][D][sensor:131]: 'BH1750 Illuminance': Sending state 55.00000 lx with 1 decimals of accuracy
[12:07:48][W][i2c:070]: Received NACK on transmit of address 0x76
[12:07:48][W][i2c:070]: Received NACK on transmit of address 0x76
[12:07:48][W][i2c:070]: Received NACK on transmit of address 0x76
[12:07:48][W][i2c:070]: Received NACK on transmit of address 0x76
[12:07:48][W][bme680_bsec.sensor:201]: Failed to set sensor settings (BME680 Error Code -2)

Additional information

Here is my home assistant history graph of the IAQ where you can see the missing pieces:
image

@Warter21
Copy link

Does it work on 0x76 or 0x77?

bme680 default address is 0x76 but for me it works only on 0x77.

Can you check this option?

bme680_bsec:
address: 0x77

@ikomhoog
Copy link
Author

This is not a problem when it boots, it gets recognized fine at boot with address 0x76 but it just stops after some time.

[21:46:11][I][i2c:033]: Scanning i2c bus for active devices...
[21:46:11][I][i2c:040]: Found i2c device at address 0x23
[21:46:12][I][i2c:040]: Found i2c device at address 0x76

The device at 0x23 is the BH1750

The BME680 has address 0x76 when the address pin is connected to GND and when it is connected to VCC it will be 0x77.
I also had the issue that it would only work at 0x77 but that was because I didn't connect the address pin which caused it to float.

Since I connected every pin correctly it works every boot on address 0x76.

@rhaamo
Copy link

rhaamo commented Dec 7, 2021

Having issues with a BME680 since some time too, only getting:

[20:08:49][W][bme680_bsec.sensor:297]: BSEC failed to process signals (BSEC Error Code -2)
[20:08:52][W][bme680_bsec.sensor:297]: BSEC failed to process signals (BSEC Error Code -2)

BME is detected:

[20:08:47][I][i2c.arduino:048]: Scanning i2c bus for active devices...
[20:08:47][I][i2c.arduino:053]: Found i2c device at address 0x76

and using:

i2c:
  sda: 21
  scl: 22
  scan: True
  id: bus_a

bme680_bsec:
  address: 0x76
  iaq_mode: static
  sample_rate: ulp
  state_save_interval: 6h

versions from the logs:

[20:10:50][I][app:099]: ESPHome version 2021.11.4 compiled on Dec  7 2021, 20:08:09
[20:10:50][C][bme680_bsec.sensor:124]: BME680 via BSEC:
[20:10:50][C][bme680_bsec.sensor:129]:   BSEC Version: 1.4.8.0

tried switching it to 0x77 instead of 0x76 and same result

@ikomhoog
Copy link
Author

ikomhoog commented Dec 8, 2021

@rhaamo I forgot this was still an open issue, it's actually solved for me.
Please try my setup to see if that fixes your issue:

This is my current config which works:

i2c:
  scl: 33
  sda: 13
  scan: true
  frequency: 100000
  
bme680_bsec:
 temperature_offset: 4

sensor:
  - platform: bme680_bsec
    temperature:
      name: "BME680 Temperature"
    pressure:
      name: "BME680 Pressure"
    humidity:
      name: "BME680 Humidity"
    iaq:
      name: "BME680 IAQ"
    co2_equivalent:
      name: "BME680 CO2 Equivalent"
    breath_voc_equivalent:
      name: "BME680 Breath VOC Equivalent"

  - platform: bh1750
    name: "BH1750 Illuminance"
    address: 0x23
    measurement_duration: 69
    update_interval: 1s

text_sensor:
  - platform: bme680_bsec
    iaq_accuracy:
      name: "BME680 IAQ Accuracy"

These are my connections:

BME VCC -> ESP 3V3
BME GND -> ESP GND
BME SCL -> ESP G33
BME SDA -> ESP G13
BME SDO -> BME GND
BME CS -> BME VCC
And there is a 10K resistor between the SDA and SCL pins.

I have weird SDA/SCL pins because I was testing and am not changing working pins.

@rhaamo
Copy link

rhaamo commented Dec 8, 2021

just tried to add the frequency part to i2c and nothing better.
I can try changing the pins or adding a 10k res later.

it's weird that it stopped working for no reasons, the thing is just sitting on a shelf and I never touched it since I made it

@rhaamo
Copy link

rhaamo commented Dec 15, 2021

tried 10k, changing pins, then 10k, no success, sensor is detected on i2c bus but that's all.

@ikomhoog
Copy link
Author

have you soldered the pins to it correctly?
I had another sensor that I just tested and gave similar issues when the pins weren't soldered correctly.
After resoldering with quality solder it connected successfully and hasn't failed since.

@lolorc
Copy link

lolorc commented Mar 3, 2022

I also have these issues with 2 bme680. every 2 weeks or so I get the "Failed to set sensor settings (BME680 Error Code -2)" messages for no apparent reason.

after a soft restart of the esp32 => it doesn't detect the bme680.
I have to electrically restart both the esp and the sensor.

I thought I could power the bme680 from an always on gpio so I could electrically restart the bme680 then reboot the esp32, but it doesn't work. it looks like i2c gets started first, the bme680 is not yet powered...

is there a way to programmatically restart i2c ?

I'm looking for a solution as my heater is controlled by a climate component with a bme680 as main sensor :-) (=> heater stops heating or always on when the issue occurs...)

@iankaufmann
Copy link

Chiming in here to say that I am having the same issue.

The BME680 works for about 24 hours, and then it just stops. If you reboot ESPHome, it says "Communication with BME680 failed!" when it comes back up. The only thing that fixes it is to completely unplug the ESP for 10 seconds or so and plug it back in. Then it works for another day.

I have replaced every component involved too... including a 2nd BME680 sensor. I have replaced the breadboard, the ESP8266, all jumper cables, and the sensor itself, with the same result.

I've checked the soldering on both BME sensors, and tried the other suggestions from this thread such as adding the 10k resistor, changing the address, and the other config changes.

I'm in the same boat as @lolorc where I'm using it to regulate a heater and I've had to add a zigbee based sensor as a fallback for when this one stops working. The trouble with that is how slowly it updates vs the BME when it is working.

I am using this integration:
https://esphome.io/components/sensor/bme680.html

Since I have ruled out all components involved, it makes me wonder if this is a software issue. There was a time when it wasn't like this, but it has been doing this for the past several months.

@lolorc
Copy link

lolorc commented Mar 4, 2022

I'm using this one : https://esphome.io/components/sensor/bme680_bsec.html and it's not crashing that often.
I'm going to add a ds18b20 as a fallback. (been using a ble sensor before, but I have issues with ble at the moment #3039)

@lolorc
Copy link

lolorc commented Mar 15, 2022

in the end my "climate" esp32 has sps30, scd30 and one bme680 on its own i2c bus, no need for a 1wire sensor since I already have two temperature sensors(bme680+scd30) but bme680 is still crashing so I'm using sensor templates to workaround the issue:

  • every time the bme680 temperature sensor gets a value I store uptime in a "last seen" template sensor
  - platform: bme680_bsec
    temperature:
      id: "esp32_01_BME680_Temperature"
      name: "esp32_01_BME680_Temperature"
      accuracy_decimals: 5
      on_value:
        then:
          - sensor.template.publish:
              id: esp32_01_bme680_temperature_last
              state: !lambda 'return id(esp32_01_uptime).state;'
  • I also have a template sensor averaging between bme680 temp & scd30 temp when the bme680 sensor is still alive, otherwise it only returns the scd30 temp
  - platform: template
    id: esp32_01_tmplt_01_temperature
    name: esp32_01_tmplt_01_temperature
    update_interval: 5s
    accuracy_decimals: 5
    unit_of_measurement: °C
    lambda: |-
      if ( id(esp32_01_uptime).state - id(esp32_01_bme680_temperature_last).state > 120 ) {
        ESP_LOGI("main", "BME680 SENSOR GONE, temp: %F", id(esp32_01_Workshop_SCD30_Temperature).state);
        return id(esp32_01_Workshop_SCD30_Temperature).state;
      } else {
        return (id(esp32_01_BME680_Temperature).state + id(esp32_01_Workshop_SCD30_Temperature).state)/2;
      }
  • climate uses this template sensor

@martijnbuts
Copy link

martijnbuts commented May 28, 2022

Is there any solution known for this problem? I experience the same problem that the ESP32 loses the BME680.
It sometimes works but not stable.

Does ESPHOME support connecting the BME680 over SPI?
The BME680 itself does support the SPI interface.

[16:13:10][C][i2c.arduino:038]: I2C Bus:
[16:13:10][C][i2c.arduino:039]: SDA Pin: GPIO21
[16:13:10][C][i2c.arduino:040]: SCL Pin: GPIO22
[16:13:10][C][i2c.arduino:041]: Frequency: 50000 Hz
[16:13:10][C][i2c.arduino:044]: Recovery: bus successfully recovered
[16:13:10][I][i2c.arduino:054]: Results from i2c bus scan:
[16:13:10][I][i2c.arduino:060]: Found i2c device at address 0x77
[16:13:10][C][homeassistant.time:010]: Home Assistant Time:
[16:13:10][C][homeassistant.time:011]: Timezone: 'GMT0BST,M3.5.0/1,M10.5.0'
[16:13:10][C][bme680.sensor:209]: BME680:
[16:13:10][C][bme680.sensor:210]: Address: 0x77
[16:13:10][E][bme680.sensor:212]: Communication with BME680 failed!

Problem found, i think to many sensors are connected to the ESP32 3 volt line. By removing the other sensors from the 3 volt line the problem is solved.

update - after +- 18 hours the BME280 works without any problems after removing the sensors from the 3 volt line.

@davewongillies
Copy link

Not sure if this will help anyone, but what fixed it for me was grounding the CS pin of the BME680 to solve this problem even though its configured to communicate with I2C.

@iankaufmann
Copy link

Not sure if this will help anyone, but what fixed it for me was grounding the CS pin of the BME680 to solve this problem even though its configured to communicate with I2C.

Thanks for posting this! I had given up on this sensor, but grounding the CS pin caused it to hold steady for 5 days now.

@thecheatah
Copy link

I wanted to confirm that setting the CS pin to ground fixed the issue. This issue was very helpful in finding the fix.

This issue should be closed.

@orenmazor
Copy link

another confirmation here.

the datasheet for this module also specifies this for SDO, which I did as well (because CS alone did not do it for me):

Screenshot 2023-06-21 at 11 17 51 AM

@robinostlund
Copy link

I also have the same issue, but for me it seems to happen when the humidity goes to high like when it is raining alot. Are your sensors in a climate with high humidity?

@orenmazor
Copy link

I also have the same issue, but for me it seems to happen when the humidity goes to high like when it is raining alot. Are your sensors in a climate with high humidity?

50-70% here

@LordNex
Copy link

LordNex commented Nov 14, 2023

Im having ths same issue. I;ve tried connecting it via SPI and I2C and all come up that no ic2 devices are found and not results are displayed. Im not soldering yet, just running the pin headers into the breadboard and then us individual wires to take care of the connections to the senor. I thought maybe it was a bad sensor so I grabbed a new BME680 and still have the same issue. At thyis point im thinking of trying a different ESP32. No other sensors have been added yet, im just starting this build so everything is basic. Any suggestions?

INFO ESPHome 2023.10.6 INFO Reading configuration /config/esphome/main-area-multisensorv02.yaml... INFO Starting log output from 192.168.10.164 using esphome API INFO Successfully connected to 192.168.10.164 [12:05:37][I][app:102]: ESPHome version 2023.10.6 compiled on Nov 14 2023, 11:48:06 [12:05:37][C][wifi:546]: WiFi: [12:05:37][C][wifi:382]: Local MAC: redacted [12:05:37][C][wifi:383]: SSID: [redacted] [12:05:37][C][wifi:384]: IP Address: 192.168.10.164 [12:05:37][C][wifi:386]: BSSID: [redacted] [12:05:37][C][wifi:387]: Hostname: 'main-area-multisensorv02' [12:05:37][C][wifi:389]: Signal strength: -67 dB ▂▄▆█ [12:05:37][C][wifi:393]: Channel: 11 [12:05:37][C][wifi:394]: Subnet: 255.255.255.0 [12:05:37][C][wifi:395]: Gateway: 192.168.10.1 [12:05:37][C][wifi:396]: DNS1: 192.160.10.250 [12:05:37][C][wifi:397]: DNS2: 192.168.10.1 [12:05:38][C][logger:416]: Logger: [12:05:38][C][logger:417]: Level: DEBUG [12:05:38][C][logger:418]: Log Baud Rate: 115200 [12:05:38][C][logger:420]: Hardware UART: UART0 [12:05:38][C][i2c.arduino:053]: I2C Bus: [12:05:38][C][i2c.arduino:054]: SDA Pin: GPIO21 [12:05:38][C][i2c.arduino:055]: SCL Pin: GPIO22 [12:05:38][C][i2c.arduino:056]: Frequency: 50000 Hz [12:05:38][C][i2c.arduino:059]: Recovery: bus successfully recovered [12:05:38][I][i2c.arduino:069]: Results from i2c bus scan: [12:05:38][I][i2c.arduino:071]: Found no i2c devices! [12:05:38][C][bme680_bsec.sensor:132]: bme680_bsec_bme680bseccomponent via BSEC: [12:05:38][C][bme680_bsec.sensor:137]: BSEC Version: 1.4.8.0 [12:05:38][C][bme680_bsec.sensor:139]: Address: 0x76 [12:05:38][E][bme680_bsec.sensor:143]: Communication failed (BSEC Status: 0, BME680 Status: -2) [12:05:38][C][bme680_bsec.sensor:146]: Temperature Offset: 0.00 [12:05:38][C][bme680_bsec.sensor:147]: IAQ Mode: Static [12:05:38][C][bme680_bsec.sensor:148]: Sample Rate: LP [12:05:38][C][bme680_bsec.sensor:149]: State Save Interval: 21600000ms [12:05:38][C][bme680_bsec.sensor:151]: Temperature 'BME680 Temperature' [12:05:38][C][bme680_bsec.sensor:151]: Device Class: 'temperature' [12:05:38][C][bme680_bsec.sensor:151]: State Class: 'measurement' [12:05:38][C][bme680_bsec.sensor:151]: Unit of Measurement: '°C' [12:05:38][C][bme680_bsec.sensor:151]: Accuracy Decimals: 1 [12:05:38][C][bme680_bsec.sensor:152]: Sample Rate: Default [12:05:38][C][bme680_bsec.sensor:153]: Pressure 'BME680 Pressure' [12:05:38][C][bme680_bsec.sensor:153]: Device Class: 'atmospheric_pressure' [12:05:38][C][bme680_bsec.sensor:153]: State Class: 'measurement' [12:05:38][C][bme680_bsec.sensor:153]: Unit of Measurement: 'hPa' [12:05:38][C][bme680_bsec.sensor:153]: Accuracy Decimals: 1 [12:05:38][C][bme680_bsec.sensor:154]: Sample Rate: Default [12:05:38][C][bme680_bsec.sensor:155]: Humidity 'BME680 Humidity' [12:05:38][C][bme680_bsec.sensor:155]: Device Class: 'humidity' [12:05:38][C][bme680_bsec.sensor:155]: State Class: 'measurement' [12:05:38][C][bme680_bsec.sensor:155]: Unit of Measurement: '%' [12:05:38][C][bme680_bsec.sensor:155]: Accuracy Decimals: 1 [12:05:38][C][bme680_bsec.sensor:156]: Sample Rate: Default [12:05:38][C][bme680_bsec.sensor:158]: IAQ 'BME680 IAQ' [12:05:38][C][bme680_bsec.sensor:158]: State Class: 'measurement' [12:05:38][C][bme680_bsec.sensor:158]: Unit of Measurement: 'IAQ' [12:05:38][C][bme680_bsec.sensor:158]: Accuracy Decimals: 0 [12:05:38][C][bme680_bsec.sensor:158]: Icon: 'mdi:gauge' [12:05:38][C][bme680_bsec.sensor:160]: IAQ Accuracy 'BME680 IAQ Accuracy' [12:05:38][C][bme680_bsec.sensor:160]: Icon: 'mdi:checkbox-marked-circle-outline' [12:05:38][C][bme680_bsec.sensor:161]: CO2 Equivalent 'BME680 CO2 Equivalent' [12:05:38][C][bme680_bsec.sensor:161]: Device Class: 'carbon_dioxide' [12:05:38][C][bme680_bsec.sensor:161]: State Class: 'measurement' [12:05:38][C][bme680_bsec.sensor:161]: Unit of Measurement: 'ppm' [12:05:38][C][bme680_bsec.sensor:161]: Accuracy Decimals: 1 [12:05:38][C][bme680_bsec.sensor:162]: Breath VOC Equivalent 'BME680 Breath VOC Equivalent' [12:05:38][C][bme680_bsec.sensor:162]: Device Class: 'volatile_organic_compounds_parts' [12:05:38][C][bme680_bsec.sensor:162]: State Class: 'measurement' [12:05:38][C][bme680_bsec.sensor:162]: Unit of Measurement: 'ppm' [12:05:38][C][bme680_bsec.sensor:162]: Accuracy Decimals: 1 [12:05:38][C][captive_portal:088]: Captive Portal: [12:05:38][C][mdns:115]: mDNS: [12:05:38][C][mdns:116]: Hostname: main-area-multisensorv02 [12:05:38][C][ota:097]: Over-The-Air Updates: [12:05:38][C][ota:098]: Address: 192.168.10.164:3232 [12:05:38][C][ota:101]: Using Password. [12:05:38][C][api:139]: API Server: [12:05:38][C][api:140]: Address: 192.168.10.164:6053 [12:05:38][C][api:142]: Using noise encryption: YES [12:05:38][C][wifi_info:009]: WifiInfo IPAddress 'bme01 IP Address'

@robinostlund
Copy link

I also have issues, for me though the issue is that bme680 is changing the address from 0x76 to 0x77 and vise versa after a couple of days, sometimes it is working for months.

@sokarovski
Copy link

Hey there, thanks to this issue and all the comments in it grounding the CS pin helped me solve my problem.

Long story:
For me, this problem only started happening after I added a 6m cable to the I2C bus. I knew that this was a bad idea/practice as I2C is not designed for such a thing. My goal was to have my heating system working on a single ESP32 so it wouldn't be dependent on HA and reading values from other sensors via HA. In case of HA failure i would have I2C display and physical button to control everything. Note that using a short 10-20cm line, I don't have this problem.

I tried changing the speed to 10kHz and 5kHz, but that did NOT fix the problem.

Inspired by @lolorc, I also added an AHT21 as a backup which does work a lot more stable. Since then i decided to use it as main sensor and use the BME as backup.

It would be nice though if the BME680 component at least reported NaN if the reading is not successful so we can setup HA automations/notifications.

@mastersf
Copy link

grounding the pin hasn't worked for me. Anyone else seeing major inconsistency with this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests