Skip to content

Commit bedde22

Browse files
committed
Added link to datasheet and learn guide, fixed some formatting, and clarified the temperature type for the celsius to ticks conversion
1 parent cc919c2 commit bedde22

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

adafruit_sgp40.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ class SGP40:
9191
# Lets quickly grab the humidity and temperature
9292
# temperature = bme280.temperature
9393
# humidity = bme280.relative_humidity
94-
# compensated_raw_gas = sgp.measure_raw(temperature=temperature, relative_humidity=humidity)
94+
# compensated_raw_gas = sgp.measure_raw(temperature=temperature,
95+
# relative_humidity=humidity)
9596
# temperature = temperature, relative_humidity = humidity)
9697
9798
@@ -109,6 +110,11 @@ class SGP40:
109110
Prolonged exposures outside of these ranges may reduce sensor performance, and
110111
the sensor must not be exposed towards condensing conditions at any time.
111112
113+
For more information see:
114+
https://www.sensirion.com/fileadmin/user_upload/customers/sensirion/Dokumente/9_Gas_Sensors/Datasheets/Sensirion_Gas_Sensors_Datasheet_SGP40.pdf
115+
and
116+
https://learn.adafruit.com/adafruit-sgp40
117+
112118
"""
113119

114120
def __init__(self, i2c, address=0x59):
@@ -160,7 +166,7 @@ def _reset(self):
160166
sleep(1)
161167

162168
@staticmethod
163-
def _temp_c_to_ticks(temperature):
169+
def _celsius_to_ticks(temperature):
164170
"""
165171
Converts Temperature in Celsius to 'ticks' which are an input parameter
166172
the sgp40 can use
@@ -217,7 +223,7 @@ def measure_raw(self, temperature=25, relative_humidity=50):
217223
_compensated_read_cmd = [0x26, 0x0F]
218224
humidity_ticks = self._relative_humidity_to_ticks(relative_humidity)
219225
humidity_ticks.append(self._generate_crc(humidity_ticks))
220-
temp_ticks = self._temp_c_to_ticks(temperature)
226+
temp_ticks = self._celsius_to_ticks(temperature)
221227
temp_ticks.append(self._generate_crc(temp_ticks))
222228
_cmd = _compensated_read_cmd + humidity_ticks + temp_ticks
223229
self._measure_command = bytearray(_cmd)

0 commit comments

Comments
 (0)