Odd high or low readings

Hi, has anyone got any ideas on how I can overcome sporadic high or low readings in temperature output.
Im using ESPhome with a BME680.

At first I was getting these spikes in readings every day until I added a couple of 4k7ohm pullup resistors one on the sda and another on the scl lines, I thought that had stopped it, but after testing for longer it had only reduced the frequency from every day to around once or twice a week.

My code is:

esphome:
  name: thermostat-lounge
  platform: ESP32
  board: esp32doit-devkit-v1

wifi:
  ssid: "ssid"
  password: "password"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

i2c:
  sda: 21
  scl: 22

# Individual sensors

sensor:
  - platform: bme680
    temperature:
      name: "L Temperature"
      id: l_temperature
    pressure:
      name: "L Pressure"
      id: l_pressure
    humidity:
      name: "L Humidity"
      id: l_humidity
    gas_resistance:
      name: "L Gas Resistance"
      id: l_gas

It seems that these spikes hit the same point each time i.e. if its a positive spike it will go to around 200°C until the next reading, if its negative it will go to around -50°C until the next reading when it will return to normal.
The other readings are effected too but at present I’m only monitoring the temperature.

I have swopped over the BME680 but that didn’t help so feel the only way to go now is with some sort of ‘if then’ statement, something like if reading is higher or lower than a set amount than false an update? Not sure if that can be done in ESPhome.

Open to suggestions.

A filter is the obvious solution, but there isn’t one that covers this specifically. You could write it in a lambda filter.

I have one but use the BSEC version. Idk if it would make a difference. I’ve also had noise on that sensor but had quite a few other components with the same behavior.

That problem was solved by adding a capacitor, is this the only sensor on the board? If yes a cap won’t help. The other time I had a problem on an i2c line it was the length of the wire.

A little over 3 meters is the recommended max for i2c. If there are other sensors on the i2c bus the lengths of each wire is cumulative. I over came the distance problem by using an i2c extender.

Might be worth a try.

The sensor is the only one on the i2c bus and is connected via 2 meters of cable, this was when the interference was really bad until I added the 4k7’s as I mentioned above helped.

The 4.7Kohms have been added to the sensor, I could remove them and add them to the esp board instead.

Have today changed the resistors over from the sensor end bus lines to the esp end bus lines to see how things go.

Hi!

did you have any success?

I’m having the same problem as you

thanks!