Skip to content

Commit

Permalink
Merge pull request #109 from kike-canaries/fix_issue_102
Browse files Browse the repository at this point in the history
Fix issue 102 and refactor device_type on UART
  • Loading branch information
hpsaturn authored Dec 7, 2021
2 parents ad6b328 + bcb8d7a commit 6e5014d
Show file tree
Hide file tree
Showing 18 changed files with 120 additions and 98 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ void setup() {
// sensors.s8.set_ABC_period(period)
// ...


if(sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());
Serial.println("-->[SETUP] Sensor configured: " + sensors.getMainDeviceSelected());

delay(500);
}
Expand Down
7 changes: 3 additions & 4 deletions examples/advanced_sensirion/sensirion.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ void setup() {
sensors.setOnErrorCallBack(&onSensorDataError); // [optional] error callback
sensors.setDebugMode(true); // [optional] debug mode

sensors.init(sensors.Sensirion); // forced Sensirion via UART.
// for i2c only leave empty this parameter
sensors.init(sensors.Sensirion); // Forced Sensirion via UART, default is I2C
// For Sensirion with i2c only leave empty this parameter

if(sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());
Serial.println("-->[SETUP] Sensor configured: " + sensors.getMainDeviceSelected());

delay(500);
}
Expand Down
6 changes: 3 additions & 3 deletions examples/basic/basic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ void setup() {
// sensors.init(sensors.CM1006); // Force detection to CM1106 CO2 sensor
// sensors.init(sensors.Auto,mRX,mTX); // Auto detection and custom RX, TX pines
// sensors.init(sensors.Auto,PMS_RX,PMS_TX); // Auto detection, custom RX,TX and custom DHT config
// sensors.detectI2COnly(true); // Force only i2c sensors

sensors.init(); // Force detection to Sensirion sensor

if(sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());

Serial.println("-->[SETUP] Sensor configured: " + sensors.getMainDeviceSelected());

delay(500);
}
Expand Down
6 changes: 3 additions & 3 deletions examples/basic_esp8266/basic_esp8266.ino
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ void setup() {
// sensors.init(sensors.Auto,PMS_RX,PMS_TX); // Auto detection, custom RX,TX and custom DHT config

sensors.init(sensors.Panasonic, 5, 6); // Panasonic sensor with ESP8266 software serial pines

if(sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());
// default is empty (I2C pines)

Serial.println("-->[SETUP] Sensor configured: " + sensors.getMainDeviceSelected());

delay(500);
}
Expand Down
7 changes: 3 additions & 4 deletions examples/co2_cm1106/co2_cm1106.ino
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ void setup() {

// sensors.setCO2RecalibrationFactor(400); // calibration method (in outdoors)

sensors.init(sensors.CM1106);

if (sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());
sensors.init(sensors.CM1106); // forced UART sensor. Empty for auto detection

Serial.println("-->[SETUP] Sensor configured: " + sensors.getMainDeviceSelected());

delay(500);
}
Expand Down
5 changes: 2 additions & 3 deletions examples/co2_cm1106/co2_cm1106_altitude_comp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ void setup() {

// sensors.setCO2RecalibrationFactor(400); // calibration method (in outdoors)

sensors.init(sensors.CM1106);
sensors.init(sensors.CM1106); // forced UART sensor. (empty for auto detection)

if (sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());
Serial.println("-->[SETUP] Sensor configured: " + sensors.getMainDeviceSelected());

delay(500);
}
Expand Down
7 changes: 3 additions & 4 deletions examples/co2_mhz19/co2_mhz19.ino
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ void setup() {

// sensors.setCO2RecalibrationFactor(400); // calibration method (in outdoors)

sensors.init(sensors.Mhz19);

if (sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());
sensors.init(sensors.Mhz19); // forced UAQ sensor. Empty for auto detection

Serial.println("-->[SETUP] Sensor configured: " + sensors.getMainDeviceSelected());

delay(500);
}
Expand Down
6 changes: 2 additions & 4 deletions examples/co2_scd30/co2_scd30.ino
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ void setup() {
sensors.detectI2COnly(true); // force to only i2c sensors

// sensors.setCO2RecalibrationFactor(400); // calibration method (in outdoors)

sensors.scd30.setTemperatureOffset(2.0); // example to set temp offset
// sensors.scd30.setTemperatureOffset(2.0); // example to set temp offset

sensors.init();

if (sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());
Serial.println("-->[SETUP] Sensor configured: " + sensors.getMainDeviceSelected());

delay(500);
}
Expand Down
5 changes: 2 additions & 3 deletions examples/co2_scd30/co2_scd30_altitude_comp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ void setup() {
// sensors.setCO2RecalibrationFactor(400); // calibration method (in outdoors)

sensors.init();

if (sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());

Serial.println("-->[SETUP] Sensor configured: " + sensors.getMainDeviceSelected());

delay(500);
}
Expand Down
14 changes: 4 additions & 10 deletions examples/co2_scd4x/co2_scd4x.ino
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,13 @@ void setup() {
sensors.setOnErrorCallBack(&onSensorDataError); // [optional] error callback
sensors.setDebugMode(false); // [optional] debug mode
sensors.detectI2COnly(true); // force to only i2c sensors

if (sensors.getPmDeviceSelected().equals("SCD4x")) {
Serial.println("-->[SETUP] SCD4x detected");
}

sensors.setCO2RecalibrationFactor(1282); // calibration method (in outdoors)

sensors.scd4x.setTemperatureOffset(2.0); // example to set temp offset

// sensors.setCO2RecalibrationFactor(1282); // calibration method (in outdoors)
// sensors.scd4x.setTemperatureOffset(2.0); // example to set temp offset

sensors.init();

if (sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());
Serial.println("-->[SETUP] Sensor configured: " + sensors.getMainDeviceSelected());

delay(500);
}
Expand Down
5 changes: 2 additions & 3 deletions examples/platformio/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ void setup() {
// sensors.init(sensors.Auto,PMS_RX,PMS_TX); // Auto detection, custom RX,TX and custom DHT config

sensors.init();

if(sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());

Serial.println("-->[SETUP] Sensor configured: " + sensors.getMainDeviceSelected());

delay(500);
}
Expand Down
5 changes: 2 additions & 3 deletions examples/pm_sds011/pm_sds011.ino
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ void setup() {
sensors.setOnErrorCallBack(&onSensorDataError); // [optional] error callback
sensors.setDebugMode(true); // [optional] debug mode

sensors.init(sensors.SDS011);
sensors.init(sensors.SDS011); // forced for SDS011 via UART, empty for auto detection

if (sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());
Serial.println("-->[SETUP] Sensor configured: " + sensors.getMainDeviceSelected());

delay(500);
}
Expand Down
3 changes: 1 addition & 2 deletions examples/sps30i2c/sps30i2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ void setup() {

sensors.init();

if(sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());
Serial.println("-->[SETUP] Sensor configured: " + sensors.getMainDeviceSelected());

delay(500);
}
Expand Down
5 changes: 4 additions & 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.4.0",
"version": "0.4.1",
"homepage":"https://canair.io",
"keywords":
[
Expand All @@ -16,6 +16,9 @@
"PMS7003",
"PMS5003",
"AM2320",
"BMP280",
"BME280",
"BME680",
"mhz19",
"scd30",
"scd4x",
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.4.0
version=0.4.1
author=@hpsaturn, CanAirIO project <[email protected]>
maintainer=Antonio Vanegas <[email protected]>
url=https://github.com/kike-canaries/canairio_sensorlib
Expand Down
6 changes: 3 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ upload_speed = 1500000
monitor_speed = 115200
monitor_filters = time
build_flags =
-D SRC_REV=339
-D SRC_REV=340
-D CORE_DEBUG_LEVEL=0
lib_deps =
adafruit/Adafruit Unified Sensor @ 1.1.4
adafruit/Adafruit Unified Sensor @ 1.1.4
adafruit/Adafruit BME280 Library @ 2.2.1
adafruit/Adafruit BMP280 Library @ 2.4.3
adafruit/Adafruit BME680 Library @ 2.0.1
Expand All @@ -27,7 +27,7 @@ lib_deps =
paulvha/sps30 @ 1.4.11
wifwaf/MH-Z19 @ 1.5.3
sparkfun/SparkFun SCD30 Arduino Library @ 1.0.16
sensirion/Sensirion Core @ 0.5.3
sensirion/Sensirion Core @ 0.5.3
sensirion/Sensirion I2C SCD4x @ 0.3.1
https://github.com/hpsaturn/DHT_nonblocking.git
https://github.com/paulvha/SN-GCJA5.git
Expand Down
Loading

0 comments on commit 6e5014d

Please sign in to comment.