Arduino library for the SHT2x, HTU2x and Si70xx temperature and humidity sensors.
This library is not tested extensively yet. It should work for SHT20, SHT21 and SHT25 but these are not tested yet. The SHT2x family of sensors should work up to 400 KHz I2C.
Furthermore there are a number of compatible sensors, these are not tested either.
Sensor | Temperature accuracy | Humidity accuracy |
---|---|---|
SHT20 | ~0.3 | 3.0 |
SHT21 | ~0.3 | 3.0 |
SHT25 | ~0.3 | 1.8 |
HTU20 | ||
HTU21 | ||
Si7013 | ||
Si7020 | ||
Si7021 |
All sensors in this family of sensors have address 0x40 (64 decimal). If you want to use more on one I2C bus one needs either an I2C multiplexer or one should switch sensors on/off like the select in SPI communication.
All classes below are derived from SHT2x class.
Note that the temperature and humidity values are recalculated on every call to getHumidity() and getTemperature(). If you're worried about the extra cycles, you should make sure to cache these values or only request them after you've performed a new read().
Value | Symbolic | Description | Notes |
---|---|---|---|
0x00 | SHT2x_OK | no error | |
0x81 | SHT2x_ERR_WRITECMD | I2C write failed | |
0x82 | SHT2x_ERR_READBYTES | I2C read failed | |
0x83 | SHT2x_ERR_HEATER_OFF | Could not switch off heater | |
0x84 | SHT2x_ERR_NOT_CONNECT | Could not connect | |
0x85 | SHT2x_ERR_CRC_TEMP | CRC error in temperature | |
0x86 | SHT2x_ERR_CRC_HUM | CRC error in humidity | |
0x87 | SHT2x_ERR_CRC_STATUS | CRC error in status field | not used |
0x88 | SHT2x_ERR_HEATER_COOLDOWN | Heater need to cool down | |
0x88 | SHT2x_ERR_HEATER_ON | Could not switch on heater |
Note: the HTU20 / HTU21 classes share the same error codes.
WARNING: Do not use heater for long periods.
Datasheet SHT2x does not mention max time so the maximum time of the SHT3x series is assumed here.
Use the heater for max 180 seconds, and let it cool down 180 seconds = 3 minutes. THe library guards the cool down time by preventing switching the heater on within 180 seconds of the last switch off. Note: this guarding is not reboot persistent.
WARNING: The user is responsible to switch the heater off manually!
The class does NOT do this automatically.
Switch off the heater by directly calling heatOff() or indirectly by calling isHeaterOn().
From HTU20 datasheet
bits | value | meaning |
---|---|---|
00 | 0 | open circuit |
01 | 1 | temperature reading |
10 | 2 | humidity reading |
11 | 3 | closed circuit |
See examples
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。