From 1461df52b356d239094264cca454bb8354675f15 Mon Sep 17 00:00:00 2001 From: Andrew VanVlack Date: Sun, 5 Sep 2021 16:36:05 -0700 Subject: [PATCH 1/2] add const import --- adafruit_sgp40/voc_algorithm.py | 1 + 1 file changed, 1 insertion(+) 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) From d74daa060ea8ac0f61670aaeb6ad332728387227 Mon Sep 17 00:00:00 2001 From: Andrew VanVlack Date: Sun, 5 Sep 2021 16:58:37 -0700 Subject: [PATCH 2/2] fixed example 1 hertz --- README.rst | 18 +++++++++++------- examples/sgp40_indextest.py | 7 ++++--- 2 files changed, 15 insertions(+), 10 deletions(-) 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/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)