@@ -18,19 +18,19 @@ Relates to the SHT85 library - https://github.com/RobTillaart/SHT85
1818
1919## Description
2020
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.
2222
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
2424not tested yet.
2525
2626Accuracy table
2727
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 |
3434
3535
3636An 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
4040- https://github.com/RobTillaart/SHT31_SW
4141
4242
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
4462
4563Version 0.5.0 introduced a breaking change.
4664You 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
4967before calling ** begin()** .
5068
5169
52- #### Related
70+ ### Related
5371
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.)
5896
5997
6098## Interface
@@ -63,7 +101,7 @@ before calling **begin()**.
63101#include " SHT31.h"
64102```
65103
66- #### Constructor
104+ ### Constructor
67105
68106- ** SHT31(uint8_t address = SHT_DEFAULT_ADDRESS, TwoWire \* wire = &Wire)** constructor.
69107Optional 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.
73111- ** uint8_t getAddress()** returns address set in the constructor.
74112
75113
76- #### Read
114+ ### Read
77115
78116- ** bool read(bool fast = true)** blocks 4 (fast) or 15 (slow) milliseconds + actual read + math.
79117Does 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.
81123- ** 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+
83128- ** float getHumidity()** computes the relative humidity in % based on the latest raw reading, and returns it.
84129- ** float getTemperature()** computes the temperature in °C based on the latest raw reading, and returns it.
85130- ** 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+
86137- ** uint16_t getRawHumidity()** returns the raw two-byte representation of humidity directly from the sensor.
87138- ** uint16_t getRawTemperature()** returns the raw two-byte representation of temperature directly from the sensor.
88139
@@ -91,26 +142,27 @@ If you're worried about the extra cycles, you should make sure to cache these va
91142you've performed a new reading.
92143
93144
94- #### Error interface
145+ ### Error interface
95146
96147- ** 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.
98150
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 |
111163
112164
113- #### Heater interface
165+ ### Heater interface
114166
115167** WARNING:** Do not use heater for long periods.
116168
@@ -121,22 +173,21 @@ within **180** seconds of the last switch off. Note: this guarding is not reboot
121173** WARNING:** The user is responsible to switch the heater off manually!
122174
123175The 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()** .
125177
126178- ** void setHeatTimeout(uint8_t seconds)** Set the time out of the heat cycle.
127179This 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**
131183or to ** SHT31_ERR_HEATER_ON** .
132- - ** bool heatOff()** switches heat cycle off.
184+ - ** bool heatOff()** switches the heat cycle off.
133185Returns 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.
137188
138189
139- #### Async interface
190+ ### Async interface
140191
141192See async example for usage
142193
@@ -160,7 +211,7 @@ Returns false if reading fails or in case of a CRC failure.
160211| | | 1 | alert
161212| 10 | Temperature tracking alert | 0 | no alert - default
162213| | | 1 | alert
163- | 9-5 | Reserved | 00000 |
214+ | 9-5 | Reserved | 00000 | reserved
164215| 4 | System reset detected | 0 | no reset since last clear status register command
165216| | | 1 | reset detected (hard or soft reset command or supply fail) - default
166217| 3-2 | Reserved | 00 |
@@ -169,17 +220,15 @@ Returns false if reading fails or in case of a CRC failure.
169220| 0 | Write data checksum status | 0 | checksum of last write correct
170221| | | 1 | checksum of last write transfer failed
171222
172-
173-
174- ## Operation
175-
176- See examples.
223+ ** bool clearStatus()** clears 15, 11, 10 and 4.
177224
178225
179226## Future
180227
181228#### Must
182229
230+ - improve documentation.
231+ - reorder interface
183232- keep in sync with SHT85 library.
184233- keep derived SHT31_SW builds green
185234
0 commit comments