SHT3xD sensor found on I2C but sensor failed

I’m trying to build a multi-sensor device using an ESP32-S3-ETH (https://www.amazon.co.uk/dp/B0FG7V5HZP) and SHT30 sensors (SHT30 Temperature And Humidity Sensor - Wired Enclosed Shell - The Pi Hut) connected over I2C.

This is the code I’ve got so far:

substitutions:
  update_interval_s: "20s"
  temperature_calibration: "0.0"
  humidity_calibration: "0.0"
  
esphome:
  name: espeth
  friendly_name: ESPETH
  on_boot:
    priority: 200
    then:
      - lambda: |-        
          delay(500);

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino #esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "RpY0P3W9DQ6Ow6zNxUGSTH3VX80kN4megOo+cfYmqgw="

ota:
  - platform: esphome
    password: "3ca09ffd090cbb11a8860892d53bd5da"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
 # ap:
 #   ssid: "Espeth Fallback Hotspot"
 #   password: "6UhBTkEfWLOn"

#captive_portal:

ethernet:
  type: W5500
  clk_pin: GPIO13
  mosi_pin: GPIO11
  miso_pin: GPIO12
  cs_pin: GPIO14
  interrupt_pin: GPIO10
  reset_pin: GPIO9

web_server:

light:
  - platform: neopixelbus
    type: GRB
    variant: WS2812
    pin: GPIO21
    num_leds: 3
    name: "NeoPixel Light"
    
button:
  - platform: restart
    name: "Restart"
    icon: "mdi:restart"

i2c:
  sda: GPIO17
  scl: GPIO16
  scan: true
  id: bus_a
  frequency: 400kHz
  timeout: 1ms

sensor:
  - platform: sht3xd
    i2c_id: bus_a
    address: 0x44
    heater_enabled: false
    temperature:
      id: temp
      name: "Temperature"
      filters:
        - lambda: return x + ${temperature_calibration};
    humidity:
      id: humidity
      name: "Humidity"
      filters:
        - lambda: return x + ${humidity_calibration};
    update_interval: ${update_interval_s}

But I always get these errors back:

[14:58:42.798][C][logger:273]: Logger:
[14:58:42.798][C][logger:273]:   Max Level: DEBUG
[14:58:42.798][C][logger:273]:   Initial Level: DEBUG
[14:58:42.799][C][logger:279]:   Log Baud Rate: 115200
[14:58:42.799][C][logger:279]:   Hardware UART: USB_CDC
[14:58:42.801][C][logger:286]:   Task Log Buffer Size: 768
[14:58:42.803][C][i2c.arduino:072]: I2C Bus:
[14:58:42.805][C][i2c.arduino:073]:   SDA Pin: GPIO17
[14:58:42.805][C][i2c.arduino:073]:   SCL Pin: GPIO16
[14:58:42.805][C][i2c.arduino:073]:   Frequency: 400000 Hz
[14:58:42.807][C][i2c.arduino:080]:   Timeout: 10 ms
[14:58:42.809][C][i2c.arduino:089]:   Recovery: bus successfully recovered
[14:58:42.811][I][i2c.arduino:099]: Results from bus scan:
[14:58:42.813][I][i2c.arduino:105]: Found device at address 0x44
[14:58:42.838][C][light:088]: Light 'NeoPixel Light'
[14:58:42.841][C][light:091]:   Default Transition Length: 1.0s
[14:58:42.841][C][light:091]:   Gamma Correct: 2.80
[14:58:42.842][C][restart.button:015]: Restart Button 'Restart'
[14:58:42.845][C][restart.button:018]:   Icon: 'mdi:restart'
[14:58:42.860][C][sht3xd:048]: SHT3xD:
[14:58:42.862][D][sht3xd:051]:   Error reading serial number
[14:58:42.864][E][sht3xd:060]:   Communication with SHT3xD failed!
[14:58:42.867][E][component:144]:   sht3xd.sensor is marked FAILED: unspecified
[14:58:42.886][C][ethernet:361]: Ethernet:
[14:58:42.888][C][ethernet:617]:   IP Address: 192.168.1.148
[14:58:42.888][C][ethernet:617]:   Hostname: 'espeth'
[14:58:42.888][C][ethernet:617]:   Subnet: 255.255.255.0
[14:58:42.888][C][ethernet:617]:   Gateway: 192.168.1.1
[14:58:42.888][C][ethernet:617]:   DNS1: 192.168.1.245
[14:58:42.888][C][ethernet:617]:   DNS2: 172.30.32.1
[14:58:42.890][C][ethernet:638]:   MAC Address: 9A:A3:16:C0:27:95
[14:58:42.890][C][ethernet:638]:   Is Full Duplex: YES
[14:58:42.890][C][ethernet:638]:   Link Speed: 100
[14:58:42.893][C][ethernet:364]:   CLK Pin: 13
[14:58:42.893][C][ethernet:364]:   MISO Pin: 12
[14:58:42.893][C][ethernet:364]:   MOSI Pin: 11
[14:58:42.893][C][ethernet:364]:   CS Pin: 14
[14:58:42.894][C][ethernet:376]:   IRQ Pin: 10
[14:58:42.896][C][ethernet:378]:   Reset Pin: 9
[14:58:42.896][C][ethernet:378]:   Clock Speed: 26 MHz
[14:58:42.898][C][ethernet:393]:   Type: W5500
[14:58:42.901][C][web_server:309]: Web Server:
[14:58:42.901][C][web_server:309]:   Address: espeth.local:80
[14:58:42.917][C][esphome.ota:075]: Over-The-Air updates:
[14:58:42.917][C][esphome.ota:075]:   Address: espeth.local:3232
[14:58:42.917][C][esphome.ota:075]:   Version: 2
[14:58:42.919][C][esphome.ota:082]:   Password configured
[14:58:42.921][C][safe_mode:018]: Safe Mode:
[14:58:42.921][C][safe_mode:018]:   Successful after: 60s
[14:58:42.921][C][safe_mode:018]:   Invoke after: 10 attempts
[14:58:42.921][C][safe_mode:018]:   Duration: 300s
[14:58:42.938][C][api:205]: Server:
[14:58:42.938][C][api:205]:   Address: espeth.local:6053
[14:58:42.940][C][api:210]:   Noise encryption: YES
[14:58:42.960][C][mdns:213]: mDNS:
[14:58:42.960][C][mdns:213]:   Hostname: espeth

So it seems that the sensor can be seen on address 0x44 over I2C but the sht3xd component can’t set up the sensors. I have tried changing the frequency and timeouts to no avail. I have been able to put arduino onto the device using Arduino IDE and the SHT30 sensor works and pulls back results, but I was hoping to use ESPHome.

Is there something I’m missing?

1 Like

Try with default frequency and timeout, set the scan: false.
Make sure your wiring is rock solid.

i2c:
    sda: 17
    scl: 16
    scan: False


sensor:

  - platform: sht3xd
    temperature:
      name: "Temperature"
      id: temperature
      device_class: "temperature"
      state_class: "measurement"      
    humidity:
      name: "Humidity"
      id: humidity
    address: 0x44
    update_interval: 1s

Yeah , keep it simple until you get it working.

Also wondering what the delay is for?

  on_boot:
    priority: 200
    then:
      - lambda: |-        
          delay(500);

Thanks for the help.
I’ve simplified it to:

esphome:
  name: espeth
  friendly_name: ESPETH

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "RpY0P3W9DQ6Ow6zNxUGSTH3VX80kN4megOo+cfYmqgw="

ota:
  - platform: esphome
    password: "3ca09ffd090cbb11a8860892d53bd5da"

ethernet:
  type: W5500
  clk_pin: GPIO13
  mosi_pin: GPIO11
  miso_pin: GPIO12
  cs_pin: GPIO14
  interrupt_pin: GPIO10
  reset_pin: GPIO9

web_server:

i2c:
    sda: 17
    scl: 16
    scan: False

sensor:
  - platform: sht3xd
    temperature:
      name: "Temperature"
      id: temperature
      device_class: "temperature"
      state_class: "measurement"      
    humidity:
      name: "Humidity"
      id: humidity
    address: 0x44
    update_interval: 1s

And double checked that the wires are attached - they seem to be fine. I tried with scan: true and the sensor can still be found, so I guess that means the wiring is ok? But I’m still getting the same:

[17:53:40.599][C][sht3xd:048]: SHT3xD:
[17:53:40.602][D][sht3xd:051]:   Error reading serial number
[17:53:40.606][E][sht3xd:060]:   Communication with SHT3xD failed!
[17:53:40.609][E][component:144]:   sht3xd.sensor is marked FAILED: unspecified

The delay was because I saw something somewhere (I’ve lost the link now) where someone had a problem with the I2C taking a while to startup, so i tried the delay as that was suggested. It didn’t work though.

On the web server output both sensors just show as NA.

Is there any difference to using GPIO17 vs just “17”?

thanks

Just shorter.
Between flashing arduino and idf are you flashing by serial/USB? You can use OTA when going between them.

When I moved it to arduino I reflashed over USB in Arduino IDE and got some readings back from the temp/humidity sensors, then flashed idf also over USB in ESPHome but I reset the device first. So I haven’t moved between them OTA.

# Example I²C configuration
i2c:
  sda: 17
  scl: 16
  scan: true
  frequency: 800kHz
  timeout: 10ms

ESPHOME documents do suggest the above freq and timeout for idf for SHT3X-D

It’s not enough. They have to be well attached, and short.

I’ve tried 800kHz and 10ms. No luck.

The wires are about 15cm long and worked in arduino ide while wired-in the same way as now. Would the “Found device at address 0x44” suggest correct wiring?

However, that does possibly present an issue with what I am trying to do. The plan here is to have a single POE-powered ESP32 with 5 temperature sensors. The ESP32 would sit in between 5 rooms and each sensor would spread out from there, with some being perhaps 10m away. It sounds like those wires would be too long for this?

You can get longer lengths to work if you use twisted pairs but milage may vary.

Correct yes. But not necessarily good enough for i2c communication.
15cm sounds ok. So you are sure about the connections (not some flimsy breadboard setup with jumper wires) and your sensor is the one you linked with pullups onboard?

Try a longer update update_interval: . It may need more time between then 1 second.

I use 30 seconds between updates.

Just a thought. Might work.

i2c is generally the wrong bus to use for those distances. It literally stands for Inter-Integrated Circuit I²C - Wikipedia
and was designed for communication on the same circuit board. 10cm is fine. 10m definitely not. But there are always ways to make things work.

For simple temperature and humidity I am a fan of the cheap BT ones that come with displays. I have almost a dozen around my home and they are great. The batteries last for months. I have one on my freezer and another in the refrigerator. It was easy.

1 Like

LOL. Indeed. SHT31 working at …… drum roll …… 12 m. Non insulated twisted pair. Bit of trial and error getting which twist and whether the other twist had tolerance. Three years and running.

1 Like

I’ve previously tried an update_interval of between 1 and 60s, but just cannot getting it working with esphome.

I’m not using a breadboard at the moment, currently just twisted the wires into the pins - perhaps that’s not as secure as it could be, but it was working in the same fashion in Arduino.

I was thinking I may have just used cat5/6 cabling for the sensor wiring, so it would be twisted pair, but it is sounding like I2C is simply the wrong commincation type for my project. It just needs to be basic temperature readings - humidity is a bonus, and it doesn’t need to be super accurate. They would be used to control IR heating.

At the moment I am using aqara zigbee sensors that have worked fine for me elsewhere, but for this set up, for some reason, I am having to change the batteries every few months even though there are barely any walls and the distances aren’t huge. I was hoping wired temperature sensors would just reduce the maintenance needed.
Perhaps single-wire DHT sensors would work better over the distances I’m trying to work at?

Totally fine - if you soldered them also…
Otherwise you are likely out of luck.

what does that even mean?

Decades ago there was wire wrap wire which was quite reliable, but that had square posts with sharp edges which allowed gas tight connections. If you just hand wrapped random wire on circular cross section pins, you likely have a marginal/sketchy connection which could be part of your problem (but might work just fine sometimes).

For just temperature real DS18B20 sensors are great. Even many of the counterfeit ones work pretty well (but some not so much). I have some that are going on for more than a decade and some that last only a month or two. My compost pile is the real test as it is hot and wet and I have run through at least a dozen sensors there. The goat yard is also hard, but that is more because one of my goats like chewing on things that are not food.

But really, long distances are hard for communication and most sensors don’t have protocols that work well over great distances. It can be done, but I just add more nodes, since Wi-Fi does work well over long distances.

Had any luck with the sht30 sensor yet? I have the same sensor (adafruit 5064, and three of them) and cannot get them to work… So strange… Have a couple SHT4x and they work great… But get this error with every kind of setting I try…

[21:42:18.756][D][sht3xd:051]:   Error reading serial number
[21:42:18.756][E][sht3xd:060]:   Communication with SHT3xD failed!
[21:42:18.756][E][component:154]:   sht3xd.sensor is marked FAILED: unspecified

Hello, I have the same problem. I’ve already tried changing the frequency and timeout in every possible way, but unfortunately without success. Is there a solution yet?