BME280 providing inaccurate data

I have a BME280 pressure, temperature and humidity sensor connected to a ESP32-C3 Super Mini. It all works fine except that the reported values for barometric pressure, temperature and humidity are a long way off the real values.

Here is the YAML that I have:

esphome:
  name: barometer
  friendly_name: Barometer

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf

logger:

api:
  encryption:
    key: "key"

ota:
  - platform: esphome
    password: "password"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: "Barometer Fallback Hotspot"
    password: "PASSWORD"

captive_portal:

i2c:
  sda: GPIO8
  scl: GPIO9
  scan: false  

sensor:
  - platform: bme280_i2c
    address: 0x76

    pressure:
      name: "Outside Pressure"
      filters:
        - offset: +9.6

    temperature:
      name: "Outside Temperature"
      id: air_temperature
      filters:
        - offset: -3.5

    humidity:
      name: "Outside Humidity"
      id: relative_humidity
      filters:
        - offset: +12.9

  - platform: dew_point
    name: "Dew point"
    temperature: air_temperature
    humidity: relative_humidity

  - platform: absolute_humidity
    name: "Absolute Humidity"
    temperature: air_temperature
    humidity: relative_humidity

  - platform: wifi_signal 
    name: "WiFi RSSI"
    id: wifi_signal_db
    entity_category: "diagnostic"

I am using this as a component of a weather station, so it is located outside the house.

To get anything like the real values, I have had to adjust the pressure up by 9.6, the temperature down by 3.5 and the humidity up by 12.9.

This suggests to me that the calibration values that are stored in EPROM on the BME280 are not being used by the ESPHome code. Is there anyway that I can check if the calibration values are being applied?

If esphome was not using calibration, I believe no-one here would have usable readings.

Is your sensor inside enclosure? Self heating or too close to Esp? If you power off the sensor for 10 minutes, how are the first readings after re-powering?
You might have fake sensor or one that did not pass the calibration on factory.
Try with some arduino sketch to get proof that esphome is the problem.

First question is what are you calibrating it against and is that device correct. How do you know it is correct?

Second I I have to correct all my temp and humidity devices when connected to an esp.

What do you compare your results with (Especially air pressure)? Did you buy sensor on aliexpress or similar? If so, there's your reason... i have several of such sensors, and i only managed to "keep things under control" when i bought decent ones for 10 times the money...
Humidity will always be off by a few percents, that's normal.

Temperature: keep yor sensor well away from esp (at least 10-20cm, and try NOT to have it in the same enclosur as esp, if possible) - esp heats up and causes wrong readings if sensor is too close.

Air pressure: note that all weather stations publish relative air pressure, not absolute. I don't see relative air presure in your yaml ?

And, just a note about relative air pressure: the formula on the esphome's page "BME280 environment" is wrong, because it has temperature in equation. Temperature is already taken into account internally when absolute pressure is calculated, so it has no place in the formula. I did report this several times, but noone seem to cares, so i gave up and used the correct one:

lambda: |-
  const float STANDARD_ALTITUDE = 315; // in meters, see note
  return (id(absolute_pressure).state)/powf((1-((float)(STANDARD_ALTITUDE))/44330), 5.255);

That's the relative air pressure bit.

At 20cm from sensor to ESP would you use a twisted pair?


Who hasn't had some fun trying to get one of these to give an accurate temp?

I found this to have been my initial thoughts.

Aha... ok, it looks "funny", but ... ok.

Nope... i have several and the longest one is even on 4-5m long cable. Ok, cable is "alarm type" (2x0.5+4-0.22mm2) - so it has shield (connected to GND), and works perfectly.

Haha... how true back then when i've had a bunch of Aliexpress sensors... not two of them showed same values. Now i use mainly BLE models from Xiaomi and some Shelly's for temperature and humidity. They are all accurate to one decimal. For pressure i have a couple of original BME's, though.


I use BMP for pressure and keep them indoor. They seem to have good precision. Accuracy harder to say. Above the blue line sensor is about 6m above lower sensor. Either way it looks like the weather is improving for the weekend.

