Communication with BME680 failed - Can't get I2C devices connected to Nodemcu with ESPHome

Tags: #<Tag:0x00007f7390d0cbf8> #<Tag:0x00007f7390d0ca68>

Hey there,

I am rather a noob in the world of home assistant and home automation, I’m going along and thoroughly enjoying learning, but I have encountered something that seems to be beyond my coding google-fu abilities and I just can’t find the solution, I’m hoping some kind person could help me crack this one.

I am running a nodemcuv2.
I have carefully connected a bme680 sensor, making sure to connect all the pins according the the info on the esphome website.

I have uploaded the following code to the nodemcu:

esphome:
  name: esp8266_1
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "my_wifi"
  password: "my_wifi_password"
  manual_ip:
    static_ip: 192.168.1.40
    gateway: 192.168.1.1
    subnet: 255.255.255.0
    dns1: 192.168.1.1
    dns2: 192.168.1.1

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

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "password"

ota:
  password: "password"
    
# i2c  
i2c:
  sda: GPIO4
  scl: GPIO5
  scan: True
  id: bme_680

# bme680 sensor
sensor:
  - platform: bme680
    i2c_id: bme_680
    address: 0x76
    temperature:
      name: "BME680 Temperature"
      oversampling: 16x
    pressure:
      name: "BME680 Pressure"
    humidity:
      name: "BME680 Humidity"
    gas_resistance:
      name: "BME680 Gas Resistance"
    update_interval: 30s

and this is the result:

[03:24:32][C][i2c:028]: I2C Bus:
[03:24:32][C][i2c:029]:   SDA Pin: GPIO4
[03:24:32][C][i2c:030]:   SCL Pin: GPIO5
[03:24:32][C][i2c:031]:   Frequency: 50000 Hz
[03:24:32][I][i2c:033]: Scanning i2c bus for active devices...
[03:24:32][I][i2c:049]: Found no i2c devices!
[03:24:32][C][logger:175]: Logger:
[03:24:32][C][logger:176]:   Level: DEBUG
[03:24:32][C][logger:177]:   Log Baud Rate: 115200
[03:24:32][C][logger:178]:   Hardware UART: UART0
[03:24:32][C][bme680.sensor:208]: BME680:
[03:24:32][C][bme680.sensor:209]:   Address: 0x76
[03:24:32][E][bme680.sensor:211]: Communication with BME680 failed!
[03:24:32][C][bme680.sensor:213]:   IIR Filter: OFF
[03:24:32][C][bme680.sensor:214]:   Update Interval: 60.0s
[03:24:32][C][bme680.sensor:216]:   Temperature 'BME680 Temperature'
[03:24:32][C][bme680.sensor:216]:     Unit of Measurement: '°C'
[03:24:32][C][bme680.sensor:216]:     Accuracy Decimals: 1
[03:24:32][C][bme680.sensor:216]:     Icon: 'mdi:thermometer'
[03:24:32][C][bme680.sensor:217]:     Oversampling: 16x
[03:24:32][C][bme680.sensor:218]:   Pressure 'BME680 Pressure'
[03:24:32][C][bme680.sensor:218]:     Unit of Measurement: 'hPa'
[03:24:32][C][bme680.sensor:218]:     Accuracy Decimals: 1
[03:24:32][C][bme680.sensor:218]:     Icon: 'mdi:gauge'
[03:24:32][C][bme680.sensor:219]:     Oversampling: 16x
[03:24:32][C][bme680.sensor:220]:   Humidity 'BME680 Humidity'
[03:24:32](Message skipped because it was too big to fit in TCP buffer - This is only cosmetic)
[03:24:32](Message skipped because it was too big to fit in TCP buffer - This is only cosmetic)
[03:24:33][C][bme680.sensor:220]:     Icon: 'mdi:water-percent'
[03:24:33][C][bme680.sensor:221]:     Oversampling: 16x
[03:24:33][C][bme680.sensor:222]:   Gas Resistance 'BME680 Gas Resistance'
[03:24:33][C][bme680.sensor:222]:     Unit of Measurement: 'Ω'
[03:24:33][C][bme680.sensor:222]:     Accuracy Decimals: 1
[03:24:33][C][bme680.sensor:222]:     Icon: 'mdi:gas-cylinder'
[03:24:33][C][bme680.sensor:226]:   Heater temperature=320°C duration=150ms

I always get this error: Communication with BME680 failed!

I have tried the addresses 0x77 and 0x76 as recommended in the documentation, as well as a few other addresses that the logs show found an i2c device at different times, but can not get any readings or successful communication with the BME680, and I just can’t figure out how to get this running.

Does anyone see anything I don’t that might be causing the problem?
Your help in solving this is so hugely appreciated.

