Skip to content

Commit a122a49

Browse files
committed
fixing resolutions
1 parent 0b99d4c commit a122a49

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

adafruit_htu31d.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ def measurements(self) -> Tuple[float, float]:
163163
i2c.write(self._buffer, end=1)
164164

165165
# wait conversion time
166-
time.sleep(0.02)
166+
# Changed as reading temp and hum at OS3 is 20.32 ms
167+
# See datasheet Table 5
168+
time.sleep(0.03)
167169

168170
self._buffer[0] = _HTU31D_READTEMPHUM
169171
with self.i2c_device as i2c:

examples/htu31d_setting_resolutions.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616
print("Temperature Resolution: ", htu.temp_resolution)
1717
print("Humidity Resolution: ", htu.humidity_resolution)
1818

19-
2019
# Setting the temperature resolution.
2120
# Possible values are "0.040", "0.025", "0.016" and "0.012"
22-
htu.temp_resolution = "0.016"
21+
htu.temp_resolution = "0.040"
2322

2423
# Setting the Relative Humidity resolution.
2524
# Possible values are "0.020%", "0.014%", "0.010%" and "0.007%"
26-
htu.humidity_resolution = "0.007%"
25+
htu.humidity_resolution = "0.020%"
2726

2827
print("Temperature Resolution: ", htu.temp_resolution)
2928
print("Humidity Resolution: ", htu.humidity_resolution)
@@ -33,16 +32,19 @@
3332

3433
while True:
3534
for humidity_resolution in hum_res:
35+
htu.humidity_resolution = humidity_resolution
3636
print(f"Current Humidity Resolution: {humidity_resolution}")
37-
for _ in range(3):
37+
for _ in range(2):
3838
print(f"Humidity: {htu.relative_humidity:.2f}")
3939
print(f"Temperature: {htu.temperature:.2f}")
4040
print("")
4141
time.sleep(0.5)
4242
for temperature_resolution in temp_res:
43+
htu.temp_resolution = temperature_resolution
4344
print(f"Current Temperature Resolution: {temperature_resolution}")
44-
for _ in range(3):
45+
for _ in range(2):
4546
print(f"Humidity: {htu.relative_humidity:.2f}")
4647
print(f"Temperature: {htu.temperature:.2f}")
4748
print("")
4849
time.sleep(0.5)
50+

0 commit comments

Comments
 (0)