Temperature problem with an ENS160+AHT21

Hello,
I have connected an ENS160+AHT21 sensors to an ESP, everything works fine but the temperature.

I used this sensor because I have read that it is very accurate but mine it is not. I always have +5/6 °C above the ambient temperature.

I powered it with the +5V because all the diagrams I found uses that pin, but onboard there is also a 3.3V

How can I solve? Is there a sort of calibration to do?

Here there reference:

  • a random digital thermometer 22°C
  • a motion sensor with temp from philips 21,22 °C
  • and the AHT21 I have to use with the Ikea Vindriktning 27.07°C

# -------------------------------------------------------------
#                         PROGETTO ZERO
# -------------------------------------------------------------
#
# creato da           RP
# data creazione      28.01.2024
# data_modifica       28.01.2024
# versione            0.20
#
#
# -------------------------------------------------------------

esphome:
  name: zero-1
  friendly_name: zero-1
  platform: ESP8266
  board: d1_mini
  # on_boot:
  #    - priority: -100
  #      then:
  #        - wait_until: api.connected
  #        - delay: 1s
  #        - if:
  #            condition:
  #              switch.is_on: use_wake_word
  #            then:
  #              - voice_assistant.start_continuous:  

api:
  encryption:
    key: "chiave-api"

ota:
  password: "chiave-ota"

wifi:
  ssid: !secret wifi_iot_ssid
  password: !secret wifi_iot_password   
  ap:
    ssid: "zero-1-wifi"
    password: "my_super_password"   

  manual_ip:
    static_ip: 192.168.207.41
    gateway: 192.168.207.254
    subnet: 255.255.255.0
    dns1: 192.168.207.254
  domain: .mydomain.cloud

logger:


## porta UART per sensore ikea (pin rest) 
uart:
  - rx_pin: D7
    # tx_pin: D8
    baud_rate: 9600

## porta i2c
i2c:
  sda: D2
  scl: D1
  scan: true
  id: bus_a
#  frequency: 200khz

binary_sensor:
#   ## Use the on-board LED to show "Fan Running"
#   - platform: gpio
#     name: zero-1-ventola
#     id: fan
#     pin:
#       number: D4
#       inverted: true

  - platform: template
    name: zero-1-luce-ok
    id: bright

sensor:
  ## IKEA PMS 2.5um Sensor
  - platform: pm1006
    id: aq_sensor
    pm_2_5:
      name: zero-1-pm-25

  ## The IKEA Light Level Sensor
  - platform: adc
    id: zero_1_livello_luce
    name: zero-1-livello-luce
    pin: A0
    update_interval: 10s
    ## Check the value and turn On/Off our Binary Sensor
    on_value:
      - lambda: !lambda |
          if (x > 0.01) {
            id(bright).publish_state(true);
            } else {
              id(bright).publish_state(false);
              }
      - logger.log:
          format: "livello luce %.6f"
          args: id(zero_1_livello_luce).state  

  # ENS160 qualità aria, co2 e voc
  - platform: ens160
    eco2:
      name: zero-1-co2
    tvoc:
      name: zero-1-voc
    aqi:
      name: zero-1-aqi
      id: id_zero_1_aqi
    update_interval: 10s
    address: 0x53
    compensation:
      temperature: id_zero_1_temperatura
      humidity: id_zero_1_umidita

  # AHT21 temperatura e umidità
  - platform: aht10
    variant: AHT20
    temperature:
      name: zero-1-temperatura
      id: id_zero_1_temperatura
    humidity:
      name: zero-1-umidita
      id: id_zero_1_umidita
    update_interval: 30s  
    address: 0x38    

text_sensor:
  - platform: template
    name: zero-1-qualita-aria
    lambda: |-
      switch ( (int) (id(id_zero_1_aqi).state) ) {
        case 1: return {"eccellente"};
        case 2: return {"buona"};
        case 3: return {"media"};
        case 4: return {"scarsa"};
        case 5: return {"molto scarsa"};
        default: return {"non disponibile"};
      }

EDIT: add code

Have you waited the 1 hour +/- it takes before itd ready to take readings?

Yes I did,
but the temperature as well as humidity are present since the first boot up, the hour is needed for the ENS160

here is a comparison between the temperature read from the sensor (blue) and from the philips hue motion sensor

the gap since the beginning is +5/6 °C

PS. I just noticed that the sensor stop sending all data (from ENP160 and from AHT), on log I have

