Sfoglia il codice sorgente

Merge pull request #41 from tyeth/add-voc-nox-index

Adds NOx and VOC index to sensor types
Brent Rubell 3 anni fa
parent
commit
6ac3e2df0f
4 ha cambiato i file con 27 aggiunte e 5 eliminazioni
  1. 6 0
      Adafruit_Sensor.cpp
  2. 9 3
      Adafruit_Sensor.h
  3. 11 1
      README.md
  4. 1 1
      library.properties

+ 6 - 0
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();

+ 9 - 3
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,8 +138,12 @@ typedef struct {
     float current;           /**< current in milliamps (mA) */
     float voltage;           /**< voltage in volts (V) */
     float tvoc;              /**< Total Volatile Organic Compounds, in ppb */
-    sensors_color_t color;   /**< color in RGB component values */
-  };                         ///< Union for the wide ranges of data we can carry
+    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;
 
 /* Sensor details (40 bytes) */

+ 11 - 1
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;
+        float           voc_index;
+        float           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 ##
 

+ 1 - 1
library.properties

@@ -1,5 +1,5 @@
 name=Adafruit Unified Sensor
-version=1.1.6
+version=1.1.7
 author=Adafruit <info@adafruit.com>
 maintainer=Adafruit <info@adafruit.com>
 sentence=Required for all Adafruit Unified Sensor based libraries.