And you are absolutely sure that you connected the sensor to GPIO4/GPIO5 as configured, and not accidentally to D4/D5?

1 Like

FYI:

Yeah, I am sure, I have double checked that a bunch of times, I even tried switching them just incase my sensor was mislabelled or something but no luck.
I know the picture isn’t the clearest, but I attached it just to show I’m pretty sure I’ve connected it up correctly.

1 Like

Appreciate that, very helpful, these are the pins that I am using to connect.

Yeah that looks ok. I think. Hard to tell because of the angle.

Are you running the BME from 5V or 3.3v (should be 3.3)?

You could try specifying D1 and D2 instead of GPIO4,5. Though I doubt that’s it.

Are you sure you have the board type correct?

Solder the header pins on the BME board for a reliable connection.

Some of these boards are dual SPI/I2C and require things like jumpering CS to VCC and SDO to GND to force to I2C mode. Do you have the data sheet for this one, are you certain it’s not running in SPI mode?

And yes - what @tom_l said, solder those pins.

Can I say at this point, thank you all so much for taking the time to help.

I have soldered the pins on the BME680, good idea!

I tried specifying D1 and D2 instead of GPIO 4,5. Sadly, it didn’t change the outcome.

The board, good question. I live in China so my access to cheap electronics is awesome, however, it’s not always so totally 100% clear you’ve got what you wanted.
I bought something that was advertised as a risym nodemcu ESP8266.
I did notice that in my code I had the board as “nodemcuv2” so I changed it to “nodemcu” but the result is the same.

I also tried not specifying the pins for i2c and specifying completely other pins for i2c but nothing has worked.

I also connected a different i2c device, and I am having the same problem, so it seems my issue is not with the BME680 but with the wiring to my nodemcu.

I bet I am just making some rookie mistake, I really want to make this work, but I just can’t figure it out.

Thank you so much for taking time to help me further with this.

My thoughts are:

  • Maybe I am still specifying the wring board type in my code
  • Maybe this particular nodemcu that I have bought uses different pins for i2c communication

I have looked into that possibility, as far as I can tell that isn’t the case.
The exact sensor I have is this one: https://www.amazon.com/Ultra-Small-Pressure-CJMCU-680-Temperature-Humidity/dp/B07ZZWJTWH
Maybe you have experience with it and know something more than me, if so I would love to learn from you.

I’m guessing this. Got a link to the place you purchased it?

I purchased it on an app called taobao.
Link is this:
https://detail.tmall.com/item.htm?spm=a230r.1.14.40.50eb191akHSbKY&id=535588732894&ns=1&abbucket=9

I’m trying to understand all the different boards and models, there’s a lot to take in, so maybe I have got this part wrong, with time I’ll get better, but now I’m struggling.
Again, thank you so much for helping a noobie out.

Looks like you had the correct board.

  platform: ESP8266
  board: nodemcuv2

Oh no, I was kind of really hoping that was the problem.
Now I’m back to no idea what’s going on or how to fix it.
Any ideas of things I could try to get this working?
Any help is really appreciated.

Definitely 3.3v using 3.3v and G pins form my nodemcu.

I know it is a long shot but I was having lots of trouble with sensors running ESPHome 1.14.3 and .4, and I switched to 1.15dev.

I also notice 1.14.5 is out which I will give a try later.

I just updated to 1.14.5 and uploaded my code to the nodemcu again but I got the same result.
Let me know how your experience goes.
If 1.14.5 doesn’t work for you either with sensors, I’ll look at switching to the dev version.
Thanks for the tip.

I was thinking maybe a picture of my nodemcu board might help.
Perhaps some eagle eyed person might spot something that could help.

IMG_6667

I have what looks like an identical board running a BMP280 and a microwave motion sensor. I did use GPIO0 as SDA but that shouldn’t make a difference. This is normally bad practice but I converted this from a ESP01 with limited pins to a NodeMCU board and was obviously too lazy to fix it when I rebuilt…

The code is below if you want to compare.

esphome:
  name: mancave
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "MYSSID"
  password: "my password"

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

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

i2c:
  sda: GPIO0
  scl: GPIO2
  scan: false
  id: bus_a
  
sensor:
  - platform: bmp280
    temperature:
      name: "Man Cave Temperature"
      oversampling: 16x
    pressure:
      name: "Man Cave Air Pressure"
    address: 0x76
    update_interval: 60s
    
binary_sensor:
  - platform: gpio
    pin:  GPIO5
    name: "Man Cave Motion"
    device_class: motion

I was out of ideas so I ordered a new bme680.
I swapped it out with the old one, and it immediately worked perfectly.
Either I had a bad board or I somehow messed it up.
Won’t be the last time I try to get readings from a bad board…
Anyway, wanted to pop back in with that info and thank everyone for taking the time to help.

3 Likes