Skip to content

Commit a5b2858

Browse files
authored
Update adafruit_sgp30.py
set_iaq_humidity
1 parent 9d6b19f commit a5b2858

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

adafruit_sgp30.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ def set_iaq_baseline(self, eCO2, TVOC): # pylint: disable=invalid-name
129129
arr.append(self._generate_crc(arr))
130130
buffer += arr
131131
self._run_profile(["iaq_set_baseline", [0x20, 0x1e] + buffer, 0, 0.01])
132+
133+
def set_iaq_humidity(self, phum): # pylint: disable=invalid-name
134+
"""Set the humidity for eCO2 and TVOC compensation algorithm"""
135+
if phum == 0:
136+
raise RuntimeError('Invalid humidity')
137+
buffer = []
138+
for value in [phum]:
139+
arr = [value >> 8, value & 0xFF]
140+
arr.append(self._generate_crc(arr))
141+
buffer += arr
142+
self._run_profile(["iaq_set_humidity", [0x20, 0x61] + buffer, 0, 0.01])
132143

133144

134145
# Low level command functions

0 commit comments

Comments
 (0)