[20:00:08][C][ens160:314]:     State Class: 'measurement'
[20:00:08][C][ens160:314]:     Unit of Measurement: '%'
[20:00:08][C][ens160:314]:     Accuracy Decimals: 2
[20:00:08][C][aht10:150]: AHT10:
[20:00:08][C][aht10:151]:   Address: 0x38
[20:00:08][E][aht10:153]: Communication with AHT10 failed!
[20:00:08][C][aht10:155]:   Temperature 'zero-1-temperatura'
[20:00:08][C][aht10:155]:     Device Class: 'temperature'
[20:00:08][C][aht10:155]:     State Class: 'measurement'
[20:00:08][C][aht10:155]:     Unit of Measurement: '°C'
[20:00:08][C][aht10:155]:     Accuracy Decimals: 2
[20:00:08][C][aht10:156]:   Humidity 'zero-1-umidita'
[20:00:08][C][aht10:156]:     Device Class: 'humidity'
[20:00:08][C][aht10:156]:     State Class: 'measurement'
[20:00:10][C][aht10:156]:     Unit of Measurement: '%'
[20:00:10][C][aht10:156]:     Accuracy Decimals: 2

I have reboot it and it start to send data again

Have you watched the logs to see if its picking up any other i2c addresses in the backround?

Your power supply is more than adequate, right?

You can always swap out sensors to rule out the actual sensor as the problem too.

How can I do? (sorry I am not so expert of esphome)

Anyway when I start the log this is what I get

[21:22:33][I][i2c.arduino:069]: Results from i2c bus scan:
[21:22:33][I][i2c.arduino:075]: Found i2c device at address 0x38
[21:22:33][I][i2c.arduino:075]: Found i2c device at address 0x53

these are the only 2 i2c devices connected, the other one used uart (for the pm2.5 from the ikea board).
Esphome sees two devices but the board is one

I am using the usb from the ikea board to power up everything (for the power I am using a 60W from ugreen) so unless some regulator inside of this board I should be ok with the current.
I have checked the voltage on the esp and on the board and I have 5.1V

Unfortunately this is the only sensor I have.
I can try to change the esp itself… using a full length board instead of the mini, but I don’t think that this will solve…

I think I find the problem, when operate this combo device, it heats up and this cause the wrong temperature reading.

…there is a strong correlation between the temperature and the validity of the ENS160 data. It seems that the heater of the ENS160 significantly warms up the AHT21 as there is an increase of about 6 °C when the ENS160 is producing data. This is a bad sign for anyone wanting to use this sensor for environment monitoring. Furthermore, at the same time that data retrieval from ENS160 stops, the temperature starts to drop again which implies that the ENS160’s heaters are turned off.

so it is compact and complete, but not the best sensor around…

Idk if you did or didnt but, researching devices/sensors before you buy them is a good idea. It doesnt seem like most people do any at all.

I can’t check all feedback that people leaves around the whole web, the few info I found were positives so I trusted them…

Anyway… Don’t worry, next time I will ask directly to you :wink:

Ya, thats true. I wasnt going to bring it up but, since you did. Im honestly a little disappointed you didnt check with me first on this one…

Next time I will, I have read some other of your posts and you are look very prepared! :+1:

I am seeing the same problem. The AHT21 is basically useless.

I complained to the seller and got half off. So using it as just the ens160 currently, although I am still unsure if that can be trusted considering how dumb the designers of this combo sensor were.

This probably would not be a problem if the sensors were not active at the same time, so this is more of a software problem than anything else.
Anyway, thanks for the info I am going to access the sensors from arduino instead so that this does not become a problem.

Hello,
I just came across your post. I can make life easier for some people in the future. I was running into the same temperature issue with the combined ENS160+AHT21 boards that I purchased from Amazon. I haven’t had any voltage sag issues, but the temperature issue was pretty bad. I have only been testing for a half a day or so, but I see very promising results when adding a 6 x 6 x 5 mm copper heatsink to the back of the PCB behind the ENS160 (the silver metal square). Temps were off by 4C or so, but now they’re quite close to reality. I also tried placing the heatsink on the back of the AHT21, but that didn’t correct the issue completely.

As for using lower power modes via software, after rummaging through the datasheet I unfortunately found that the sensor needs a 3 minute warm-up any time it’s not in the STANDARD (active) mode. While one could take a temp reading, then enable the ENS160, wait 3 minutes and take a gas reading, this isn’t a great solution. I was hoping for a similar fix, but oh well. I hope this helps.
Cheers!

Ugh…as a new poster, I wasn’t able to embed two photos. Here’s a pic of it in action attached to a D1 mini clone.

1 Like

Can you please share your code.

ich habe den gleichen sensor und will ihn gerne nutzen. gerne aber ohne provisorische metallteile. hat jemand eine andere lösung gefunden? der temperatursensor ist ja eigentlich gut separiert. ich kann mir das gar nicht gut erklären warum er so viel grad zuviel anzeigt. das problem ist ja dann auch die luftfeuchte. die wird ja bei 5 grad zuviel gemessen. und auch wenn ich die temperatur kalibriere, bleibt ja die luftfeuchtigkeit zu niedrig.

oder gibt es einen anderen sensor in der preiskategorie, der auch eCO2 messen kann? bzw wie zuverlässig sind denn die eCO2 werte des sensors? ich will ihn hauptsächlich dafür nutzen

I am seeing AHT give readings of 31C in a room that is 21C!!! WHAT THE HECK???

Is it really junk? I thought it was supposed to be good, better than DHT? My DHT is more accurate…