RobTillaart / DHTNew

Arduino library for DHT11 and DHT22 with automatic sensor recognition
MIT License
99 stars 15 forks source link

Support for SonOff Si7021 #75

Closed Tomat7 closed 2 years ago

Tomat7 commented 2 years ago

Hello! Thanks for nice library. Is the any plans on support for Sonoff Si7021 sensor which is slightly different from Sonoff am2301?

RobTillaart commented 2 years ago

no plans, not familiar with that sensor. how much different? link to datasheet?

RobTillaart commented 2 years ago

Found - https://forum.mysensors.org/topic/9462/low-power-temperature-humidity-node-with-sonoff-si7021 Adafruit has a library - #include "Adafruit_Si7021.h"

Seems to be a I2C device so it cannot be controlled by this library. If there are no further questions you may close the issue.

Tomat7 commented 2 years ago

Yes, original Si7021 is the chip with I2C bus, but ITEAD built "sensor with controller inside". So, sensor has 1-wire bus "like am2301" and compatible with all SonOff devices from TH-series. The details, schema and other links: https://itead.cc/product/sonoff-si7021/ https://wiki.iteadstudio.com/Sonoff_Sensor_Si7021 https://wiki.iteadstudio.com/images/7/7c/Sonoff_Si7021_Sensor_Schematic.pdf https://kaspars.net/blog/sonoff-si7021 https://github.com/arendst/Tasmota/issues/735#issuecomment-348718383

Thanks.

RobTillaart commented 2 years ago

According to the links it should be an AM2301 compatible, and that should work. You might try a run with the dhtnew_pulse_diag.ino sketch and post the output, to see if it indeed matches the protocol.

Assume it is DHT22 compatible, so forcing the type to 22 => dht.setType(22);

RobTillaart commented 2 years ago

You might try a run with the dhtnew_pulse_diag.ino sketch and post the output

@Tomat7 did you try?
or do you have the sensor working?

As I do not have a SonOff Si7021 sensor I cannot do any testing if and where it fails.

RobTillaart commented 2 years ago

As there is no answer I assume the issue is solved.

Sukalo0290 commented 2 years ago

Hey Rob, i'm just starting up on this.

I have a unit that can read both AM2301 and SI7021 sensors but the readings are different i assume due to some sort of offset. Would your code be able to detect the sensor and adjust the offset accordingly?

I'm struggling to get any of your example sketches to load any data, i'm using an esp32, are the data pins different to what you have designed the library for?

I can load the sketch onto the esp without fail but nothing happens.

If you plug each sensor into a sonoff controller it correctly reads both sensors the same but on mine the si7021 is out but a couple degrees and humidity % but not sure exactly what the offset is or how to auto detect it.

RobTillaart commented 2 years ago

@Sukalo0290

My library should support the AM2301 as it uses the same protocol as the DHT22. I have no Si7021 sensor to verify if it works with the DHTNew library.

Note: these sensors are not super accurate - read datasheet for deviations.

From your post I understand you get readings from both (that is good) but they differ. The library supports setHumOffset() and setTempOffset() to correct the raw values.


Would your code be able to detect the sensor and adjust the offset accordingly?

No, the library has no means to recognize the sensor. The only exception is the DHT11 (+ compatible) which uses a different protocol. These sensors do not have any unique ID that could be used for this.


I'm struggling to get any of your example sketches to load any data, i'm using an esp32, are the data pins different to what you have designed the library for?

You can adjust data pins in the constructor DHTNEW(uint8_t pin) to your configuration


If you plug each sensor into a sonoff controller it correctly reads both sensors the same but on mine the si7021 is out but a couple degrees and humidity % but not sure exactly what the offset is or how to auto detect it.

No idea, no experience with sonoff controllers unfortunately.

RobTillaart commented 2 years ago

@Sukalo0290 Any other questions, if not I close this issue.

RobTillaart commented 2 years ago

@Tomat7 @Sukalo0290 FYI In version 0.4.14 I added experimental support for the Sonoff Si7021 in the DHTNEW library. The code is based on work of @phiguimaran, see issue https://github.com/RobTillaart/DHTNew/issues/79