From 7d15c6fd8f4c6210276ce56027604e6a22203e4f Mon Sep 17 00:00:00 2001 From: tyeth Date: Thu, 15 Dec 2022 21:56:46 +0000 Subject: [PATCH 1/3] Adds NOx and VOC index to sensor types What is sensirion's NOx index? https://sensirion.com/media/documents/9F289B95/6294DFFC/Info_Note_NOx_Index.pdf Resolve https://github.com/adafruit/Wippersnapper_Components/issues/103 --- Adafruit_Sensor.cpp | 6 ++++++ Adafruit_Sensor.h | 6 +++++- README.md | 12 +++++++++++- library.properties | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Adafruit_Sensor.cpp b/Adafruit_Sensor.cpp index e97aa46..a5a6d4e 100644 --- a/Adafruit_Sensor.cpp +++ b/Adafruit_Sensor.cpp @@ -64,6 +64,12 @@ void Adafruit_Sensor::printSensorDetails(void) { case SENSOR_TYPE_TVOC: Serial.print(F("Total Volatile Organic Compounds (ppb)")); break; + case SENSOR_TYPE_VOC_INDEX: + Serial.print(F("Volatile Organic Compounds (Index)")); + break; + case SENSOR_TYPE_NOX_INDEX: + Serial.print(F("Nitrogen Oxides (Index)")); + break; } Serial.println(); diff --git a/Adafruit_Sensor.h b/Adafruit_Sensor.h index 432cfa6..0054af8 100755 --- a/Adafruit_Sensor.h +++ b/Adafruit_Sensor.h @@ -67,7 +67,9 @@ typedef enum { SENSOR_TYPE_VOLTAGE = (15), SENSOR_TYPE_CURRENT = (16), SENSOR_TYPE_COLOR = (17), - SENSOR_TYPE_TVOC = (18) + SENSOR_TYPE_TVOC = (18), + SENSOR_TYPE_VOC_INDEX = (19), + SENSOR_TYPE_NOX_INDEX = (20) } sensors_type_t; /** struct sensors_vec_s is used to return a vector in a common format. */ @@ -136,6 +138,8 @@ typedef struct { float current; /**< current in milliamps (mA) */ float voltage; /**< voltage in volts (V) */ float tvoc; /**< Total Volatile Organic Compounds, in ppb */ + int32_t voc_index; /**< VOC (Volatile Organic Compound) index where 100 is normal */ + int32_t nox_index; /**< NOx (Nitrogen Oxides) index where 100 is normal */ sensors_color_t color; /**< color in RGB component values */ }; ///< Union for the wide ranges of data we can carry } sensors_event_t; diff --git a/README.md b/README.md index 18839d6..293bd4b 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,10 @@ typedef enum SENSOR_TYPE_AMBIENT_TEMPERATURE = (13), SENSOR_TYPE_VOLTAGE = (15), SENSOR_TYPE_CURRENT = (16), - SENSOR_TYPE_COLOR = (17) + SENSOR_TYPE_COLOR = (17), + SENSOR_TYPE_TVOC = (18), + SENSOR_TYPE_VOC_INDEX = (19), + SENSOR_TYPE_NOX_INDEX = (20) } sensors_type_t; ``` @@ -137,6 +140,9 @@ typedef struct float relative_humidity; float current; float voltage; + float tvoc; + int32_t voc_index; + int32_t nox_index; sensors_color_t color; }; } sensors_event_t; @@ -179,6 +185,10 @@ A key part of the abstraction layer is the standardisation of values on SI units - **current**: values are in **milliamps** (mA) - **voltage**: values are in **volts** (V) - **color**: values are in 0..1.0 RGB channel luminosity and 32-bit RGBA format +- **tvoc**: values are in **parts per billion** (ppb) +- **voc_index**: values are an **index** from 1-500 with 100 being normal +- **nox_index**: values are an **index** from 1-500 with 100 being normal + ## The Unified Driver Abstraction Layer in Practice ## diff --git a/library.properties b/library.properties index d2d3af1..019fd7a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Adafruit Unified Sensor -version=1.1.6 +version=1.1.7 author=Adafruit maintainer=Adafruit sentence=Required for all Adafruit Unified Sensor based libraries. From ab0e94cd8447c58a8c35d7d79c86fba67ce6369e Mon Sep 17 00:00:00 2001 From: Tyeth Gundry Date: Thu, 15 Dec 2022 23:10:12 +0000 Subject: [PATCH 2/3] clang tidy --- Adafruit_Sensor.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Adafruit_Sensor.h b/Adafruit_Sensor.h index 0054af8..c18489f 100755 --- a/Adafruit_Sensor.h +++ b/Adafruit_Sensor.h @@ -138,10 +138,11 @@ typedef struct { float current; /**< current in milliamps (mA) */ float voltage; /**< voltage in volts (V) */ float tvoc; /**< Total Volatile Organic Compounds, in ppb */ - int32_t voc_index; /**< VOC (Volatile Organic Compound) index where 100 is normal */ - int32_t nox_index; /**< NOx (Nitrogen Oxides) index where 100 is normal */ - sensors_color_t color; /**< color in RGB component values */ - }; ///< Union for the wide ranges of data we can carry + int32_t voc_index; /**< VOC (Volatile Organic Compound) index where 100 is + normal */ + int32_t nox_index; /**< NOx (Nitrogen Oxides) index where 100 is normal */ + sensors_color_t color; /**< color in RGB component values */ + }; ///< Union for the wide ranges of data we can carry } sensors_event_t; /* Sensor details (40 bytes) */ From d3d2fd776bd709cd92f9f68caa51df8cdfcf1fa2 Mon Sep 17 00:00:00 2001 From: tyeth Date: Tue, 20 Dec 2022 17:25:10 +0000 Subject: [PATCH 3/3] change indexes to floats --- Adafruit_Sensor.h | 7 ++++--- README.md | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Adafruit_Sensor.h b/Adafruit_Sensor.h index c18489f..b0169d8 100755 --- a/Adafruit_Sensor.h +++ b/Adafruit_Sensor.h @@ -138,9 +138,10 @@ typedef struct { float current; /**< current in milliamps (mA) */ float voltage; /**< voltage in volts (V) */ float tvoc; /**< Total Volatile Organic Compounds, in ppb */ - int32_t voc_index; /**< VOC (Volatile Organic Compound) index where 100 is - normal */ - int32_t nox_index; /**< NOx (Nitrogen Oxides) index where 100 is normal */ + float voc_index; /**< VOC (Volatile Organic Compound) index where 100 is + normal (unitless) */ + float nox_index; /**< NOx (Nitrogen Oxides) index where 100 is normal + (unitless) */ sensors_color_t color; /**< color in RGB component values */ }; ///< Union for the wide ranges of data we can carry } sensors_event_t; diff --git a/README.md b/README.md index 293bd4b..1e87bed 100644 --- a/README.md +++ b/README.md @@ -141,8 +141,8 @@ typedef struct float current; float voltage; float tvoc; - int32_t voc_index; - int32_t nox_index; + float voc_index; + float nox_index; sensors_color_t color; }; } sensors_event_t;