@@ -16,27 +16,33 @@ Arduino library for the SHT2x, HTU2x and Si70xx temperature and humidity sensors
1616
1717## Description
1818
19- This library is not tested extensively yet.
20- It works for the Si7021 including the asynchronous interface.
21- It should work for SHT20, SHT21 and SHT25 but these are not tested yet.
22- The SHT2x family of sensors should work up to 400 KHz I2C.
19+ This library is to use the SHT20, SHT21 and SHT25 and compatible temperature
20+ and humidity sensors.
21+ The interface implements an asynchronous API to prevent blocking code, examples
22+ exist how this is used.
23+ For simplicity there is also a blocking read() call.
24+
25+ The library is verified for the SHT21, HTU21 and Si7021 including the asynchronous
26+ interface. It is expected to work for SHT20 and SHT25 as these are datasheet
27+ compatible but these are not tested yet.
2328
2429Furthermore there are several other sensors that should be compatible
2530(see table below), but have not been tested either.
2631
27- Accuracy table
32+ Accuracy table (indicative)
2833
29- | Sensor | Temperature | Humidity | Notes |
30- | :---------:| :-----------:| :--------:| :--------|
31- | SHT20 | ~ 0.3 | ±3.0 | |
32- | SHT21 | ~ 0.3 | ±3.0 | |
33- | SHT25 | ~ 0.3 | ±1.8 | |
34- | HTU20 | | | to-do |
35- | HTU21 | | | #40 |
36- | Si7013 | | | to-do |
37- | Si7020 | | | to-do |
38- | Si7021 | ~ 0.3 | ~ 2.0 | |
39- | GY21 | | | to-do |
34+ | Sensor | test | Temperature | Humidity | Notes |
35+ | :--------:| :----:| :-----------:| :--------:| :--------|
36+ | SHT20 | - | ±0.3 | ±3.0 |
37+ | SHT21 | Y | ±0.3 | ±3.0 |
38+ | SHT25 | - | ±0.3 | ±1.8 |
39+ | HTU20 | - | | |
40+ | HTU21 | Y | ±0.3 | ±2.0 | #40 #42
41+ | Si7013 | - | ±0.3 | ±3.0 |
42+ | Si7020 | - | ±0.3 | ±4.0 |
43+ | Si7021 | Y | ±0.3 | ±2.0 |
44+ | GY21 | - | | | often HTU21
45+ | HDC1080 | - | ±0.2 | ±2.0 | TI
4046
4147
4248All sensors in this family of sensors have address 0x40 (64 decimal).
@@ -46,6 +52,30 @@ or one should switch sensors on/off like the select in SPI communication.
4652Feedback as always is welcome.
4753
4854
55+ ### 0.5.5 Wifi affecting accuracy
56+
57+ See https://github.com/RobTillaart/SHT2x/issues/42
58+
59+ User pgtest did a number of experiments after he saw an increased temperature
60+ and decreased humidity when the sensors he used were in close proximity (about 3 cm)
61+ of the ESP-C3 Wifi antenna. As far as understood the 2.4 GHz heats up the water
62+ molecules in the air which cause the absolute humidity to rise, and thus the relative
63+ humidity to go down. Furthermore it seems that water evaporates which causes the
64+ absolute humidity drop too, resulting in drop of relative humidity too.
65+ Possibly there are more ways the 2.4 GHz could affect the sensor, especially the amount
66+ of Wifi usage could be a factor.
67+
68+ Shortly discussed on the Arduino forum, there were additional cause e.g. RF effect on
69+ internal electronics and possible effects from a power dip when Wifi is switched on.
70+
71+ The library does not compensate for the found effect as there is no formula that calculates
72+ the delta for a given distance and/or Wifi usage. However one could use the multiMap()
73+ library to build (non-linear) corrections if needed.
74+
75+ Advice is to keep the sensor "as far" from heat sources including Wifi as possible.
76+ Also take care of good air circulation in/around the sensor.
77+
78+
4979### 0.5.0 Breaking change
5080
5181Version 0.5.0 introduced a breaking change.
@@ -57,10 +87,44 @@ before calling **begin()**.
5787
5888### Related
5989
90+ - https://github.com/RobTillaart/SHT2x
91+ - https://github.com/RobTillaart/SHT2x_INT - integer math only to minimize footprint.
6092- https://github.com/RobTillaart/SHT31
6193- https://github.com/RobTillaart/SHT85
62- - https://github.com/RobTillaart/tinySHT2x
63- - https://github.com/RobTillaart/Temperature Temperature related formulas.
94+ - https://github.com/RobTillaart/tinySHT2x - specific for AVR tiny processors.
95+ - https://github.com/RobTillaart/Temperature - Temperature related formulas.
96+ - https://github.com/RobTillaart/MultiMap - non linear mapping
97+
98+
99+ ### Special chars (win)
100+
101+ ALT241 = ± (plus-minus)
102+ ALT167 = º (degrees)
103+
104+
105+ ## I2C
106+
107+ ### Performance
108+
109+ The SHT2x family of sensors should work up to 400 KHz I2C.
110+
111+
112+ ### I2C multiplexing
113+
114+ Sometimes you need to control more devices than possible with the default
115+ address range the device provides.
116+ This is possible with an I2C multiplexer e.g. TCA9548 which creates up
117+ to eight channels (think of it as I2C subnets) which can use the complete
118+ address range of the device.
119+
120+ Drawback of using a multiplexer is that it takes more administration in
121+ your code e.g. which device is on which channel.
122+ This will slow down the access, which must be taken into account when
123+ deciding which devices are on which channel.
124+ Also note that switching between channels will slow down other devices
125+ too if they are behind the multiplexer.
126+
127+ - https://github.com/RobTillaart/TCA9548
64128
65129
66130## Interface
@@ -115,7 +179,7 @@ these bits.
115179These functions are used for synchronous (blocking) reads of temperature and humidity.
116180
117181- ** bool read()** : Reads both temperature and humidity from the sensor.
118- This is a blocking call; program execution will pause until the readings are complete.
182+ This is a blocking call, and program execution will pause until the readings are complete.
119183- ** float getTemperature()** : Returns the temperature in degrees Celsius (°C) based
120184on the latest raw data acquired by ` read() ` .
121185- ** float getHumidity()** : Returns the relative humidity in percent (%) based on the
@@ -125,7 +189,7 @@ value for temperature directly from the sensor, as acquired by `read()`.
125189- ** uint16_t getRawHumidity()** : Returns the raw, not calibrated 16-bit integer
126190value for humidity directly from the sensor, as acquired by ` read() ` .
127191
128- ** Note on ` read() ` and data retrieval: **
192+ ** Note on ` read() ` and data retrieval**
129193The ` getTemperature() ` and ` getHumidity() ` functions recalculate values from raw
130194data on every call. If performance is critical, cache these values in your code after
131195a ` read() ` instead of calling them repeatedly. Raw values are useful for minimizing
@@ -152,7 +216,7 @@ stalled while waiting for sensor data. This interface is experimental (since 0.2
152216and may change in future versions.
153217See discussion in [ issue #16 ] ( https://github.com/RobTillaart/SHT2x/issues/16 ) .
154218
155- ** General Workflow for Asynchronous Operations: **
219+ ** General Workflow for Asynchronous Operations**
156220
1572211 . ** Initiate a request:** Call ` requestTemperature() ` to start a temperature
158222measurement or ` requestHumidity() ` to start a humidity measurement.
@@ -167,7 +231,7 @@ retrieve the humidity value. These functions then fetch the data from the sensor
167231and update the internal raw values.
168232You can then use ` getTemperature() ` or ` getHumidity() ` to get the processed values.
169233
170- ** Difference between synchronous ` read() ` and asynchronous operations: **
234+ ** Difference between synchronous ` read() ` and asynchronous operations**
171235- ** Synchronous ` read() ` ** : When you call ` read() ` , your program stops and waits
172236for the sensor to complete both temperature and humidity measurements.
173237This is simpler to use but can block other operations for the duration of the sensor's
@@ -178,7 +242,7 @@ retrieve the result.
178242This avoids blocking but requires a slightly more complex program structure to
179243periodically check the sensor's status.
180244
181- ** Asynchronous Function Descriptions: **
245+ ** Asynchronous Function Descriptions**
182246
183247- ** ` bool requestTemperature() ` ** : Initiates a request for a temperature reading from the sensor.
184248If a previous asynchronous request (either temperature or humidity) was still pending,
@@ -220,7 +284,7 @@ The possible return values are:
220284| 0x02 | ` SHT2x_REQ_HUMIDITY ` | A humidity request is currently pending or was the last one made. |
221285| 0xFF | ` SHT2x_REQ_FAIL ` | A humidity request is currently pending or was the last one made. |
222286
223- ** Example Snippet (Asynchronous Reading): **
287+ ** Example Snippet (Asynchronous Reading)**
224288
225289``` cpp
226290#include " SHT2x.h"
@@ -292,7 +356,7 @@ void loop() {
292356}
293357```
294358
295- ** Waiting until the device is ready: **
359+ ** Waiting until the device is ready**
296360
297361These sensors typically need a bit of time to start up before they can accept commands.
298362The SHT21, for instance, requires up to 15ms after it's been powered up.
@@ -339,7 +403,8 @@ specific sensor model; refer to the sensor datasheet.)
339403### Electronic ID
340404
341405Functions to retrieve the unique electronic identification code and firmware version from the sensor.
342- (These functions need more testing and have primarily been tested with Si7021 sensors.)
406+ These functions need more testing and have primarily been tested with Si7021 sensors (low prio).
407+ They might not be supported on some "compatible" sensors.
343408
344409- ** uint32_t getEIDA()** : Returns the first part (A) of the electronic ID.
345410- ** uint32_t getEIDB()** : Returns the second part (B) of the electronic ID.
@@ -353,8 +418,8 @@ Allows adjustment of the measurement resolution for temperature and humidity.
353418as initial results are not perfectly aligned with datasheet specifications.
354419It has been primarily tested on HTUxx and Si7021 sensors using the ` SHT2X_resolution.ino ` example.
355420
356- - ** bool setResolution(uint8_t res )** : Sets the measurement resolution.
357- ` res ` can be 0, 1, 2, or 3. Other values will result in the function returning ` false ` .
421+ - ** bool setResolution(uint8_t resolution )** : Sets the measurement resolution.
422+ ` resolution ` can be 0, 1, 2, or 3. Other values will result in the function returning ` false ` .
358423- ** uint8_t getResolution()** : Returns the currently set resolution (cached value).
359424
360425Datasheet SHT20 Table 8: Resolution settings
@@ -366,6 +431,7 @@ Datasheet SHT20 Table 8: Resolution settings
366431| 2 | 10 bit | 13 bit |
367432| 3 | 11 bit | 11 bit |
368433
434+
369435Datasheet SHT20 Table 7: Measurement timing (milliseconds) vs. observed real-world measurements.
370436(See details at https://github.com/RobTillaart/SHT2x/pull/11 )
371437
0 commit comments