8000 created properties for tvoc, eco2. verified on hardware. changed exam… · alexmrqt/micropython-sgp30@627879d · GitHub
[go: up one dir, main page]

Skip to content

Commit

Permalink
created properties for tvoc, eco2. verified on hardware. changed exam…
Browse files Browse the repository at this point in the history
…ple to reflect modifications
  • Loading branch information
brentru committed May 29, 2018
1 parent 45cd757 commit 627879d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
33 changes: 33 additions & 0 deletions adafruit_sgp30.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,39 @@ def __init__(self, i2c, address=_SGP30_DEFAULT_I2C_ADDR):
raise RuntimeError('SGP30 Not detected')
self.iaq_init()

self._co2eq = None # pylint: disable=invalid-name
self._tvoc = None # pylint: disable=invalid-name
self._tvoc_base = None # pylint: disable=invalid-name
self._co2eq_base = None # pylint: disable=invalid-name


@property
def tvoc(self): # pylint: disable=invalid-name
"""Total Volatile Organic Compound in parts per billion."""
self._tvoc = self.iaq_measure()[1]
return self._tvoc


@property
def tvoc_base(self): #pylint: disable=invalid-name
"""Total Volatile Organic Compound baseline value"""
self._tvoc_base = self.get_iaq_baseline()[1]
return self._tvoc_base


@property
def co2eq(self): #pylint: disable=invalid-name
"""Carbon Dioxide Equivalent in parts per million"""
self._co2eq = self.iaq_measure()[0]
return self._co2eq


@property
def co2eq_base(self): #pylint: disable=invalid-name
"""Carbon Dioxide Equivalent baseline value"""
self._co2eq_base = self.get_iaq_baseline()[0]
return self._co2eq_base

def iaq_init(self):
"""Initialize the IAQ algorithm"""
# name, command, signals, delay
Expand Down
5 changes: 3 additions & 2 deletions examples/sgp30_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@

while True:
co2eq, tvoc = sgp30.iaq_measure()
print("CO2eq = %d ppm \t TVOC = %d ppb" % (co2eq, tvoc))
print("co2eq = %d ppm \t tvoc = %d ppb" % (sgp30.co2eq, sgp30.tvoc))
time.sleep(1)
elapsed_sec += 1
if elapsed_sec > 10:
elapsed_sec = 0
co2eq_base, tvoc_base = sgp30.get_iaq_baseline()
print("**** Baseline values: CO2eq = 0x%x, TVOC = 0x%x" % (co2eq_base, tvoc_base))
print("**** Baseline values: co2eq = 0x%x, tvoc = 0x%x"
% (sgp30.co2eq_base, sgp30.tvoc_base))

0 comments on commit 627879d

Please sign in to comment.
0