Calibrating sensor output value

Hey everyone,

Firstly, I’m new to HA so you’ll have to bear with me, but here’s my situation: I have an incubator that I’m trying to put a DHT22 in so I can see the temp/humidity on my HA dashboard. I am using an ESP32 with ESPhome. I have done everything to the point where it would work perfectly if my DHT22 was accurate.

The problem is that my DHT22 reads temp ~3 degrees high and humidity about 5% higher than the actually temp/humidity is(based off of the other 3 temp/humidity devices in the incubator).

Simply put, I need a way (preferably through the HA interface as my coding skills are basically none existent at this point) to take the values from the DHT22/ESP32 and just add 3 degrees and 5% to them so I can display them accurately on the HA dashboard.

I tried creating a number helper named “calibrator” with an adjustable value between -5 and +5 so I could easily adjust the value(incase 3 was too much/ too little). Then I created a “combine sensor states” helper which was supposed to combine the ESP32_Temperature value with the calibrator helper value so it could then be displayed. Of course this didn’t work, that’d be too easy.

From what I can tell, the combine state helper can’t combine the values because the temperature value is, for example, 103.8F and the calibrator is 3. Maybe it’s because of the F or the decimal??? But I have no idea really.

The combine state helper will show 103.8F if I only have the temperature entity selected in it, but once I include the calibrator helper it just says value: unknown.

Thanks ahead for any help!

There is a very easy way to do this.

Do this in ESPHome using sensor filters. This is the example config for the DHT sensor as you did not supply yours:

# Example configuration entry
sensor:
  - platform: dht
    pin: D2
    temperature:
      name: "Living Room Temperature"
   filters:     ####### add this #######
     - offset: -3
    humidity:
      name: "Living Room Humidity"
   filters:     ####### add this #######
     - offset: -5
    update_interval: 60s
1 Like

As far You know how to create number to enter calibration offset, just use it value in sensor filter:

sensor:
  - platform: ZZZ
    ...
    filters:
      - lambda: return x + id(number_with_offset).state;
1 Like