@@ -18,19 +18,19 @@ Relates to the SHT85 library - https://github.com/RobTillaart/SHT85
18
18
19
19
## Description
20
20
21
- The SHT3x family of sensors should work up to 1 MHz I2C
21
+ The SHT3x family of sensors should work up to 1 MHz I2C.
22
22
23
- This library should also work for SHT30 and SHT35 but these are
23
+ This library should also work for SHT30 and SHT35 but these are
24
24
not tested yet.
25
25
26
26
Accuracy table
27
27
28
- | SENSOR | Temperature | Humidity |
29
- | :--------:| :-------------:| :----------:|
30
- | SHT30 | ~ 0.3 | 2.0 |
31
- | SHT31 | ~ 0.3 | 1.5 |
32
- | SHT35 | ~ 0.2 | 1.5 |
33
- | SHT85 | ~ 0.2 | 1.5 |
28
+ | Sensor | Temperature | Humidity | Verified }
29
+ | :--------:| :-------------:| :----------:| :----------: |
30
+ | SHT30 | ~ 0.3° | 2.0% | N |
31
+ | SHT31 | ~ 0.3° | 1.5% | Y |
32
+ | SHT35 | ~ 0.2° | 1.5% | N |
33
+ | SHT85 | ~ 0.2° | 1.5% | Y |
34
34
35
35
36
36
An elaborated library for the SHT31 sensor can be found here
@@ -40,7 +40,25 @@ A derived class for using the SHT31 sensor with SoftWire (soft I2C) can be found
40
40
- https://github.com/RobTillaart/SHT31_SW
41
41
42
42
43
- #### 0.5.0 Breaking change
43
+ ### I2C multiplexing
44
+
45
+ Sometimes you need to control more devices than possible with the default
46
+ address range the device provides.
47
+ This is possible with an I2C multiplexer e.g. TCA9548 which creates up
48
+ to eight channels (think of it as I2C subnets) which can use the complete
49
+ address range of the device.
50
+
51
+ Drawback of using a multiplexer is that it takes more administration in
52
+ your code e.g. which device is on which channel.
53
+ This will slow down the access, which must be taken into account when
54
+ deciding which devices are on which channel.
55
+ Also note that switching between channels will slow down other devices
56
+ too if they are behind the multiplexer.
57
+
58
+ - https://github.com/RobTillaart/TCA9548
59
+
60
+
61
+ ### 0.5.0 Breaking change
44
62
45
63
Version 0.5.0 introduced a breaking change.
46
64
You cannot set the pins in ** begin()** any more.
@@ -49,12 +67,32 @@ The user has to call **Wire.begin()** and can optionally set the Wire pins
49
67
before calling ** begin()** .
50
68
51
69
52
- #### Related
70
+ ### Related
53
71
54
- - https://github.com/RobTillaart/SHT31
55
- - https://github.com/RobTillaart/SHT31_SW
56
- - https://github.com/RobTillaart/SHT31_SWW
57
- - https://github.com/RobTillaart/SHT85
72
+ SHT series temperature sensors
73
+
74
+ - https://github.com/RobTillaart/SHT2x
75
+ - https://github.com/RobTillaart/SHT31 Sensirion humidity / temperature sensor
76
+ - https://github.com/RobTillaart/SHT31_SW = softWire based I2C.
77
+ - https://github.com/RobTillaart/SHT31_SWW = softWire based I2C.
78
+ - https://github.com/RobTillaart/SHT85 Sensirion humidity / temperature sensor
79
+ - https://github.com/RobTillaart/tinySHT2x
80
+
81
+ Other temperature sensors
82
+
83
+ - https://github.com/RobTillaart/DHTNew DHT11/22 etc
84
+ - https://github.com/RobTillaart/DHTStable DHT11/22 etc
85
+ - https://github.com/RobTillaart/DHT_Simulator
86
+ - https://github.com/RobTillaart/DS18B20_INT OneWire temperature sensor
87
+ - https://github.com/RobTillaart/DS18B20_RT OneWire temperature sensor
88
+
89
+ An elaborated library for the SHT31 sensor can be found here
90
+ - https://github.com/hawesg/SHT31D_Particle_Photon_ClosedCube
91
+
92
+ Other, including Dewpoint, heatindex, related functions and conversions.
93
+
94
+ - https://www.kandrsmith.org/RJS/Misc/Hygrometers/calib_many.html (interesting)
95
+ - https://github.com/RobTillaart/Temperature (conversions, dewPoint, heat index etc.)
58
96
59
97
60
98
## Interface
@@ -63,7 +101,7 @@ before calling **begin()**.
63
101
#include " SHT31.h"
64
102
```
65
103
66
- #### Constructor
104
+ ### Constructor
67
105
68
106
- ** SHT31(uint8_t address = SHT_DEFAULT_ADDRESS, TwoWire \* wire = &Wire)** constructor.
69
107
Optional select address and the I2C bus (Wire, Wire1 etc).
@@ -73,16 +111,29 @@ Returns false if device address is incorrect or device cannot be reset.
73
111
- ** uint8_t getAddress()** returns address set in the constructor.
74
112
75
113
76
- #### Read
114
+ ### Read
77
115
78
116
- ** bool read(bool fast = true)** blocks 4 (fast) or 15 (slow) milliseconds + actual read + math.
79
117
Does read both the temperature and humidity.
80
- - ** uint16_t readStatus()** details see datasheet and ** Status fields** below.
118
+
119
+ Meta information about the sensor.
120
+
121
+ - ** uint16_t readStatus()** returns bit mask, details see ** Status fields** below (and datasheet).
122
+ - ** bool clearStatus()** clear status register, see ** Status fields** below.
81
123
- ** uint32_t lastRead()** in milliSeconds since start of program.
82
- - ** bool reset(bool hard = false)** resets the sensor, soft reset by default. Returns false if it fails.
124
+ - ** bool reset(bool hard = false)** resets the sensor, soft reset by default. Returns false if call fails.
125
+
126
+ The following functions will return the same value until a new ** read()** call (or async) is made.
127
+
83
128
- ** float getHumidity()** computes the relative humidity in % based on the latest raw reading, and returns it.
84
129
- ** float getTemperature()** computes the temperature in °C based on the latest raw reading, and returns it.
85
130
- ** float getFahrenheit()** computes the temperature in °F based on the latest raw reading, and returns it..
131
+
132
+
133
+ The ** getRawHumidity()** and ** getRawTemperature()** can be used to minimize storage or communication as the data type is 50% smaller.
134
+ Another application is faster comparison with a previous value or threshold.
135
+ However comparisons are quite fast.
136
+
86
137
- ** uint16_t getRawHumidity()** returns the raw two-byte representation of humidity directly from the sensor.
87
138
- ** uint16_t getRawTemperature()** returns the raw two-byte representation of temperature directly from the sensor.
88
139
@@ -91,26 +142,27 @@ If you're worried about the extra cycles, you should make sure to cache these va
91
142
you've performed a new reading.
92
143
93
144
94
- #### Error interface
145
+ ### Error interface
95
146
96
147
- ** int getError()** returns last set error flag and clear it.
97
- Be sure to clear the error flag by calling ** getError()** before calling any command as the error flag could be from a previous command.
148
+ Be sure to clear the error flag by calling ** getError()** before calling
149
+ any command as the error flag could be from a previous command.
98
150
99
- | Error | Symbolic | Description |
100
- | :-------:| :----------------------------| :------------------------------|
101
- | 0x00 | SHT31_OK | no error |
102
- | 0x81 | SHT31_ERR_WRITECMD | I2C write failed |
103
- | 0x82 | SHT31_ERR_READBYTES | I2C read failed |
104
- | 0x83 | SHT31_ERR_HEATER_OFF | Could not switch off heater |
105
- | 0x84 | SHT31_ERR_NOT_CONNECT | Could not connect |
106
- | 0x85 | SHT31_ERR_CRC_TEMP | CRC error in temperature |
107
- | 0x86 | SHT31_ERR_CRC_HUM | CRC error in humidity |
108
- | 0x87 | SHT31_ERR_CRC_STATUS | CRC error in status field |
109
- | 0x88 | SHT31_ERR_HEATER_COOLDOWN | Heater need to cool down |
110
- | 0x88 | SHT31_ERR_HEATER_ON | Could not switch on heater |
151
+ | Error | Symbolic | Description |
152
+ | :-------:| :----------------------------| :------------------------------- |
153
+ | 0x00 | SHT31_OK | no error |
154
+ | 0x81 | SHT31_ERR_WRITECMD | I2C write failed |
155
+ | 0x82 | SHT31_ERR_READBYTES | I2C read failed |
156
+ | 0x83 | SHT31_ERR_HEATER_OFF | Could not switch off heater |
157
+ | 0x84 | SHT31_ERR_NOT_CONNECT | Could not connect |
158
+ | 0x85 | SHT31_ERR_CRC_TEMP | CRC error in temperature |
159
+ | 0x86 | SHT31_ERR_CRC_HUM | CRC error in humidity |
160
+ | 0x87 | SHT31_ERR_CRC_STATUS | CRC error in status field |
161
+ | 0x88 | SHT31_ERR_HEATER_COOLDOWN | Heater need to cool down |
162
+ | 0x89 | SHT31_ERR_HEATER_ON | Could not switch on heater |
111
163
112
164
113
- #### Heater interface
165
+ ### Heater interface
114
166
115
167
** WARNING:** Do not use heater for long periods.
116
168
@@ -121,22 +173,21 @@ within **180** seconds of the last switch off. Note: this guarding is not reboot
121
173
** WARNING:** The user is responsible to switch the heater off manually!
122
174
123
175
The class does ** NOT** do this automatically.
124
- Switch off the heater by directly calling ** heatOff()** or indirectly by calling ** isHeaterOn()** .
176
+ Switch off the heater by explicitly calling ** heatOff()** or indirectly by calling ** isHeaterOn()** .
125
177
126
178
- ** void setHeatTimeout(uint8_t seconds)** Set the time out of the heat cycle.
127
179
This value is truncated to max 180 seconds.
128
- - ** uint8_t getHeatTimeout
129
- - ** bool heatOn()** switches heat cycle on if not already on.
130
- Returns false if fails, setting error to ** SHT31_ERR_HEATER_COOLDOWN**
180
+ - ** uint8_t getHeatTimeout() ** returns the value set.
181
+ - ** bool heatOn()** switches the heat cycle on if not already on.
182
+ Returns false if the call fails, setting error to ** SHT31_ERR_HEATER_COOLDOWN**
131
183
or to ** SHT31_ERR_HEATER_ON** .
132
- - ** bool heatOff()** switches heat cycle off.
184
+ - ** bool heatOff()** switches the heat cycle off.
133
185
Returns false if fails, setting error to ** SHT31_ERR_HEATER_OFF** .
134
- - ** bool isHeaterOn()** is the sensor still in heating cycle? replaces ** heatUp()** .
135
- Will switch the heater off if max heating time has passed.
136
- - ** bool heatUp()** will be obsolete in the future. replaced by ** isHeaterOn()**
186
+ - ** bool isHeaterOn()** is the sensor still in a heating cycle? Replaces ** heatUp()** .
187
+ Will switch the heater off if maximum heating time has passed.
137
188
138
189
139
- #### Async interface
190
+ ### Async interface
140
191
141
192
See async example for usage
142
193
@@ -160,7 +211,7 @@ Returns false if reading fails or in case of a CRC failure.
160
211
| | | 1 | alert
161
212
| 10 | Temperature tracking alert | 0 | no alert - default
162
213
| | | 1 | alert
163
- | 9-5 | Reserved | 00000 |
214
+ | 9-5 | Reserved | 00000 | reserved
164
215
| 4 | System reset detected | 0 | no reset since last clear status register command
165
216
| | | 1 | reset detected (hard or soft reset command or supply fail) - default
166
217
| 3-2 | Reserved | 00 |
@@ -169,17 +220,15 @@ Returns false if reading fails or in case of a CRC failure.
169
220
| 0 | Write data checksum status | 0 | checksum of last write correct
170
221
| | | 1 | checksum of last write transfer failed
171
222
172
-
173
-
174
- ## Operation
175
-
176
- See examples.
223
+ ** bool clearStatus()** clears 15, 11, 10 and 4.
177
224
178
225
179
226
## Future
180
227
181
228
#### Must
182
229
230
+ - improve documentation.
231
+ - reorder interface
183
232
- keep in sync with SHT85 library.
184
233
- keep derived SHT31_SW builds green
185
234
0 commit comments