8000 address https://github.com/adafruit/Adafruit_Sensor/issues/48 · adafruit/Adafruit_Sensor@1f527eb · GitHub
[go: up one dir, main page]

Skip to content

Commit 1f527eb

Browse files
committed
address #48
1 parent a902f89 commit 1f527eb

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

Adafruit_Sensor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ void Adafruit_Sensor::printSensorDetails(void) {
9797
case SENSOR_TYPE_GAS_RESISTANCE:
9898
Serial.print(F("Gas Resistance (ohms)"));
9999
break;
100+
case SENSOR_TYPE_UNITLESS_PERCENT:
101+
Serial.print(F("Unitless Percent (%)"));
102+
break;
100103
}
101104

102105
Serial.println();

Adafruit_Sensor.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ typedef enum {
7979
SENSOR_TYPE_PM25_ENV = (27),
8080
SENSOR_TYPE_PM100_ENV = (28),
8181
SENSOR_TYPE_GAS_RESISTANCE = (29),
82+
SENSOR_TYPE_LUX = (30),
83+
SENSOR_TYPE_UNITLESS_PERCENT = (31)
8284
} sensors_type_t;
8385

8486
/** struct sensors_vec_s is used to return a vector in a common format. */
@@ -132,7 +134,7 @@ typedef struct {
132134
int32_t reserved0; /**< reserved */
133135
int32_t timestamp; /**< time is in milliseconds */
134136
union {
135-
float data[4]; ///< Raw data
137+
float data[4]; ///< Raw data */
136138
sensors_vec_t acceleration; /**< acceleration values are in meter per second
137139
per second (m/s^2) */
138140
sensors_vec_t
@@ -166,10 +168,12 @@ typedef struct {
166168
million (ppm) */
167169
float pm100_env; /**< Environmental Particulate Matter 100 in parts per
168170
million (ppm) */
169-
float gas_resistance; /**< Proportional to the amount of VOC particles in
170-
the air (Ohms) */
171-
sensors_color_t color; /**< color in RGB component values */
172-
}; ///< Union for the wide ranges of data we can carry
171+
float gas_resistance; /**< Proportional to the amount of VOC particles in
172+
the air (Ohms) */
173+
float lux; /**< SI lux (Lux) */
174+
float unitless_percent; /**<Percentage, unit-less (%) */
175+
sensors_color_t color; /**< color in RGB component values */
176+
}; ///< Union for the wide ranges of data we can carry
173177
} sensors_event_t;
174178

175179
/* Sensor details (40 bytes) */

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ typedef struct
161161
float pm25_env,
162162
float pm100_env,
163163
float gas_resistance,
164+
float unitless_percent,
164165
sensors_color_t color;
165166
};
166167
} sensors_event_t;
@@ -189,7 +190,7 @@ Calling this function will provide some basic information about the sensor (the
189190

190191
## Standardised SI values for `sensors_event_t`
191192

192-
A key part of the abstraction layer is the standardisation of values on SI units of a particular scale, which is accomplished via the data[4] union in sensors\_event\_t above. This 16 byte union includes fields for each main sensor type, and uses the following SI units and scales:
193+
A key part of the abstraction layer is the standardization of values on SI units of a particular scale, which is accomplished via the data[4] union in sensors\_event\_t above. This 16 byte union includes fields for each main sensor type, and uses the following SI units and scales:
193194

194195
- **acceleration**: values are in **meter per second per second** (m/s^2)
195196
- **magnetic**: values are in **micro-Tesla** (uT)
@@ -215,12 +216,13 @@ A key part of the abstraction layer is the standardisation of values on SI units
215216
- **pm25_env**: values are in **parts per million** (ppm)
216217
- **pm100_env**: values are in **parts per million** (ppm)
217218
- **gas_resistance**: values are in **ohms**
219+
- **unitless_percent**: values are in **%**
218220

219221
## The Unified Driver Abstraction Layer in Practice ##
220222

221223
Using the unified sensor abstraction layer is relatively easy once a compliant driver has been created.
222224

223-
Every compliant sensor can now be read using a single, well-known 'type' (sensors\_event\_t), and there is a standardised way of interrogating a sensor about its specific capabilities (via sensor\_t).
225+
Every compliant sensor can now be read using a single, well-known 'type' (sensors\_event\_t), and there is a standardized way of interrogating a sensor about its specific capabilities (via sensor\_t).
224226

225227
An example of reading the [TSL2561](https://github.com/adafruit/Adafruit_TSL2561) light sensor can be seen below:
226228

0 commit comments

Comments
 (0)
0