diff --git a/adafruit_sgp30.py b/adafruit_sgp30.py old mode 100644 new mode 100755 index c7b7731..8441276 --- a/adafruit_sgp30.py +++ b/adafruit_sgp30.py @@ -75,6 +75,31 @@ def __init__(self, i2c, address=_SGP30_DEFAULT_I2C_ADDR): raise RuntimeError('SGP30 Not detected') self.iaq_init() + + @property + def tvoc(self): + """Total Volatile Organic Compound in parts per billion.""" + return self.iaq_measure()[1] + + + @property + def baseline_tvoc(self): + """Total Volatile Organic Compound baseline value""" + return self.get_iaq_baseline()[1] + + + @property + def co2eq(self): + """Carbon Dioxide Equivalent in parts per million""" + return self.iaq_measure()[0] + + + @property + def baseline_co2eq(self): + """Carbon Dioxide Equivalent baseline value""" + return self.get_iaq_baseline()[0] + + def iaq_init(self): """Initialize the IAQ algorithm""" # name, command, signals, delay diff --git a/examples/sgp30_simpletest.py b/examples/sgp30_simpletest.py index fb9c44b..b209b17 100644 --- a/examples/sgp30_simpletest.py +++ b/examples/sgp30_simpletest.py @@ -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.baseline_co2eq, sgp30.baseline_tvoc))