Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonoff SI7021 sensor on TH10 #735

Closed
cputoaster opened this issue Aug 14, 2017 · 37 comments
Closed

Sonoff SI7021 sensor on TH10 #735

cputoaster opened this issue Aug 14, 2017 · 37 comments
Labels
stale Action - Issue left behind - Used by the BOT to call for attention

Comments

@cputoaster
Copy link

cputoaster commented Aug 14, 2017

I have a TH10 with an official SI7021 sensor connected. It works fine through ewlink with original Sonoff FW 2.0.4. I dont get any sensor appearing when flashing Tasmota 5.5.2.

I can see that others got this to work (here #96 ), maybe with a Basic instead of a TH10, but I somehow cannot. I did set gpio4 to I2C SDA and gpio14 to I2C SCL as mentioned in the wiki https://github.com/arendst/Sonoff-Tasmota/wiki/Sensor-Configuration . A scan in the console shows nothing: {"I2Cscan":"No devices found"}

How does the single connected data wire (https://www.itead.cc/wiki/Sonoff_Sensor_Si7021) work with the two gpio ports anyway? Does anyone have this working on a TH10?

@cputoaster
Copy link
Author

ah, looking at the schematics of the sensor, there is an MCU present, so that may translate to some kind of 1-wire protocol.

@bobo-t
Copy link

bobo-t commented Aug 17, 2017

same issue here, I have a TH16 / Si7021, works with fw 2.0.4, it's not detected with Tasmota 5.5.2b (configured as per wiki).
with web log level 3 I see in console after reboot:

SHT1X: Sensor did not ACK command
I2C: T/RH? found at address 0x40

i2cscan returns "No devices found"

@cputoaster
Copy link
Author

Yeah, I guess its a 1-wire protocol, not i2c that we see at the Sonoff. So either its compatible with one of the other existing sensors or its something new. I could not get it to work in a first testing with DHT11, AM2301, DHT22, DS18x20, so I guess its time to get out the signal analyzer ;-).

@davidelang
Copy link
Collaborator

davidelang commented Aug 17, 2017 via email

@bobo-t
Copy link

bobo-t commented Aug 17, 2017

my settings: module 1 , gpio14 5, gpio6 6

@cputoaster
Copy link
Author

Hmm, from the wiki I thought it would be gpio4 to I2C SDA and gpio14 to I2C SCL. But googling the cable connector pinout shows that only gpio14 is actually connected, so the protocol cannot be I2C as that would require two GPIOs.

@arendst
Copy link
Owner

arendst commented Aug 18, 2017

Well there is the bare SI7021 which is an I2C device and there is the ITEAD provided SI7021 external sensor which is the same I2C device controlled by an internal microcontroller to make it a one wire device.

Tasmota currently only supports the bare I2C device as I have no info about the one wire ITEAD protocol.

@bobo-t
Copy link

bobo-t commented Aug 18, 2017

I soldered a strap on TH16 PCB to make available GPIO4 to 4-wire jack and then i decoupled the SCA and SCL pins from MCU on ITEAD's Si7021 sensor and connected the wires to Si7021 chip (including the extra one), now it's working:

STATUS10 {"StatusSNS":{"Time":"2017-08-18T12:59:20", "SI7021":{"Temperature":28.8, "Humidity":37.1}, "TempUnit":"C"}}

anyway it's probably better to use 3-wire type of sensor .

@chris-008
Copy link

I have the same issue with a non functioning Itead SI7021 sensor.
So just to be sure, If we buy an alternative single wire sensor as summarized at https://github.com/arendst/Sonoff-Tasmota/wiki/Sensor-Configuration , we should be good to go? If so , any particular type which is recommended?

@cputoaster
Copy link
Author

cputoaster commented Oct 9, 2017 via email

@chris-008
Copy link

chris-008 commented Oct 10, 2017

Thx @cuptoaster, I'll buy one!

@gelitoam
Copy link

gelitoam commented Oct 10, 2017

I already bought two TH10 with two ITEAD's Si7021 (before reading this). Will Tasmota support them in the (near) future or do I better buy supported ones?

@jctual
Copy link

jctual commented Oct 13, 2017

Does anyone know the protocol used on ITEAD 1-wire si7021 to be able to develop a plugin ?

@cputoaster
Copy link
Author

FYI, I asked on their forum. This is ITEADs answer:

"Sonoff Si7021 just used for our TH device.
So we don't offer protool to customer."

On another note: I would think that reverse engineering the protocol would not be a big thing, I just never got around to connect my USB scope yet.

@peterforeman
Copy link

Same here: T/RH? found at 0x40, and no data. Only reading this AFTER i bought the sensors :-(

@cputoaster Would be great if you can get around the reverse engineering some day!

@zalessky
Copy link

@bobo-t can show on the photo where and how soldered on the Si7021? And how to configure the firmware? I have the same sensor, but I can not get it to work

@bobo-t
Copy link

bobo-t commented Nov 21, 2017

See below picture:
si7021
You need to disconnect the other chip (see the cut on the pcb).
Software configuration:
Module type Sonoff TH
GPIO1 None
GPIO3 None
GPIO4 06 I2C SDA
GPIO14 05 I2C SCL

@zalessky
Copy link

@bobo-t Thank you! sensor works now

@ruimarinho
Copy link

@zalessky could you provide a more detailed guide on how you achieved that?

@zalessky
Copy link

@ruimarinho

  1. blow out a small chip with a blowtorch
  2. solder the data wires as in the picture above from @bobo-t
  3. solder the other end of them to the TN card for GIPO4 and GIPO14 - as in the picture:
    http://tinkerman.cat/wp-content/uploads/2016/10/20161004_220416_LABELSs.jpg
  4. You can leave the power wires for tests as is, but you can also solder them - at your discretion.
    At me the sensor has earned only on firmware ESP Easy
    setup as in the wiki: https://www.letscontrolit.com/wiki/index.php/SI7021/HTU21D

@ruimarinho
Copy link

Thank you very much for your comment. On the wiki, it says Tasmota supports SI7021. Weren't you able to get it working as well?

@zalessky
Copy link

No. I could not tune in

@zalessky
Copy link

@ruimarinho I found my error in the settings and this sensor earned on Tastota firmware. all OK. The sensor is not detected immediately. need a little wait :)

@kkuisma
Copy link

kkuisma commented Dec 2, 2017

I also bought five ITEAD's Si7021 sensors and noticed that those don't work with Tasmota. So, I took my logic analyzer and reverse engineered it. I can send more details later, if needed, but it looks their "one wire" protocol is quite simple. First, the host need to send 0.5ms low pulse, then go high for ~40us, and then move to tri-state (INPUT) to let the sensor send data back. The sensor sends totally 1bit+5 bytes/41 bits (MSB order). At first, the sensor sends a "start bit" that is "1". Next two bytes/16 bits are humidity with one decimal (i.e. 35.6% is sent as 356), two bytes/16 bits after that are temperature in Celsius, again with one decimal (i.e. 23.4C is sent as 234), and finally the last byte/8 bits is a checksum. When sensor sends logical "1" it pulls the line HIGH to ~75us, when it sends logical "0", it pulls the line HIGH to ~25us. There is about 40us (LOW) between HIGH pulses. Checksum is basically a (8-bit) sum of 4 data bytes. I also wrote a simple test code and got right values from the sensor without ITEAD's firmware, so, I believe my revers engineering is correct. @arendst, are you interested to add the support to some following release if I provide needed details?

@cputoaster
Copy link
Author

cputoaster commented Dec 2, 2017 via email

@gerritthomson
Copy link

@kkuisma well done. It would be great to have this protocol included. I bought 4 th16 & 4 si7021 prior to reading this thread.

@gerritthomson
Copy link

@kkuisma looking at the easpeasy code for the dht devices the protocol looks very similar. Perhaps itead implemented the si7021 as a variant of the dht devices.

@xoseperez
Copy link

xoseperez commented Dec 3, 2017

I can confirm that Itead's SI7021 sensor behaves like their AM2301. They have just created a facade to make it use the same protocol. @arendst , your code is different from mine but I think you will only have to change the "delay(20);" in line 88 of the dht file to "delayMicroseconds(500);"

BTW, thanks a lot @kkuisma

@kkuisma
Copy link

kkuisma commented Dec 3, 2017

Excellent! Thx a lot @arendst, and @xoseperez. I just tried the latest version and with very quick and short test, it seems to work perfectly with ITEAD's Si7021 sensor :-)

arendst added a commit that referenced this issue Dec 6, 2017
5.10.0a
 * Add (experimental) support for sensor SHT3x
 * Add support
for sensor MH-Z19(B) using serial interface to be enabled with define
USE_MHZ19 in user_config.h (#561, #1248)
 * Add (experimental) support
for sensor MH-Z19(B) using SoftwareSerial to be enabled with define
USE_MHZ19 in user_config.h (#561, #1248)
 * Add support for iTead SI7021
temperature and humidity sensor by consolidating DHT22 into AM2301 and
using former DHT22 as SI7021 (#735)
 * Fix BME280 calculation (#1051)
 *
Add support for BME680 using adafruit libraries (#1212)
 * Change
ADS1115 default voltage range from +/-2V to +/-6V (#1289)
 * Add
multipress support and more user configurable options to Sonoff Dual R2
(#1291)
 * Fix Sonoff Bridge missed learned key if learned data contains
0x55 (End of Transmission) flag (#1095, #1294)
 * Add support for
TSL2561 using adafruit library (#661, #1311)
 * Add alternative support
for SHT3x (#1314)
@jdpiguet
Copy link

jdpiguet commented Dec 8, 2017

So how should the module configuration look like?
I have "Module type (Sonoff Basic)" as "04 Sonoff TH" and "GPIO14 Sensor" as "03 SI7021"
But I don't get any measurement...
[Edit] Problem solved: the configuration is correct, it was a HW issue!

arendst added a commit that referenced this issue Dec 8, 2017
5.10.0a
 * Add (experimental) support for sensor SHT3x
 * Add support
for sensor MH-Z19(B) using serial interface to be enabled with define
USE_MHZ19_HARD_SERIAL in user_config.h (#561, #1248)
 * Add
(experimental) support for sensor MH-Z19(B) using SoftwareSerial to be
enabled with define USE_MHZ19_SOFT_SERIAL_OBSOLETE in user_config.h
(#561, #1248)
 * Add (experimental) support for sensor MH-Z19(B) using
stripped SoftwareSerial to be enabled with define USE_MHZ19_SOFT_SERIAL
in user_config.h (#561, #1248)
 * Add support for iTead SI7021
temperature and humidity sensor by consolidating DHT22 into AM2301 and
using former DHT22 as SI7021 (#735)
 * Fix BME280 calculation (#1051)
 *
Add support for BME680 using adafruit libraries (#1212)
 * Change
ADS1115 default voltage range from +/-2V to +/-6V (#1289)
 * Add
multipress support and more user configurable options to Sonoff Dual R2
(#1291)
 * Fix Sonoff Bridge missed learned key if learned data contains
0x55 (End of Transmission) flag (#1095, #1294)
 * Add support for
TSL2561 using adafruit library (#661, #1311)
 * Add alternative support
for SHT3x (#1314)
arendst added a commit that referenced this issue Jan 7, 2018
5.11.0 20180107
 * Minor webpage HTML optimizations (#1358)
 * Updated
German translation (#1438)
 * Change Sonoff Pow Energy MQTT data message
and consolidate Status 8 into Status 10
 * Change ADS1115 default
voltage range from +/-2V to +/-6V (#1289)
 * Change text to Active for 3
minutes (#1364)
 * Change Wemo SetBinaryState to distinguish from
GetBinaryState (#1357)
 * Change output of HTTP command to valid JSON
and Array only (#1363)
 * Removed all MQTT, JSON and Command language
defines from locale files and set fixed to English (#1473)
 * Renamed
commands Color2,3,4 to Color3,4,5
 * Fix BME280 calculation (#1051)
 *
Fix Sonoff Bridge missed learned key if learned data contains 0x55 (End
of Transmission) flag (#1095, #1294)
 * Fix PWM initialization in
Dimmer/Color mode (#1321)
 * Fix Wemo Emulation (#1357)
 * Fix display
of build date and time in non-english locale (#1465)
 * Fix Wemo and Hue
emulation by adding M-Search response delay (#1486)
 * Add libraries
Adafruit_BME680-1.0.5, Adafruit_Sensor-1.0.2.02, TasmotaSerial-1.0.0 and
TSL2561-Arduino-Library
 * Add command Color2 to set color while keeping
same dimmer value
 * Add device function pointers
 * Add support for
SenseAir S8 CO2 sensor
 * Add color led signal to Carbon Dioxide (CO2)
sensors using defines CO2_LOW and CO2_HIGH in user_config.h
 * Add
support for Domoticz Air Quality sensor to be used by MH-Z19(B) and
SenseAir sensors
 * Add support for PZEM004T energy sensor
 * Add
support for iTead SI7021 temperature and humidity sensor by
consolidating DHT22 into AM2301 and using former DHT22 as SI7021 (#735)

* Add support for BME680 using adafruit libraries (#1212)
 * Add support
for MH-Z19(B) CO2 sensor (#561, #1248)
 * Add multipress support and
more user configurable GPIO to Sonoff Dual R2 (#1291)
 * Add support for
TSL2561 using adafruit library (#661, #1311)
 * Add support for SHT3x
(#1314)
 * Add support for Arilux LC06 (#1414)
 * Add Italian language
file (#1449)
 * Add 2nd Gen Alexa support to Wemo emulation discovery
(#1357, #1450)
 * Add define for additional number of WS2812 schemes
(#1463)
@socbrian
Copy link

socbrian commented Jan 7, 2018

Just upgraded to 5.11.0 and my si7021 works great! Thanks, probably can make this closed now

joecotton pushed a commit to joecotton/Sonoff-Tasmota that referenced this issue Jan 8, 2018
5.11.0 20180107
 * Minor webpage HTML optimizations (arendst#1358)
 * Updated
German translation (arendst#1438)
 * Change Sonoff Pow Energy MQTT data message
and consolidate Status 8 into Status 10
 * Change ADS1115 default
voltage range from +/-2V to +/-6V (arendst#1289)
 * Change text to Active for 3
minutes (arendst#1364)
 * Change Wemo SetBinaryState to distinguish from
GetBinaryState (arendst#1357)
 * Change output of HTTP command to valid JSON
and Array only (arendst#1363)
 * Removed all MQTT, JSON and Command language
defines from locale files and set fixed to English (arendst#1473)
 * Renamed
commands Color2,3,4 to Color3,4,5
 * Fix BME280 calculation (arendst#1051)
 *
Fix Sonoff Bridge missed learned key if learned data contains 0x55 (End
of Transmission) flag (arendst#1095, arendst#1294)
 * Fix PWM initialization in
Dimmer/Color mode (arendst#1321)
 * Fix Wemo Emulation (arendst#1357)
 * Fix display
of build date and time in non-english locale (arendst#1465)
 * Fix Wemo and Hue
emulation by adding M-Search response delay (arendst#1486)
 * Add libraries
Adafruit_BME680-1.0.5, Adafruit_Sensor-1.0.2.02, TasmotaSerial-1.0.0 and
TSL2561-Arduino-Library
 * Add command Color2 to set color while keeping
same dimmer value
 * Add device function pointers
 * Add support for
SenseAir S8 CO2 sensor
 * Add color led signal to Carbon Dioxide (CO2)
sensors using defines CO2_LOW and CO2_HIGH in user_config.h
 * Add
support for Domoticz Air Quality sensor to be used by MH-Z19(B) and
SenseAir sensors
 * Add support for PZEM004T energy sensor
 * Add
support for iTead SI7021 temperature and humidity sensor by
consolidating DHT22 into AM2301 and using former DHT22 as SI7021 (arendst#735)

* Add support for BME680 using adafruit libraries (arendst#1212)
 * Add support
for MH-Z19(B) CO2 sensor (arendst#561, arendst#1248)
 * Add multipress support and
more user configurable GPIO to Sonoff Dual R2 (arendst#1291)
 * Add support for
TSL2561 using adafruit library (arendst#661, arendst#1311)
 * Add support for SHT3x
(arendst#1314)
 * Add support for Arilux LC06 (arendst#1414)
 * Add Italian language
file (arendst#1449)
 * Add 2nd Gen Alexa support to Wemo emulation discovery
(arendst#1357, arendst#1450)
 * Add define for additional number of WS2812 schemes
(arendst#1463)
@aenertia
Copy link

Just tried with the itead si7021 module and brand new th16's (ver 2.1 dated 2017-6-8 on silkscreen) and dev branch of tasmota; am getting this:

DHT: Timeout waiting for start signal high pulse

when configured as GPIO14

Board is only powered over serial - if this matters at all, haven't tested off AC with in built rectifier. I bought a bunch of these to monitor our new house (it's an old damp house unfortunately) and the prospect of needing to mod all of them and my th16's for I2C doesn't really sound appealing.

@mcoms
Copy link

mcoms commented May 23, 2018

Powered over AC and with a new Sonoff TH16 v2.1 2017-6-8 and a new Sonoff Sensor SI7021 v1.0 running Sonoff-Tasmota 5.13.1, and module configured as 04 Sonoff TH, GPIO14: 03 SI7021, this works fine.

However a second identical device and sensor gives me DHT: Timeout waiting for start signal high pulse. I believe this is because I plugged the sensor in with the board powered up. If you get this error you may have a damaged sensor.

@stale
Copy link

stale bot commented Jul 7, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Action - Issue left behind - Used by the BOT to call for attention label Jul 7, 2018
curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
* Add (experimental) support for iTead SI7021 temperature and humidity
sensor (arendst#735)
 * Change ADS1115 default voltage range from +/-2V to
+/-6V (arendst#1289)
curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
5.10.0a
 * Add (experimental) support for sensor SHT3x
 * Add support
for sensor MH-Z19(B) using serial interface to be enabled with define
USE_MHZ19 in user_config.h (arendst#561, arendst#1248)
 * Add (experimental) support
for sensor MH-Z19(B) using SoftwareSerial to be enabled with define
USE_MHZ19 in user_config.h (arendst#561, arendst#1248)
 * Add support for iTead SI7021
temperature and humidity sensor by consolidating DHT22 into AM2301 and
using former DHT22 as SI7021 (arendst#735)
 * Fix BME280 calculation (arendst#1051)
 *
Add support for BME680 using adafruit libraries (arendst#1212)
 * Change
ADS1115 default voltage range from +/-2V to +/-6V (arendst#1289)
 * Add
multipress support and more user configurable options to Sonoff Dual R2
(arendst#1291)
 * Fix Sonoff Bridge missed learned key if learned data contains
0x55 (End of Transmission) flag (arendst#1095, arendst#1294)
 * Add support for
TSL2561 using adafruit library (arendst#661, arendst#1311)
 * Add alternative support
for SHT3x (arendst#1314)
curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
5.10.0a
 * Add (experimental) support for sensor SHT3x
 * Add support
for sensor MH-Z19(B) using serial interface to be enabled with define
USE_MHZ19_HARD_SERIAL in user_config.h (arendst#561, arendst#1248)
 * Add
(experimental) support for sensor MH-Z19(B) using SoftwareSerial to be
enabled with define USE_MHZ19_SOFT_SERIAL_OBSOLETE in user_config.h
(arendst#561, arendst#1248)
 * Add (experimental) support for sensor MH-Z19(B) using
stripped SoftwareSerial to be enabled with define USE_MHZ19_SOFT_SERIAL
in user_config.h (arendst#561, arendst#1248)
 * Add support for iTead SI7021
temperature and humidity sensor by consolidating DHT22 into AM2301 and
using former DHT22 as SI7021 (arendst#735)
 * Fix BME280 calculation (arendst#1051)
 *
Add support for BME680 using adafruit libraries (arendst#1212)
 * Change
ADS1115 default voltage range from +/-2V to +/-6V (arendst#1289)
 * Add
multipress support and more user configurable options to Sonoff Dual R2
(arendst#1291)
 * Fix Sonoff Bridge missed learned key if learned data contains
0x55 (End of Transmission) flag (arendst#1095, arendst#1294)
 * Add support for
TSL2561 using adafruit library (arendst#661, arendst#1311)
 * Add alternative support
for SHT3x (arendst#1314)
KrzysztofPrzygoda added a commit to KrzysztofPrzygoda/Tasmota that referenced this issue Jan 9, 2020
1. Only DHT22 protocol has been changed according to the issue arendst#5619.
2. noInterrupts() command moved to the begining of the reading protocol.
3. One switch created to embrace protocols for all sensors in one place for better code readability (protocols revision gathered below and placed in code comments).
4. Tested on AM2302. Usually issue arendst#5619 occured after several hours and needed power cycle reboot. Currently works without a problem for over 2 days.

DHT21, DHT22, AM2301, AM2302
Specs:
https://cdn-shop.adafruit.com/datasheets/Digital+humidity+and+temperature+sensor+AM2302.pdf

Protocol:
1. MCU PULLS LOW data bus for 1 to 10ms to activate sensor
2. MCU PULLS UP data bus for 20-40us to ask sensor for response
3. SENSOR PULLS LOW data bus for 80us as a response
4. SENSOR PULLS UP data bus for 80us for data sending preparation
5. SENSOR starts sending data (LOW 50us then HIGH 26-28us for "0" or 70us for "1")

DHT11
Specs:
https://www.mouser.com/datasheet/2/758/DHT11-Technical-Data-Sheet-Translated-Version-1143054.pdf

Protocol:
1. MCU PULLS LOW data bus for at least 18ms to activate sensor
2. MCU PULLS UP data bus for 20-40us to ask sensor for response
3. SENSOR PULLS LOW data bus for 80us as a response
4. SENSOR PULLS UP data bus for 80us for data sending preparation
5. SENSOR starts sending data (LOW 50us then HIGH 26-28us for "0" or 70 us for "1")

SI7021
Specs:
https://www.silabs.com/documents/public/data-sheets/Si7021-A20.pdf

Protocol:
Reverse-engineered on arendst#735 (comment):
1. MCU PULLS LOW data bus for at 500us to activate sensor
2. MCU PULLS UP data bus for ~40us to ask sensor for response
3. SENSOR starts sending data (LOW 40us then HIGH ~25us for "0" or ~75us for "1")
4. SENSOR sends "1" start bit as a response
5. SENSOR sends 16 bits (2 bytes) of a humidity with one decimal (i.e. 35.6% is sent as 356)
6. SENSOR sends 16 bits (2 bytes) of a temperature with one decimal (i.e. 23.4C is sent as 234)
7. SENSOR sends 8 bits (1 byte) checksum of 4 data bytes
@Littlesloths
Copy link

Is it possible to use more than one of sonoff's (itead) sensors with their one wire bus (not I2C) on one GPIO? I've seen others doing that via I2C, but on one-wire there seems to be no bus-scan and only one sensor possible to choose, correct?
I like to use 1x SI7021 + 1x AM2302 (to avoid using 2x same SI7021 in case that is not supported) + 1x ds18b20.

@Littlesloths
Copy link

See below picture:
si7021
You need to disconnect the other chip (see the cut on the pcb).
Software configuration:
Module type Sonoff TH
GPIO1 None
GPIO3 None
GPIO4 06 I2C SDA
GPIO14 05 I2C SCL

In case I cut the connections as per your picture, may the four pins vcc, gnd, sda, scl be used? or do I need to cut some more?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Action - Issue left behind - Used by the BOT to call for attention
Projects
None yet
Development

No branches or pull requests