CanAirIO Sensors Library 0.7.7
Generic sensor manager, abstratctions and bindings of multiple air sensors libraries
Sensors.hpp
1#ifndef Sensors_hpp
2#define Sensors_hpp
3
4#include <AHTxx.h>
5#include <AM232X.h>
6#include <Adafruit_BME280.h>
7#include <Adafruit_BME680.h>
8#include <Adafruit_BMP280.h>
9#include <Adafruit_SCD30.h>
10#include <Adafruit_SHT31.h>
11#include <Adafruit_Sensor.h>
12#include <Arduino.h>
13#include <DFRobot_MultiGasSensor.h>
14#include <MHZ19.h>
15#include <NOxGasIndexAlgorithm.h>
16#include <SensirionI2CScd4x.h>
17#include <SensirionI2CSen5x.h>
18#include <SensirionI2CSgp41.h>
19#include <SparkFun_Particle_Sensor_SN-GCJA5_Arduino_Library.h>
20#include <VOCGasIndexAlgorithm.h>
21#include <Wire.h>
22#include <cm1106_uart.h>
23#include <drivers/NoiseSlave.h>
24#include <drivers/PMS5003T.h>
25#include <drivers/geiger.h>
26#include <drivers/pm1006.h>
27#include <s8_uart.h>
28#include <sps30.h>
29#include <time.h>
30
31#ifdef DHT11_ENABLED
32#include <dht_nonblocking.h>
33#endif
34
35#define CSL_VERSION "0.7.7"
36#define CSL_REVISION 386
37
38/***************************************************************
39 * D F R o b o t G r a v i t y g a s s e n s o r s
40 ***************************************************************/
51#ifndef DFROBOT_CO_I2C_ADDR
52#define DFROBOT_CO_I2C_ADDR 0x78
53#endif
54#ifndef DFROBOT_O3_I2C_ADDR
55#define DFROBOT_O3_I2C_ADDR 0x79
56#endif
57#ifndef DFROBOT_NH3_I2C_ADDR
58#define DFROBOT_NH3_I2C_ADDR 0x7A
59#endif
60#ifndef DFROBOT_NO2_I2C_ADDR
61#define DFROBOT_NO2_I2C_ADDR 0x7B
62#endif
63
64/***************************************************************
65 * S E T U P E S P 3 2 B O A R D S A N D F I E L D S
66 ***************************************************************/
67
68// provisional pins. Config those via CLI
69#ifdef WEMOSOLED
70#define PMS_RX 13 // config for Wemos board & TTGO18650
71#define PMS_TX 15 // some old TTGO18650 have PMS_RX 18 & PMS_TX 17
72#elif HELTEC
73#define PMS_RX 17
74#define PMS_TX 18
75#elif TTGO_TQ
76#define PMS_RX 13
77#define PMS_TX 18
78#elif M5COREINK
79#define PMS_RX 13
80#define PMS_TX 14
81#elif TTGO_TDISPLAY
82#define PMS_RX 13
83#define PMS_TX 12
84#elif ESP32PICOD4
85#define PMS_RX 19
86#define PMS_TX 18
87#elif ESP32GENERIC
88#define PMS_RX RX
89#define PMS_TX TX
90#elif M5STICKCPLUS
91#define PMS_RX 36
92#define PMS_TX 0
93#elif M5COREINK
94#define PMS_RX 13
95#define PMS_TX 14
96#elif M5ATOM
97#define PMS_RX 23
98#define PMS_TX 33
99#elif M5PICOD4
100#define PMS_RX 3
101#define PMS_TX 1
102#elif AG_OPENAIR
103#define PMS_TYPE 8
104#define PMS_RX 20
105#define PMS_TX 21
106#elif TTGO_T7
107#define PMS_RX 17
108#define PMS_TX 16
109#elif ESP32DEVKIT
110#define PMS_RX 17
111#define PMS_TX 16
112#else
113#define PMS_RX -1 // DEFAULTS for other boards. Please setup it via CLI
114#define PMS_TX -1
115#endif
116
117#ifdef M5AIRQ
118#define GROVE_SDA 13
119#define GROVE_SCL 15
120#define I2C1_SDA_PIN 11
121#define I2C1_SCL_PIN 12
122#endif
123
124// Read UART sensor retry.
125#define SENSOR_RETRY 1000 // Max Serial characters
126
127// UART default port (ESP8266 has no Serial2, use SoftwareSerial via default branch)
128#if defined(ARDUINO_ARCH_ESP32)
129#define SENSOR_COMMS SERIALPORT2
130#else
131#define SENSOR_COMMS 3 // Custom value: use default (SoftwareSerial) path on ESP8266
132#endif
133
134// Sensors units definitions (symbol/name)
135#define SENSOR_UNITS \
136 X(NUNIT, "NUNIT", "NUNIT") \
137 X(PM1, "ug/m3", "PM1") \
138 X(PM25, "ug/m3", "PM2.5") \
139 X(PM4, "ug/m3", "PM4") \
140 X(PM10, "ug/m3", "PM10") \
141 X(TEMP, "C", "T") \
142 X(TEMPK, "K", "T") \
143 X(TEMPF, "F", "T") \
144 X(HUM, "%", "H") \
145 X(CO2, "ppm", "CO2") \
146 X(CO2TEMP, "C", "CO2T") \
147 X(CO2TEMPK, "K", "CO2TK") \
148 X(CO2TEMPF, "F", "CO2TF") \
149 X(CO2HUM, "%", "CO2H") \
150 X(PRESS, "hPa", "P") \
151 X(ALT, "m", "Alt") \
152 X(GAS, "Ohm", "Gas") \
153 X(CPM, "CPM", "RAD") \
154 X(RAD, "uSv/h", "RAD") \
155 X(NH3, "ppm", "NH3") \
156 X(CO, "ppm", "CO") \
157 X(NO2, "ppm", "NO2") \
158 X(O3, "ppm", "O3") \
159 X(NOXI, "noxi", "NOXI") \
160 X(VOCI, "voci", "VOCI") \
161 X(NOX, "nox", "NOX") \
162 X(VOC, "voc", "VOC") \
163 X(NOISE, "dB", "Noise") \
164 X(NOISEAVG, "dB", "NoiseAvg") \
165 X(NOISEPEAK, "dB", "NoisePeak") \
166 X(NOISEMIN, "dB", "NoiseMin") \
167 X(NOISEAVGLEGAL, "dB", "NoiseAvgLegal") \
168 X(NOISEAVGLEGALMAX, "dB", "NoiseAvgLegalMax") \
169 X(NOISEL90, "dB", "NoiseL90") \
170 X(NOISELD, "dB", "Ld") \
171 X(NOISELE, "dB", "Le") \
172 X(NOISELN, "dB", "Ln") \
173 X(NOISELDEN, "dB", "Lden") \
174 X(UCOUNT, "COUNT", "UCOUNT")
175
176#define X(unit, symbol, name) unit,
177typedef enum UNIT : size_t { SENSOR_UNITS } UNIT;
178#undef X
179
180// sensors types: 1:PM, 2:CO2, 3:ENV
181#define SENSORS_TYPES \
182 X(Auto, "GENERIC", 1) \
183 X(SGCJA5, "GCJA5", 1) \
184 X(SSPS30, "SPS30", 1) \
185 X(SDS011, "SDS011", 1) \
186 X(SMHZ19, "MHZ19", 2) \
187 X(SCM1106, "CM1106", 2) \
188 X(SAIRS8, "SAIRS8", 2) \
189 X(IKEAVK, "IKEAVK", 1) \
190 X(P5003T, "PM5003T", 1) \
191 X(SSCD30, "SCD30", 2) \
192 X(SSCD4X, "SCD4X", 2) \
193 X(SSEN5X, "SEN5X", 1) \
194 X(SSHT31, "SHT31", 3) \
195 X(SBME280, "BME280", 3) \
196 X(SBMP280, "BMP280", 3) \
197 X(SBME680, "BME680", 3) \
198 X(SAHTXX, "AHTXX", 3) \
199 X(SAM232X, "AM232X", 3) \
200 X(SDHTX, "DHTX", 3) \
201 X(SDFRCO, "DFRCO", 3) \
202 X(SDFRNH3, "DFRNH3", 3) \
203 X(SDFRNO2, "DFRNO2", 3) \
204 X(SDFRO3, "DFRO3", 3) \
205 X(SCAJOE, "CAJOE", 3) \
206 X(SSGP41, "SGP41", 3) \
207 X(SNOISE, "NOISE", 3) \
208 X(SCOUNT, "SCOUNT", 3)
209
210#define X(utype, uname, umaintype) utype,
211typedef enum SENSORS : size_t { SENSORS_TYPES } SENSORS; // backward compatibility
212#undef X
213
214// MAIN SENSOR GROUPS TYPE
215enum class SensorGroup {
216 SENSOR_NONE,
217 SENSOR_PM,
218 SENSOR_CO2,
219 SENSOR_ENV,
220 SENSOR_RAD // CAJOE_GEIGER
221};
222// TEMPERATURE UNITS
223enum class TEMPUNIT { CELSIUS, FAHRENHEIT, KELVIN };
224
225typedef void (*errorCbFn)(const char *msg);
226typedef void (*voidCbFn)();
227
232class Sensors {
233 public:
235 struct sps_values val;
236
239
241 int sample_time = 10;
242
244 float toffset = 0.0;
245
247 float altoffset = 0.0;
248
250 float sealevel = 1013.25;
251
253 float hpa = 0.0;
254
256 SPS30 sps30;
257
259 SensirionI2CSgp41 sgp41;
260 uint8_t conditioning_s = 10;
262 VOCGasIndexAlgorithm vocAlgorithm{1.0f};
263 NOxGasIndexAlgorithm noxAlgorithm;
264
267
268 /*****************************************
269 * I2C sensors:
270 ****************************************/
271
273 AM232X am2320;
275 Adafruit_BME280 bme280;
277 Adafruit_BMP280 bmp280;
279 Adafruit_BME680 bme680;
281 AHTxx aht10;
283 Adafruit_SHT31 sht31;
284
285#ifdef DHT11_ENABLED
287 float dhthumi, dhttemp;
288#endif
290 MHZ19 mhz19;
292 Adafruit_SCD30 scd30;
294 CM1106_UART *cm1106;
296 CM1106_sensor cm1106sensor;
298 CM1106_ABC abc;
300 SFE_PARTICLE_SENSOR pmGCJA5;
302 S8_UART *s8;
304 S8_sensor s8sensor;
306 SensirionI2CScd4x scd4x;
307 // SEN5x sensor PM
308 SensirionI2CSen5x sen5x;
310 PM1006 *pm1006;
312 DFRobot_GAS_I2C dfrCO;
314 DFRobot_GAS_I2C dfrNH3;
316 DFRobot_GAS_I2C dfrNO2;
318 DFRobot_GAS_I2C dfrO3;
320 GEIGER *rad;
322 PMS5003T *pm5003t;
323
324 Sensors();
325 ~Sensors();
326
327 void init(u_int pms_type = 0, int pms_rx = PMS_RX, int pms_tx = PMS_TX);
328
329 void loop();
330
331 bool readAllSensors();
332
333 bool isDataReady();
334
335 void setSampleTime(int seconds);
336
337 void setOnDataCallBack(voidCbFn cb);
338
339 void setOnErrorCallBack(errorCbFn cb);
340
341 void setTemperatureUnit(TEMPUNIT tunit);
342
343 void setDebugMode(bool enable);
344
345 bool isUARTSensorConfigured() const;
346
347 int getUARTDeviceTypeSelected() const;
348
349 uint16_t getPM1() const;
350
351 uint16_t getPM25() const;
352
353 uint16_t getPM4() const;
354
355 uint16_t getPM10() const;
356
357 uint16_t getCO2() const;
358
359 float getCO2humi() const;
360
361 float getCO2temp() const;
362
363 float getTemperature() const;
364
365 float getHumidity() const;
366
367 float getPressure() const;
368
369 float getAltitude() const;
370
371 float getGas() const;
372
373 float getNH3() const;
374
375 float getCO() const;
376
377 float getNO2() const;
378
379 float getO3() const;
380
381 float getVOC() const;
382
383 float getNOX() const;
384
385 float getVOCI() const;
386
387 float getNOXI() const;
388
389 void enableGeigerSensor(int gpio);
390
391 float getNoise() const;
392
393 float getNoiseAverage() const;
394
395 float getNoisePeak() const;
396
397 float getNoiseMin() const;
398
399 float getNoiseLegalAverage() const;
400
401 float getNoiseLegalMaximum() const;
402 float getNoiseL90() const;
403 float getNoiseLd() const;
404 float getNoiseLe() const;
405 float getNoiseLn() const;
406 float getNoiseLden() const;
407 bool sendNoiseSensorTime(uint32_t unixTime);
408 bool syncNoiseSensorTime();
409 void setNoiseSensorTimeSyncInterval(uint32_t intervalMs);
410
411 uint32_t getGeigerCPM(void) const;
412
413 float getGeigerMicroSievertHour(void) const;
414
415 void initTOffset(float offset);
416
417 float getTOffset() const;
418
419 void setTempOffset(float offset);
420
421 float getTempOffset() const;
422
423 void setCO2AltitudeOffset(float altitude);
424
425 void setSeaLevelPressure(float hpa);
426
427 void setCO2RecalibrationFactor(int ppmValue);
428
429 void detectI2COnly(bool enable);
430
431 String getLibraryVersion() const;
432
433 int16_t getLibraryRevision() const;
434
435 bool isSensorRegistered(SENSORS sensor) const;
436
437 uint8_t *getSensorsRegistered();
438
439 uint8_t getSensorsRegisteredCount() const;
440
441 String getSensorName(SENSORS sensor) const;
442
443 SensorGroup getSensorGroup(SENSORS sensor) const;
444
445 uint8_t getUnitsRegisteredCount() const;
446
447 bool isUnitRegistered(UNIT unit) const;
448
449 String getUnitName(UNIT unit) const;
450
451 String getUnitSymbol(UNIT unit) const;
452
453 UNIT getNextUnit();
454
455 void resetUnitsRegister();
456
458
459 void resetNextUnit();
460
461 void resetAllVariables();
462
463 float getUnitValue(UNIT unit);
464
465 void printUnitsRegistered(bool debug = false);
466
467 void printSensorsRegistered(bool debug = false);
468
469 void startI2C();
470
471 private:
472#ifdef DHT11_ENABLED
474 uint32_t delayMS;
475#endif
477 Stream *_serial;
479 Stream *_serial2;
481 errorCbFn _onErrorCb = nullptr;
483 voidCbFn _onDataCb = nullptr;
484
485 int dev_uart_type = -1;
487 bool s8_uart2 = false;
488
489 bool dataReady;
490
491 bool readAllComplete = false;
492
493 uint8_t sensors_registered_count;
494
495 uint8_t units_registered_count;
496
497 uint8_t current_unit = 0;
498
499 uint16_t pm1; // PM1
500 uint16_t pm25; // PM2.5
501 uint16_t pm4; // PM4
502 uint16_t pm10; // PM10
503
504 float humi = 0.0; // % Relative humidity
505 float temp = 0.0; // Temperature (°C)
506 float pres = 0.0; // Pressure
507 float alt = 0.0;
508 float gas = 0.0;
509 float voci = 0.0;
510 float noxi = 0.0;
511 uint16_t voc = 0;
512 uint16_t nox = 0;
513
514 // temperature unit (C,K,F)
515 TEMPUNIT temp_unit = TEMPUNIT::CELSIUS;
516
517 uint16_t CO2Val; // CO2 in ppm
518 float CO2humi = 0.0; // humidity of CO2 sensor
519 float CO2temp = 0.0; // temperature of CO2 sensor
520
521 float nh3; // Amonium in ppm
522 float co; // Carbon monoxide in ppm
523 float no2; // Nitrogen dioxide in ppm
524 float o3; // Ozone in ppm
525
526 TwoWire *noiseWire = nullptr;
527 SensorData noiseSensorData{};
528 bool noiseWireReady = false;
529 uint8_t noiseSensorAddress = 0;
530
531 bool noiseSensorEnabled = false;
532 float noiseInstant = 0.0;
533 float noiseAvgValue = 0.0;
534 float noisePeakValue = 0.0;
535 float noiseMinValue = 0.0;
536 float noiseAvgLegalValue = 0.0;
537 float noiseAvgLegalMaxValue = 0.0;
538 float noiseL90Value = 0.0;
539 float noiseLdValue = 0.0;
540 float noiseLeValue = 0.0;
541 float noiseLnValue = 0.0;
542 float noiseLdenValue = 0.0;
543 bool noiseScanDone = false;
544 uint32_t noiseLastTimeSyncMs = 0;
545 uint32_t noiseLastSyncAttemptMs = 0;
546 uint32_t noiseTimeSyncIntervalMs = 86400000;
547 static constexpr uint32_t NOISE_SYNC_RETRY_MS = 30000;
548 bool noiseTimeSyncEnabled = true;
549
550 void am2320Init();
551 void am2320Read();
552
553 void bme280Init();
554 void bme280Read();
555
556 void bmp280Init();
557 void bmp280Read();
558
559 void bme680Init();
560 void bme680Read();
561
562 void aht10Init();
563 void aht10Read();
564
565 void sht31Init();
566 void sht31Read();
567
568 void CO2scd30Init();
569 void CO2scd30Read();
570 void setSCD30TempOffset(float offset);
571 float getSCD30TempOffset() const;
572 void setSCD30AltitudeOffset(float offset);
573 void CO2correctionAlt();
574 float hpaCalculation(float altitude);
575
576 void CO2scd4xInit();
577 void CO2scd4xRead();
578 void setSCD4xTempOffset(float offset);
579 float getSCD4xTempOffset() const;
580 void setSCD4xAltitudeOffset(float offset);
581
582 void sen5xInit();
583 void sen5xRead();
584 void setsen5xTempOffset(float offset);
585
586 void sgp41Init();
587 void sgp41Read();
588
589 void GCJA5Init();
590 void GCJA5Read();
591
592#ifdef DHT11_ENABLED
593 void dhtInit();
594 void dhtRead();
595 bool dhtIsReady(float *temperature, float *humidity);
596#endif
597
598 void DFRobotNH3Init();
599 void DFRobotNH3Read();
600 void DFRobotCOInit();
601 void DFRobotCORead();
602 void DFRobotNO2Init();
603 void DFRobotNO2Read();
604 void DFRobotO3Init();
605 void DFRobotO3Read();
606
607 float dfrGasTempCompensation(float rawPpm, float temperature, uint8_t gasType);
608 float dfrGasPressCompensation(float ppm, float pressure);
609 float dfrGasHumiCompensation(float ppm, float humidity, uint8_t gasType);
610 bool dfrHasExternalTempSensor() const;
611
612 // UART sensors methods:
613
614 bool sensorSerialInit(u_int pms_type, int rx, int tx);
615 bool pmSensorAutoDetect(u_int pms_type);
616 bool pmSensorRead();
617 bool pmGenericRead();
618 bool pmGCJA5Read();
619 bool pmSDS011Read();
620 bool pm1006Read();
621 bool pm5003TRead();
622 bool CO2Mhz19Read();
623 bool CO2CM1106Read();
624 bool CO2Mhz19Init();
625 bool CO2CM1106Init();
626 bool senseAirS8Init();
627 bool senseAirS8Read();
628 bool sensorSerial2Init(int rx, int tx);
629 bool PM1006Init();
630 bool PM5003TInit();
631
632 bool sps30I2CInit();
633 bool sps30UARTInit();
634 bool sps30Read();
635 bool sps30tests();
636 void sps30ErrToMess(char *mess, uint8_t r);
637 void sps30Errorloop(char *mess, uint8_t r);
638 void sps30DeviceInfo();
639
640 void geigerRead();
641
642 void onSensorError(const char *msg);
643
644 void enableWire1();
645
646 void disableWire1();
647
648 bool serialInit(u_int pms_type, unsigned long speed_baud, int pms_rx, int pms_tx);
649
650 String hwSerialRead(unsigned int length_buffer);
651
652 void restart(); // restart serial (it isn't works sometimes)
653
654 void DEBUG(const char *text, const char *textb = "") const;
655
656 void printValues();
657
658 void printHumTemp();
659
660 void printUART(const char *name, unsigned long speed, int pin_rx, int pin_tx);
661
662 void printI2C(const char *name, const char *i2cname, int pin_sda, int pin_scl);
663
664 void tempRegister(bool isCO2temp);
665
666 void sensorRegister(SENSORS sensor);
667
668 void sensorAnnounce(SENSORS sensor);
669
670 void unitRegister(UNIT unit);
671
672 uint8_t *getUnitsRegistered();
673
674 bool noiseSensorAutoDetect();
675 void noiseSensorService();
676 void noiseSensorCollect();
677 bool noiseSensorReadIdentity(TwoWire &wire, uint8_t address, SensorIdentity &identity);
678 bool noiseSensorReadData(TwoWire &wire, uint8_t address, SensorData &out);
679 bool noiseSensorDevicePresent(TwoWire &wire, uint8_t address);
680 void noiseSensorInitWire();
681
682// @todo use DEBUG_ESP_PORT ?
683#ifdef WM_DEBUG_PORT
684 Stream &_debugPort = WM_DEBUG_PORT;
685#else
686 Stream &_debugPort = Serial; // debug output stream ref
687#endif
688};
689
690#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SENSORSHANDLER)
691extern Sensors sensors;
692#endif
693
694#endif
CanAirIO Sensors Manager main class.
Definition: Sensors.hpp:232
float getNH3() const
get NH3 value in ppm
Definition: Sensors.cpp:494
float getTempOffset() const
Get temperature offset for Sensirion sensors (from internal sensor in SCD4x and SCD30)
Definition: Sensors.cpp:473
void printUnitsRegistered(bool debug=false)
print the sensor units names available
Definition: Sensors.cpp:835
void setTempOffset(float offset)
Set temperature offset for all temperature sensors.
Definition: Sensors.cpp:461
float getAltitude() const
get Altitude value in meters
Definition: Sensors.cpp:488
SensirionI2CScd4x scd4x
SCD4x object sensor.
Definition: Sensors.hpp:306
bool i2conly
only detect i2c sensors flag
Definition: Sensors.hpp:266
String getUnitSymbol(UNIT unit) const
get the sensor unit symbol
Definition: Sensors.cpp:691
int getUARTDeviceTypeSelected() const
UART only: get the UART sensor type. See SENSORS enum. Also getDeviceName()
Definition: Sensors.cpp:591
DFRobot_GAS_I2C dfrNH3
DFRobot gravity NH3 object sensor addr 0x7A.
Definition: Sensors.hpp:314
uint16_t getPM10() const
get PM10 ug/m3 value
Definition: Sensors.cpp:352
void loop()
Main sensors loop. All sensors are read here, please call it on main loop.
Definition: Sensors.cpp:72
void setCO2AltitudeOffset(float altitude)
set CO2 altitude offset (m)
Definition: Sensors.cpp:290
void resetAllVariables()
reset all library variables (generic sensors units)
Definition: Sensors.cpp:2604
String getSensorName(SENSORS sensor) const
get the sensor name
Definition: Sensors.cpp:625
float getTOffset() const
Get sensorlib actual internal temperature offset.
Definition: Sensors.cpp:454
uint16_t getPM1() const
get PM1.0 ug/m3 value
Definition: Sensors.cpp:343
bool isUnitRegistered(UNIT unit) const
get the sensor unit status on the registry
Definition: Sensors.cpp:656
float getNO2() const
get NO2 value in ppm
Definition: Sensors.cpp:500
float getCO() const
get CO value in ppm
Definition: Sensors.cpp:497
int16_t getLibraryRevision() const
return the current revision code number
Definition: Sensors.cpp:603
CM1106_UART * cm1106
CM1106 UART main object sensor.
Definition: Sensors.hpp:294
String getUnitName(UNIT unit) const
get the sensor unit name
Definition: Sensors.cpp:681
bool devmode
Debug mode for increase verbose.
Definition: Sensors.hpp:238
void resetUnitsRegister()
reset the sensor units registry.
Definition: Sensors.cpp:714
void setCO2RecalibrationFactor(int ppmValue)
set CO2 recalibration PPM value (400 to 2000)
Definition: Sensors.cpp:253
String getLibraryVersion() const
returns the CanAirIO Sensorslib version
Definition: Sensors.cpp:600
AHTxx aht10
AHTXX sensors object.
Definition: Sensors.hpp:281
float altoffset
Altitude compensation variable.
Definition: Sensors.hpp:247
bool readAllSensors()
Read all sensors but use only one time or use loop() instead. All sensors are read here....
Definition: Sensors.cpp:101
uint8_t getUnitsRegisteredCount() const
get device sensors units detected count
Definition: Sensors.cpp:674
void initTOffset(float offset)
Initialize internal temperature offset to be used on startup.
Definition: Sensors.cpp:447
Adafruit_BMP280 bmp280
BMP280 object (Humidity, Pressure, Altitude and Temperature)
Definition: Sensors.hpp:277
struct sps_values val
SPS30 values. Only for Sensirion SPS30 sensor.
Definition: Sensors.hpp:235
bool isDataReady()
get the sensor status
Definition: Sensors.cpp:340
Adafruit_BME280 bme280
BME280 object (Humidity, Pressure, Altitude and Temperature)
Definition: Sensors.hpp:275
DFRobot_GAS_I2C dfrO3
DFRobot gravity O3 object sensor add 0x79.
Definition: Sensors.hpp:318
VOCGasIndexAlgorithm vocAlgorithm
Sensirion gas index algorithms for SGP41 raw signal processing.
Definition: Sensors.hpp:262
void enableGeigerSensor(int gpio)
Enable Geiger sensor on specific pin.
Definition: Sensors.cpp:2649
void setOnDataCallBack(voidCbFn cb)
Get sensor data.
Definition: Sensors.cpp:325
float getHumidity() const
get humidity % value of environment sensor
Definition: Sensors.cpp:361
AM232X am2320
AM2320 object (Humidity and temperature)
Definition: Sensors.hpp:273
Adafruit_SCD30 scd30
SCD30 object sensor.
Definition: Sensors.hpp:292
uint16_t getPM25() const
get PM2.5 ug/m3 value
Definition: Sensors.cpp:346
float getUnitValue(UNIT unit)
get the sensor unit value (float)
Definition: Sensors.cpp:750
void resetSensorsRegister()
reset the sensor registry.
Definition: Sensors.cpp:727
float getGas() const
get Gas resistance value of BMP680 sensor
Definition: Sensors.cpp:485
CM1106_sensor cm1106sensor
CM1106 UART main variable.
Definition: Sensors.hpp:296
Adafruit_SHT31 sht31
SHT31 object (Humidity and temperature)
Definition: Sensors.hpp:283
void setSeaLevelPressure(float hpa)
set the sea level pressure (hPa)
Definition: Sensors.cpp:312
bool isUARTSensorConfigured() const
UART only: check if the UART sensor is registered.
Definition: Sensors.cpp:585
bool isSensorRegistered(SENSORS sensor) const
Read and check the sensors status on initialization.
Definition: Sensors.cpp:613
float getGeigerMicroSievertHour(void) const
get Geiger count in uSv/h units
Definition: Sensors.cpp:2674
uint16_t getCO2() const
get CO2 ppm value
Definition: Sensors.cpp:355
SFE_PARTICLE_SENSOR pmGCJA5
Panasonic SN-GCJA5 object sensor.
Definition: Sensors.hpp:300
Adafruit_BME680 bme680
BME680 object (Humidity, Gas, IAQ, Pressure, Altitude and Temperature)
Definition: Sensors.hpp:279
DFRobot_GAS_I2C dfrNO2
DFRobot gravity NO2 object sensor add 0x7B.
Definition: Sensors.hpp:316
SensorGroup getSensorGroup(SENSORS sensor) const
get the sensor group type
Definition: Sensors.cpp:638
PMS5003T * pm5003t
PMS5003T Plantower with T&H of Airgradient.
Definition: Sensors.hpp:322
PM1006 * pm1006
IKEA Vindriktn object sensor.
Definition: Sensors.hpp:310
float sealevel
Sea level pressure (hPa)
Definition: Sensors.hpp:250
float getO3() const
get O3 value in ppm
Definition: Sensors.cpp:503
void init(u_int pms_type=0, int pms_rx=PMS_RX, int pms_tx=PMS_TX)
All sensors init.
Definition: Sensors.cpp:155
float getTemperature() const
get temperature value from environment sensor
Definition: Sensors.cpp:400
void setOnErrorCallBack(errorCbFn cb)
Optional callback for get the sensors errors.
Definition: Sensors.cpp:331
uint32_t getGeigerCPM(void) const
get Geiger count. Tics in the last 60secs
Definition: Sensors.cpp:2663
float getCO2humi() const
get humidity % value of CO2 sensor device
Definition: Sensors.cpp:358
float hpa
Altitude hpa calculation.
Definition: Sensors.hpp:253
void setSampleTime(int seconds)
set loop time interval for each sensor sample
Definition: Sensors.cpp:237
void setDebugMode(bool enable)
Optional for increase the debug level.
Definition: Sensors.cpp:337
SensirionI2CSgp41 sgp41
Sensirion sgp41 library (Rh, T, Voc, Nox)
Definition: Sensors.hpp:259
uint16_t getPM4() const
get PM4 ug/m3 value
Definition: Sensors.cpp:349
float toffset
Temperature offset (for final temp output)
Definition: Sensors.hpp:244
CM1106_ABC abc
CM1106 UART calibration object.
Definition: Sensors.hpp:298
UNIT getNextUnit()
get the next sensor unit available
Definition: Sensors.cpp:697
S8_UART * s8
SenseAir S8 CO2 object sensor.
Definition: Sensors.hpp:302
DFRobot_GAS_I2C dfrCO
DFRobot gravity CO object sensor addr 0x78.
Definition: Sensors.hpp:312
MHZ19 mhz19
Mhz19 object sensor.
Definition: Sensors.hpp:290
int sample_time
Initial sample time for all sensors.
Definition: Sensors.hpp:241
float getCO2temp() const
get temperature value from the CO2 sensor device
Definition: Sensors.cpp:387
S8_sensor s8sensor
SenseAir S8 CO2 object sensor.
Definition: Sensors.hpp:304
void detectI2COnly(bool enable)
Forced to enable I2C sensors only. Recommended to use only if you are using a I2C sensor and improve ...
Definition: Sensors.cpp:597
void resetNextUnit()
reset the next sensor unit counter.
Definition: Sensors.cpp:740
void setTemperatureUnit(TEMPUNIT tunit)
set the temperature type unit
Definition: Sensors.cpp:367
void printSensorsRegistered(bool debug=false)
print the sensor names detected
Definition: Sensors.cpp:850
uint8_t getSensorsRegisteredCount() const
get device sensors detected count
Definition: Sensors.cpp:606
float getPressure() const
get Pressure value in hPa
Definition: Sensors.cpp:491
GEIGER * rad
Geiger CAJOE object sensor.
Definition: Sensors.hpp:320
uint8_t * getSensorsRegistered()
get the sensor registry for retrieve the sensor names
Definition: Sensors.cpp:648
SPS30 sps30
Sensirion dust SPS30 library.
Definition: Sensors.hpp:256