Skip to content

Commit

Permalink
Merge pull request #201 from kike-canaries/add_register_validation
Browse files Browse the repository at this point in the history
Add register validation
  • Loading branch information
hpsaturn authored Feb 13, 2024
2 parents c5c1be5 + 9b66d6d commit c2c0f4a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CanAirIO Air Quality Sensors Library",
"version": "0.7.3",
"version": "0.7.4",
"homepage":"https://canair.io",
"keywords":
[
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=CanAirIO Air Quality Sensors Library
version=0.7.3
version=0.7.4
author=@hpsaturn, CanAirIO project <[email protected]>
maintainer=Antonio Vanegas <[email protected]>
url=https://github.com/kike-canaries/canairio_sensorlib
Expand Down
11 changes: 11 additions & 0 deletions src/Sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ bool Sensors::pmSensorRead() {
******************************************************************************/

void Sensors::am2320Read() {
if (!isSensorRegistered(SENSORS::SAM232X)) return;
if (!am2320.isConnected()) return;
int status = am2320.read();
if (status != AM232X_OK) return;
Expand All @@ -913,6 +914,7 @@ void Sensors::am2320Read() {
}

void Sensors::bme280Read() {
if (!isSensorRegistered(SENSORS::SBME280)) return;
float humi1 = bme280.readHumidity();
float temp1 = bme280.readTemperature();
if (isnan(humi1) || humi1 == 0 || isnan(temp1)) return;
Expand All @@ -928,6 +930,7 @@ void Sensors::bme280Read() {
}

void Sensors::bmp280Read() {
if (!isSensorRegistered(SENSORS::SBMP280)) return;
float temp1 = bmp280.readTemperature();
float press1 = bmp280.readPressure();
float alt1 = bmp280.readAltitude(sealevel);
Expand All @@ -943,6 +946,7 @@ void Sensors::bmp280Read() {
}

void Sensors::bme680Read() {
if (!isSensorRegistered(SENSORS::SBME680)) return;
if (!bme680.performReading()) return;
float temp1 = bme680.temperature;
temp = temp1 - toffset;
Expand All @@ -960,6 +964,7 @@ void Sensors::bme680Read() {
}

void Sensors::aht10Read() {
if (!isSensorRegistered(SENSORS::SAHTXX)) return;
float temp1 = aht10.readTemperature();
if (temp1 != AHTXX_ERROR) {
float humi1 = aht10.readHumidity();
Expand All @@ -973,6 +978,7 @@ void Sensors::aht10Read() {
}

void Sensors::sht31Read() {
if (!isSensorRegistered(SENSORS::SSHT31)) return;
float humi1 = sht31.readHumidity();
float temp1 = sht31.readTemperature();
if (!isnan(humi1)) humi = humi1;
Expand Down Expand Up @@ -1002,6 +1008,7 @@ void Sensors::CO2scd30Read() {
}

void Sensors::CO2scd4xRead() {
if (!isSensorRegistered(SENSORS::SSCD4X)) return;
uint16_t tCO2 = 0;
float tCO2temp, tCO2humi = 0;
uint16_t error = scd4x.readMeasurement(tCO2, tCO2temp, tCO2humi);
Expand Down Expand Up @@ -1051,6 +1058,7 @@ void Sensors::sen5xRead() {

void Sensors::GCJA5Read() {
if (dev_uart_type == SENSORS::SGCJA5) return;
if (!isSensorRegistered(SENSORS::SGCJA5)) return;
if (!pmGCJA5.isConnected()) return;
uint16_t _pm1 = pmGCJA5.getPM1_0();
uint16_t _pm25 = pmGCJA5.getPM2_5();
Expand All @@ -1067,18 +1075,21 @@ void Sensors::GCJA5Read() {
}

void Sensors::DFRobotNH3Read() {
if (!isSensorRegistered(SENSORS::SDFRNH3)) return;
if (!dfrNH3.begin()) return;
nh3 = dfrNH3.readGasConcentrationPPM();
unitRegister(UNIT::NH3);
}

void Sensors::DFRobotCORead() {
if (!isSensorRegistered(SENSORS::SDFRCO)) return;
if (!dfrCO.begin()) return;
co = dfrCO.readGasConcentrationPPM();
unitRegister(UNIT::CO);
}

void Sensors::DFRobotNO2Read() {
if (!isSensorRegistered(SENSORS::SDFRNO2)) return;
if (!dfrNO2.begin()) return;
no2 = dfrNO2.readGasConcentrationPPM();
unitRegister(UNIT::NO2);
Expand Down
4 changes: 2 additions & 2 deletions src/Sensors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include <dht_nonblocking.h>
#endif

#define CSL_VERSION "0.7.3"
#define CSL_REVISION 382
#define CSL_VERSION "0.7.4"
#define CSL_REVISION 383

/***************************************************************
* 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
Expand Down

0 comments on commit c2c0f4a

Please sign in to comment.