diff --git a/README.rst b/README.rst index 6d972f2..5822bd9 100644 --- a/README.rst +++ b/README.rst @@ -92,20 +92,24 @@ For humidity compensated raw gas and voc index readings, we'll need a secondary humidity = bme280.relative_humidity # For compensated raw gas readings - compensated_raw_gas = sgp.measure_raw(temperature = temperature, relative_humidity = humidity) - - time.sleep(1) + """ + compensated_raw_gas = sgp.measure_raw( + temperature=temperature, relative_humidity=humidity + ) + print("Raw Data:", compensated_raw_gas) + """ # For Compensated voc index readings - voc_index = sgp.measure_index(temperature = temperature, relative_humidity = humidity) + voc_index = sgp.measure_index( + temperature=temperature, relative_humidity=humidity) - print(compensated_raw_gas) - print(voc_index) + print("VOC Index:", voc_index) print("") time.sleep(1) - It may take several minutes for the VOC index to start changing as it calibrates the baseline readings. +The voc algorithm expects a 1 hertz sampling rate. Run `measure_index()` once per second. + Contributing ============ diff --git a/adafruit_sgp40/voc_algorithm.py b/adafruit_sgp40/voc_algorithm.py index 3106fa2..dfc8e73 100644 --- a/adafruit_sgp40/voc_algorithm.py +++ b/adafruit_sgp40/voc_algorithm.py @@ -11,6 +11,7 @@ * Author(s): yangfeng """ +from micropython import const _VOCALGORITHM_SAMPLING_INTERVAL = const(1) _VOCALGORITHM_INITIAL_BLACKOUT = const(45) diff --git a/examples/sgp40_indextest.py b/examples/sgp40_indextest.py index 5d9dd4d..cef744e 100644 --- a/examples/sgp40_indextest.py +++ b/examples/sgp40_indextest.py @@ -18,18 +18,19 @@ humidity = bme280.relative_humidity # For compensated raw gas readings + """ compensated_raw_gas = sgp.measure_raw( temperature=temperature, relative_humidity=humidity ) - - time.sleep(1) + print("Raw Data:", compensated_raw_gas) + """ # For Compensated voc index readings + # The algorithm expects a 1 hertz sampling rate. Run "measure index" once per second. # It may take several minutes for the VOC index to start changing # as it calibrates the baseline readings. voc_index = sgp.measure_index(temperature=temperature, relative_humidity=humidity) - print("Raw Data:", compensated_raw_gas) print("VOC Index:", voc_index) print("") time.sleep(1)