SHT20 in ESPHome on D1 mini

I was attempting to follow the recommendations on this thread to get an SHT20 working in ESPHome on my D1 mini (esp8266) by grabbing the SHT20 stuff from @koan’s library mentioned here, specifically:

  libraries:
    - "Wire"
    - "uFire SHT20"
    - "ArduinoJson"
  includes:
    - include/sht20.h

When building I get this error though (and yeah, I copied the header file and it’s being used):

Compiling /data/deepfreeze/.pioenvs/deepfreeze/lib1ec/uFire SHT20/uFire_SHT20_JSON.cpp.o
/data/deepfreeze/.piolibdeps/deepfreeze/uFire SHT20/src/uFire_SHT20_JSON.cpp:1:18: error: missing binary operator before token "("
 #if __has_include("ArduinoJson.h")
                  ^
*** [/data/deepfreeze/.pioenvs/deepfreeze/lib1ec/uFire SHT20/uFire_SHT20_JSON.cpp.o] Error 1

I haven’t done any CPP in over 20 years, and just barely then and have no idea what this error even means for me to attempt to fix myself and google wasn’t helping me out - likely I just couldn’t google right on this. Is anyone able to provide some more information on what this error means so I can hopefully resolve it?

Thanks,
jl

Hello,

i m interested too with this sensor…seems to be waterproof…other sensors like BME680 dont work after few month in outdoor use…because of humidity…just go to 100% of humidity and dont work anymore…

have you seen this :slight_smile:
https://github.com/Ge1mer/SHT20-Esphome

i will order a SHT20 to test,

try this and make a feedback please,

:wink:

I hadn’t seen this, I’ll see if I can give it a shot this weekend. Thanks!

That’s weird, I just built a configuration with this library today with the latest ESPHome version, and this is running fine on my M5Stack PM2.5 Air Quality Kit. I never tried this library on an ESP8266, though.

I came back to this today and was able to get the SHT20 to work on my D1 mini using this header. I’m running esphome 2022.2.3 as well - not sure if something in one of the updates fixed it or if I just clicked “install” correctly.

Working config for me:

esphome:
  name: deepfreeze
  platform: ESP8266
  board: d1_mini
  libraries:
    - "Wire"
    - "uFire SHT20"
    - "ArduinoJson"
  includes:
    - include/sht20.h

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  ap:
    ssid: "deepfreeze_fallback"
    password: "lost_my_wifi"

captive_portal:
logger:
ota:
api:

time:
  - platform: homeassistant
    id: esptime
    timezone: America/Denver

i2c:
  sda: GPIO04
  scl: GPIO05
  scan: True
  frequency: 200kHz

binary_sensor:
  - platform: status
    name: "Deep Freeze Node Status"
    id: system_status

sensor:
  - platform: uptime
    name: deepfreeze_uptime
  - platform: wifi_signal
    name: "WiFi Signal Sensor"
  - platform: custom
    lambda: |-
      auto sht20 = new SHT20();
      App.register_component(sht20);
      return {sht20->temperature_sensor, sht20->humidity_sensor, sht20->vpd_sensor, sht20->dew_point_sensor};
    sensors:
      - name: "Temperature"
        id: deepfreeze_temperature
        unit_of_measurement: °C
        accuracy_decimals: 2
      - name: "Humidity"
        id: deepfreeze_humidity
        unit_of_measurement: "%"
        accuracy_decimals: 2
      - name: "Vapour-pressure deficit"
        id: deepfreeze_vpd
        unit_of_measurement: "kPa"
        accuracy_decimals: 2
      - name: "Dew point"
        id: deepfreeze_dew_point
        unit_of_measurement: °C
        accuracy_decimals: 2

deep_sleep:
  run_duration: 10s
  sleep_duration: 1min

1 Like

hello,

it doesnt work for me… here are the value :

'Temperature': Sending state 128.86732 °C with 2 decimals of accuracy
[12:01:32][D][sensor:124]: 'Humidity': Sending state 118.00000 % with 2 decimals of accuracy
[12:01:32][D][sensor:124]: 'Vapour-pressure deficit': Sending state -50.00000 kPa with 2 decimals of accuracy

values are the same if i unplug the sht20 lol

Esphome 2022.3.2

i try with a esp32s, same result…value never change, even if i disconnect the sht20…faulty one? dont understand

SDA is green wire and scl yellow, Vcc is 3.3v red wire, GND is black, right please?

same on arduino…temp -46°c and -6% humidity…faulty new sensor for sure…i hold on…

EDIT : my sht20 have the 0x44 adress and not the 0x40…:

Found i2c device at address 0x44

so i modify the library “uFire_SHT20.h” line 14 :

#define SHT20_I2C              0x44

and include in esphome instead of the offcial one :

  includes:
    - include/sht20.h
    - include/ufire/uFire_SHT20.cpp
    - include/ufire/uFire_SHT20.h
    - include/ufire/uFire_SHT20_JSON.cpp
    - include/ufire/uFire_SHT20_JSON.h
    - include/ufire/uFire_SHT20_MP.cpp
    - include/ufire/uFire_SHT20_MP.h

but doesnt work better…

If someone has an idea please?

!!!LOL UPDATE five hours later…!!!

the adress make me thing i bought a SHT20 and they bring me a SHT3x…

Esphome have already the SHT3X-D Temperature+Humidity Sensor Component out of the box…easy…

five lines of code and…IT WORKS LIKE A CHARM

Thanks aliExpress…

hi guys i have a problem with this sensor. if i connect only this device to the i2c bus it works correctly, if i connect also an oled display to the same bus non sensor is not detected.
if I connect the display and the sensor on two different buses, the sensor is detected but reports wrong data