originals or aliexpress ones? (it's 5 vs 15€)
(i guess if used only for pressure it is a good idea to keep them indoors.. you have the point here)

All this is pointless unless you have a calibrated temperature humidity and air pressure gauges to compare them to. If you don't have these at hand you are just guessing.

A temp sensor you bought, even from a reputable supplier is no guarantee of accuracy. Even putting a sensor 20cm from a calibrated sensor could easily show a difference.

What I am trying to say is stop over thinking it, it's really only going to be a bit out and not worth worrying about :slight_smile:

Cheap ones of aliexpress. I gave up using them outside as I was using deep sleep and after a few months they would stop reading and I would have to power cycle them. Inside awake all the time they have worked well. I calibate their temperature against my Xiaomi Ble

That's true. However i guess that "best second" is: i bought 6 of BLE Xiaomi's and i've had them on the same place (very close to each other) for a month or so, and they were all accurate to max. one decimal. I'd say that's "good enough" for amateur... without any reference.... statistically there's very little chance that 6 of them would lie exactly the same...

Honestly: i replaced most of my BME's with BLE models mostly for convenience: they are battery powered so i can place them just about anywhere without drawing that wires...
I printed stevenson screens for them and i converted them from CR2032 to 2x1.5V for better battery life.
Not long ago added two Shelly's ( Shelly BLU H&T) to my "collection".

Totally I have 5 sensors arranged at different locations around my house - at least one of them is always in the shade - not in the sun (yeah, i know... i'm a bit of a freak... can't help it... :laughing:). A template sensor then shows the one with lowest temperature on my dashboard.

Yeah, as said, these xiaomi's are quite accurate, agreed.

I too have many temp sensors around my house, garden and outbuildings. Of various different types. They are all calibrated against one device. They all work well and consistently. But I have no idea the temp is correct to 2 decimal places.

In the end to be practical I just had to pick a device and use that as reference.

Yes, that, and comparing your (outside) temperatures with official ones over time. If they are consistently too high or too low it's time for (re)calibration.

I don't think any digital temp sensor could be off 3.5deg according to specs if mounted properly. So either it's recovered from trash bean or it's installed improperly. Or verified against sensor that is one of those mentioned.

If you look at the specs of the DHT11/12 you'll see they are +/- 2°C. My experiments with them showed me this. I applied an offset and found that it was an addition +/- 2°C depending on actual temperature. Even with a slope and an offset, I never could get two to agree. So, yes, these devices can by off by 4°C!

The picture showed an ESP-01 with a DHT11. The heat dissipation from the ESP8266 increases the temperature reading by 5°F!

I looked for a NIST traceable WiFi thermometer ... US$150 to 200!

Either or, not both...

Thanks for all the comments and suggestions - I have now fixed the inaccuracy issue ... :grin:

Initially I thought that the BMP280 and the BME280 sensor PCBs I had were fakes. But the testing I did suggested that was highly unlikely.

Then I thought that ESPHome wasn't applying the calibration correction factors correctly. That also seemed unlikely, but I could not prove it, hence this posting.

It turns out that the "inaccuracy" was due to 2 errors on my part:

  1. I was using the atmospheric pressure value from our local weather bureau as my reference, forgetting that the value is at mean sea level. My house is about 75 m above sea level, so my reading should be about 9 hPa lower than the weather bureau figure. Issue fixed.

  2. The BME280 PCB was located adjacent to the ESP32 PCB, both mounted on some strip-board. I measured the surface temperature of the ESP32 chip and it was about 10 deg C above ambient and was "warming" the BME280 sensor, which was just 10mm away. I then removed the BME280 from the strip-board and connected the BME280 to the ESP32 via a 200 mm length of 4-core cable and voila, the temperature and humidity readings returned to "normal".

Building a weather station from scratch turns out to be more complicated than I had imagined ...

Are the files for the 3D print available somewhere ??

But if you are comparing one with another, one may be -2, the other +2, therefore 4.