CanAirIO Sensors Manager main class. More...
#include <Sensors.hpp>
Public Member Functions | |
void | init (u_int pms_type=0, int pms_rx=PMS_RX, int pms_tx=PMS_TX) |
All sensors init. More... | |
void | loop () |
Main sensors loop. All sensors are read here, please call it on main loop. | |
bool | readAllSensors () |
Read all sensors but use only one time or use loop() instead. All sensors are read here. Use it carefully, better use sensors.loop() | |
bool | isDataReady () |
get the sensor status | |
void | setSampleTime (int seconds) |
set loop time interval for each sensor sample | |
void | setOnDataCallBack (voidCbFn cb) |
Get sensor data. More... | |
void | setOnErrorCallBack (errorCbFn cb) |
Optional callback for get the sensors errors. More... | |
void | setTemperatureUnit (TEMPUNIT tunit) |
set the temperature type unit More... | |
void | setDebugMode (bool enable) |
Optional for increase the debug level. More... | |
bool | isUARTSensorConfigured () |
UART only: check if the UART sensor is registered. More... | |
int | getUARTDeviceTypeSelected () |
UART only: get the UART sensor type. See SENSORS enum. Also getDeviceName() More... | |
uint16_t | getPM1 () |
get PM1.0 ug/m3 value | |
uint16_t | getPM25 () |
get PM2.5 ug/m3 value | |
uint16_t | getPM4 () |
get PM4 ug/m3 value | |
uint16_t | getPM10 () |
get PM10 ug/m3 value | |
uint16_t | getCO2 () |
get CO2 ppm value | |
float | getCO2humi () |
get humidity % value of CO2 sensor device | |
float | getCO2temp () |
get temperature value from the CO2 sensor device | |
float | getTemperature () |
get temperature value from environment sensor | |
float | getHumidity () |
get humidity % value of environment sensor | |
float | getPressure () |
get Pressure value in hPa | |
float | getAltitude () |
get Altitude value in meters | |
float | getGas () |
get Gas resistance value of BMP680 sensor | |
float | getNH3 () |
get NH3 value in ppm | |
float | getCO () |
get CO value in ppm | |
float | getNO2 () |
get NO2 value in ppm | |
void | enableGeigerSensor (int gpio) |
Enable Geiger sensor on specific pin. More... | |
uint32_t | getGeigerCPM (void) |
get Geiger count. Tics in the last 60secs More... | |
float | getGeigerMicroSievertHour (void) |
get Geiger count in uSv/h units More... | |
void | setTempOffset (float offset) |
Set temperature offset for all temperature sensors. More... | |
void | setCO2AltitudeOffset (float altitude) |
set CO2 altitude offset (m) More... | |
void | setSeaLevelPressure (float hpa) |
set the sea level pressure (hPa) More... | |
void | setCO2RecalibrationFactor (int ppmValue) |
set CO2 recalibration PPM value (400 to 2000) More... | |
void | detectI2COnly (bool enable) |
Forced to enable I2C sensors only. Recommended to use only if you are using a I2C sensor and improve the performance. | |
String | getLibraryVersion () |
returns the CanAirIO Sensorslib version | |
int16_t | getLibraryRevision () |
return the current revision code number | |
bool | isSensorRegistered (SENSORS sensor) |
Read and check the sensors status on initialization. More... | |
uint8_t * | getSensorsRegistered () |
get the sensor registry for retrieve the sensor names More... | |
uint8_t | getSensorsRegisteredCount () |
get device sensors detected count | |
String | getSensorName (SENSORS sensor) |
get the sensor name More... | |
SensorGroup | getSensorGroup (SENSORS sensor) |
get the sensor group type More... | |
uint8_t | getUnitsRegisteredCount () |
get device sensors units detected count | |
bool | isUnitRegistered (UNIT unit) |
get the sensor unit status on the registry More... | |
String | getUnitName (UNIT unit) |
get the sensor unit name More... | |
String | getUnitSymbol (UNIT unit) |
get the sensor unit symbol More... | |
UNIT | getNextUnit () |
get the next sensor unit available More... | |
void | resetUnitsRegister () |
reset the sensor units registry. More... | |
void | resetSensorsRegister () |
reset the sensor registry. More... | |
void | resetNextUnit () |
reset the next sensor unit counter. More... | |
void | resetAllVariables () |
reset all library variables (generic sensors units) | |
float | getUnitValue (UNIT unit) |
get the sensor unit value (float) More... | |
void | printUnitsRegistered (bool debug=false) |
print the sensor units names available More... | |
void | printSensorsRegistered (bool debug=false) |
print the sensor names detected More... | |
Public Attributes | |
struct sps_values | val |
SPS30 values. Only for Sensirion SPS30 sensor. | |
bool | devmode |
Debug mode for increase verbose. | |
int | sample_time = 10 |
Initial sample time for all sensors. | |
float | toffset = 0.0 |
Temperature offset (for final temp output) | |
float | altoffset = 0.0 |
Altitud compensation variable. | |
float | sealevel = 1013.25 |
Sea level pressure (hPa) | |
float | hpa = 0.0 |
Altitud hpa calculation. | |
SPS30 | sps30 |
Sensirion library. | |
bool | i2conly |
only detect i2c sensors flag | |
AM232X | am2320 |
AM2320 object (Humidity and temperature) | |
Adafruit_BME280 | bme280 |
BME280 object (Humidity, Pressure, Altitude and Temperature) | |
Adafruit_BMP280 | bmp280 |
BMP280 object (Humidity, Pressure, Altitude and Temperature) | |
Adafruit_BME680 | bme680 |
BME680 object (Humidity, Gas, IAQ, Pressure, Altitude and Temperature) | |
AHTxx | aht10 |
AHTXX sensors object. | |
Adafruit_SHT31 | sht31 |
SHT31 object (Humidity and temperature) | |
MHZ19 | mhz19 |
Mhz19 object sensor. | |
Adafruit_SCD30 | scd30 |
SCD30 object sensor. | |
CM1106_UART * | cm1106 |
CM1106 UART main object sensor. | |
CM1106_sensor | cm1106sensor |
CM1106 UART main variable. | |
CM1106_ABC | abc |
CM1106 UART calibration object. | |
SFE_PARTICLE_SENSOR | pmGCJA5 |
Panasonic SN-GCJA5 object sensor. | |
S8_UART * | s8 |
SenseAir S8 CO2 object sensor. | |
S8_sensor | s8sensor |
SenseAir S8 CO2 object sensor. | |
SensirionI2CScd4x | scd4x |
SCD4x object sensor. | |
SensirionI2CSen5x | sen5x |
PM1006 * | pm1006 |
IKEA Vindriktn object sensor. | |
DFRobot_GAS_I2C | dfrCO |
DFRobot gravity CO object sensor addr 0x78. | |
DFRobot_GAS_I2C | dfrNH3 |
DFRobot gravity NH3 object sensor addr 0x7A. | |
DFRobot_GAS_I2C | dfrNO2 |
DFRobot gravity NO2 object sensor add 0x7B. | |
GEIGER * | rad |
Geiger CAJOE object sensor. | |
CanAirIO Sensors Manager main class.
void Sensors::enableGeigerSensor | ( | int | gpio | ) |
Enable Geiger sensor on specific pin.
gpio | number or pin. |
uint32_t Sensors::getGeigerCPM | ( | void | ) |
get Geiger count. Tics in the last 60secs
float Sensors::getGeigerMicroSievertHour | ( | void | ) |
get Geiger count in uSv/h units
UNIT Sensors::getNextUnit | ( | ) |
get the next sensor unit available
SensorGroup Sensors::getSensorGroup | ( | SENSORS | sensor | ) |
get the sensor group type
sensor | (mandatory) SENSORS enum value. |
if the sensor is not in a group, return 0. if the sensor is in a group, return 1 (PM), 2 (CO2), 3 (ENV).
String Sensors::getSensorName | ( | SENSORS | sensor | ) |
get the sensor name
sensor | (mandatory) SENSORS enum value. |
uint8_t * Sensors::getSensorsRegistered | ( | ) |
get the sensor registry for retrieve the sensor names
See the Advanced Multivariable example
int Sensors::getUARTDeviceTypeSelected | ( | ) |
UART only: get the UART sensor type. See SENSORS enum. Also getDeviceName()
String Sensors::getUnitName | ( | UNIT | unit | ) |
get the sensor unit name
unit | (mandatory) UNIT enum value. |
String Sensors::getUnitSymbol | ( | UNIT | unit | ) |
get the sensor unit symbol
unit | (mandatory) UNIT enum value. |
float Sensors::getUnitValue | ( | UNIT | unit | ) |
get the sensor unit value (float)
unit | (mandatory) UNIT enum value. |
Also you can use the specific primitive like getTemperature(), getHumidity(), getGas(), getAltitude(), getPressure()
void Sensors::init | ( | u_int | pms_type = 0 , |
int | pms_rx = PMS_RX , |
||
int | pms_tx = PMS_TX |
||
) |
All sensors init.
pms_type | (optional) UART PMS type, please see DEVICE_TYPE enum. |
pms_rx | (optional) UART PMS RX pin. |
pms_tx | (optional) UART PMS TX pin. |
bool Sensors::isSensorRegistered | ( | SENSORS | sensor | ) |
Read and check the sensors status on initialization.
sensor | (mandatory) SENSORS enum value. |
bool Sensors::isUARTSensorConfigured | ( | ) |
UART only: check if the UART sensor is registered.
bool Sensors::isUnitRegistered | ( | UNIT | unit | ) |
get the sensor unit status on the registry
See the Advanced Multivariable example
void Sensors::printSensorsRegistered | ( | bool | debug = false | ) |
print the sensor names detected
debug | optional boolean to set the debug mode flag. |
void Sensors::printUnitsRegistered | ( | bool | debug = false | ) |
print the sensor units names available
debug | optional boolean to set the debug mode flag. |
void Sensors::resetNextUnit | ( | ) |
reset the next sensor unit counter.
This function is useful to reset the counter to review the sensor units again. but it is not necessary to call this function.
void Sensors::resetSensorsRegister | ( | ) |
reset the sensor registry.
This function is useful to reset the sensors registry after a sensor is removed. It should be called before the initialization of the sensors but it is Not necessary to call this function.
void Sensors::resetUnitsRegister | ( | ) |
reset the sensor units registry.
This function is useful to reset the units registry after a sensor unit is removed. but it is Not necessary to call this function.
void Sensors::setCO2AltitudeOffset | ( | float | altitude | ) |
set CO2 altitude offset (m)
altitude | (m). |
This method is used to compensate the CO2 value with the altitude. Recommended on high altitude.
void Sensors::setCO2RecalibrationFactor | ( | int | ppmValue | ) |
set CO2 recalibration PPM value (400 to 2000)
ppmValue | the ppm value to set, normally 400. |
This method is used to set the CO2 recalibration value, please use it only on outdoor conditions. Please see the documentation of each sensor for more information.
void Sensors::setDebugMode | ( | bool | enable | ) |
Optional for increase the debug level.
enable | true to enable debug mode, false to disable debug mode. |
void Sensors::setOnDataCallBack | ( | voidCbFn | cb | ) |
Get sensor data.
cb | (mandatory) callback function to be called when data is ready. |
void Sensors::setOnErrorCallBack | ( | errorCbFn | cb | ) |
Optional callback for get the sensors errors.
cb | callback function to be called when any warnning or error happens. |
void Sensors::setSeaLevelPressure | ( | float | hpa | ) |
set the sea level pressure (hPa)
hpa | (hPa). |
This method is used to set the sea level pressure for some sensors that need it.
void Sensors::setTemperatureUnit | ( | TEMPUNIT | tunit | ) |
set the temperature type unit
tunit | celciuse, kelvin or fahrenheit. |
void Sensors::setTempOffset | ( | float | offset | ) |
Set temperature offset for all temperature sensors.
offset | temperature offset in °C (default 0). |
Positive value for offset to be subtracetd to the temperature.