From 4105607aeb1d3417427f7053182a805adfed75aa Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Fri, 29 Jul 2022 11:13:35 +0200 Subject: [PATCH 01/17] added directive for disable serial2 on C3 (untested) --- src/Sensors.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 4515801a..5a1be502 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1670,12 +1670,14 @@ bool Sensors::serialInit(int pms_type, unsigned long speed_baud, int pms_rx, int break; case SERIALPORT2: + #ifndef ESP32C3 DEBUG("-->[SLIB] UART COMM port \t: Serial2"); if (pms_type == SENSORS::SSPS30) Serial2.begin(speed_baud); else Serial2.begin(speed_baud, SERIAL_8N1, pms_rx, pms_tx, false); _serial = &Serial2; + #endif break; #endif default: From 74535987d9dc34bec3e045b2c387a7087ecbe62d Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sat, 21 Jan 2023 14:00:09 +0100 Subject: [PATCH 02/17] added testing section for this device --- platformio.ini | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/platformio.ini b/platformio.ini index 84795053..5745a2f6 100644 --- a/platformio.ini +++ b/platformio.ini @@ -67,6 +67,14 @@ build_src_filter = -<*> + [env:esp32] extends = esp32_common build_src_filter = -<*> + +build_flags = + ${env.build_flags} + -D ESP32C3=1 + +[env:esp32c3] +extends = esp32_common +board = esp32-c3-devkitm-1 +build_src_filter = -<*> + [env:atmelsam] extends = atmelsam_common From 82520571e7467fa988b1d2d2fc88f60e21d0dd2d Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Thu, 26 Jan 2023 22:28:03 +0100 Subject: [PATCH 03/17] fixed issue for esp32c3 --- src/Sensors.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index b7fe7a57..62f1eef8 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1674,6 +1674,7 @@ bool Sensors::serialInit(u_int pms_type, unsigned long speed_baud, int pms_rx, i break; case SERIALPORT2: +#ifdef Serial2 DEBUG("-->[SLIB] UART COMM port \t: Serial2"); if (pms_type == SENSORS::SSPS30) Serial2.begin(speed_baud); @@ -1681,6 +1682,10 @@ bool Sensors::serialInit(u_int pms_type, unsigned long speed_baud, int pms_rx, i Serial2.begin(speed_baud, SERIAL_8N1, pms_rx, pms_tx, false); _serial = &Serial2; break; +#else + DEBUG("-->[SLIB] UART COMM port \t: Undefined"); + return false; +#endif // Serial2 #endif default: From 40f35e133b0a4410ad5b1335c6fe3e5ab72191ca Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Thu, 26 Jan 2023 22:30:03 +0100 Subject: [PATCH 04/17] revert original serial2 condition --- src/Sensors.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 1e7713b9..b7fe7a57 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1674,14 +1674,12 @@ bool Sensors::serialInit(u_int pms_type, unsigned long speed_baud, int pms_rx, i break; case SERIALPORT2: - #ifndef ESP32C3 DEBUG("-->[SLIB] UART COMM port \t: Serial2"); if (pms_type == SENSORS::SSPS30) Serial2.begin(speed_baud); else Serial2.begin(speed_baud, SERIAL_8N1, pms_rx, pms_tx, false); _serial = &Serial2; - #endif break; #endif default: From 07d8b1183996e0dd1eaee738c7a2eaf463960d0e Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Fri, 27 Jan 2023 00:03:51 +0100 Subject: [PATCH 05/17] successful test over M5Stamp C3 board (init without crash) --- examples/advanced_multivariable/src/main.cpp | 6 +++--- platformio.ini | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/advanced_multivariable/src/main.cpp b/examples/advanced_multivariable/src/main.cpp index 33116c06..7b7c6afd 100644 --- a/examples/advanced_multivariable/src/main.cpp +++ b/examples/advanced_multivariable/src/main.cpp @@ -62,12 +62,12 @@ void setup() { Serial.println("\n== Sensor test setup ==\n"); Serial.println("-->[SETUP] Detecting sensors.."); - sensors.setSampleTime(5); // config sensors sample time interval + sensors.setSampleTime(10); // config sensors sample time interval sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback - sensors.setDebugMode(false); // [optional] debug mode + sensors.setDebugMode(true); // [optional] debug mode sensors.detectI2COnly(false); // disable force to only i2c sensors sensors.init(); // Auto detection to UART and i2c sensors - delay(500); + delay(1000); } void loop() { diff --git a/platformio.ini b/platformio.ini index 0ce3d466..3f9c595c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -24,7 +24,7 @@ lib_deps = adafruit/Adafruit SCD30 @ 1.0.9 adafruit/Adafruit BusIO @ 1.14.1 robtillaart/AM232X @ 0.4.5 - paulvha/sps30 @ 1.4.14 + paulvha/sps30 @ 1.4.16 wifwaf/MH-Z19 @ 1.5.4 jcomas/S8_UART @ 1.0.1 sensirion/Sensirion Core @ 0.6.0 @@ -43,7 +43,7 @@ lib_deps = ${env.lib_deps} [esp32_common] extends = common -platform = espressif32 +platform = espressif32 @ 4.4.0 board = esp32dev [esp8266_common] From 1ed3c1ab30a053802e4c5664e2c63134b5377288 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Fri, 27 Jan 2023 22:44:21 +0100 Subject: [PATCH 06/17] changed I2C Wire1 validation only cheking the Wire1 define --- platformio.ini | 2 +- src/Sensors.cpp | 36 ++++++++++++++++++------------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/platformio.ini b/platformio.ini index 3f9c595c..015c7ee1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -43,7 +43,7 @@ lib_deps = ${env.lib_deps} [esp32_common] extends = common -platform = espressif32 @ 4.4.0 +platform = espressif32 @ 5.3.0 board = esp32dev [esp8266_common] diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 62f1eef8..675348b0 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1342,14 +1342,14 @@ void Sensors::sps30DeviceInfo() { void Sensors::am2320Init() { sensorAnnounce(SENSORS::SAM232X); - #ifdef ESP32 + #ifndef Wife1 + if (!am2320.begin()) return; + #else am2320 = AM232X(&Wire); if (!am2320.begin()) { am2320 = AM232X(&Wire1); if (!am2320.begin()) return; } - #else - if (!am2320.begin()) return; #endif am2320.wakeUp(); sensorRegister(SENSORS::SAM232X); @@ -1358,36 +1358,36 @@ void Sensors::am2320Init() { void Sensors::sht31Init() { sensorAnnounce(SENSORS::SSHT31); sht31 = Adafruit_SHT31(); - #ifdef ESP32 + #ifndef Wire1 + if (!sht31.begin()) return; + #else if (!sht31.begin()) { sht31 = Adafruit_SHT31(&Wire1); if (!sht31.begin()) return; } - #else - if (!sht31.begin()) return; #endif sensorRegister(SENSORS::SSHT31); } void Sensors::bme280Init() { sensorAnnounce(SENSORS::SBME280); - #ifdef ESP32 - if (!bme280.begin() && !bme280.begin(BME280_ADDRESS,&Wire1)) return; - #else + #ifndef Wire1 if (!bme280.begin()) return; + #else + if (!bme280.begin() && !bme280.begin(BME280_ADDRESS,&Wire1)) return; #endif sensorRegister(SENSORS::SBME280); } void Sensors::bmp280Init() { sensorAnnounce(SENSORS::SBMP280); - #ifdef ESP32 + #ifndef Wire1 + if (!bmp280.begin() && !bmp280.begin(BMP280_ADDRESS_ALT)) return; + #else if (!bmp280.begin() && !bmp280.begin(BMP280_ADDRESS_ALT)) { bmp280 = Adafruit_BMP280(&Wire1); if (!bmp280.begin() && !bmp280.begin(BMP280_ADDRESS_ALT)) return; } - #else - if (!bmp280.begin() && !bmp280.begin(BMP280_ADDRESS_ALT)) return; #endif bmp280.setSampling(Adafruit_BMP280::MODE_NORMAL, // Operating Mode. Adafruit_BMP280::SAMPLING_X2, // Temp. oversampling @@ -1427,10 +1427,10 @@ void Sensors::aht10Init() { void Sensors::CO2scd30Init() { sensorAnnounce(SENSORS::SSCD30); - #ifdef ESP32 - if (!scd30.begin() && !scd30.begin(SCD30_I2CADDR_DEFAULT, &Wire1, SCD30_CHIP_ID)) return; - #else + #ifndef Wire1 if (!scd30.begin()) return; + #else + if (!scd30.begin() && !scd30.begin(SCD30_I2CADDR_DEFAULT, &Wire1, SCD30_CHIP_ID)) return; #endif delay(10); @@ -1518,10 +1518,10 @@ void Sensors::setSCD4xAltitudeOffset(float offset) { void Sensors::GCJA5Init() { sensorAnnounce(SENSORS::SGCJA5); - #ifdef ESP32 - if (!pmGCJA5.begin() && !pmGCJA5.begin(Wire1)) return; - #else + #ifndef Wire1 if (!pmGCJA5.begin()) return; + #else + if (!pmGCJA5.begin() && !pmGCJA5.begin(Wire1)) return; #endif sensorRegister(SENSORS::SGCJA5); } From 32ccdf0f7bd19fc86d4bec3bfa99330d35ecc026 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Fri, 27 Jan 2023 22:53:28 +0100 Subject: [PATCH 07/17] deprecated DHT11 sensor (it crashes ESP32C3 core) --- src/Sensors.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 675348b0..7a0a2d83 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -963,6 +963,9 @@ void Sensors::GCJA5Read() { unitRegister(UNIT::PM10); } +/** + * @deprecated Please don't use this sensor anymore + */ bool Sensors::dhtIsReady(float *temperature, float *humidity) { static unsigned long measurement_timestamp = millis(); if (millis() - measurement_timestamp > sample_time * (uint32_t)1000) { @@ -974,11 +977,18 @@ bool Sensors::dhtIsReady(float *temperature, float *humidity) { return (false); } +/** + * @deprecated Please don't use this sensor anymore + */ void Sensors::setDHTparameters(int dht_sensor_pin, int dht_sensor_type) { DHT_nonblocking dht_sensor(DHT_SENSOR_PIN, DHT_SENSOR_TYPE); } +/** + * @deprecated Please don't use this sensor anymore + */ void Sensors::dhtRead() { +#ifdef DHT11_ENABLED if (dhtIsReady(&dhttemp, &dhthumi) != true) return; temp = dhttemp - toffset; humi = dhthumi; @@ -987,6 +997,7 @@ void Sensors::dhtRead() { DEBUG("-->[SLIB] DHTXX read\t\t: done!"); unitRegister(UNIT::TEMP); unitRegister(UNIT::HUM); +#endif } void Sensors::onSensorError(const char *msg) { @@ -1526,9 +1537,14 @@ void Sensors::GCJA5Init() { sensorRegister(SENSORS::SGCJA5); } +/** + * @deprecated Please don't use this sensor anymore + */ void Sensors::dhtInit() { +#ifdef DHT11_ENABLED sensorAnnounce(SENSORS::SDHTX); dhtRead(); +#endif } // Altitude compensation for CO2 sensors without Pressure atm or Altitude compensation From 345b0d0eff7bc0464d77e8197c8c36d307b78b0d Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Fri, 27 Jan 2023 23:46:39 +0100 Subject: [PATCH 08/17] fixed possible case error in esp32c3 --- src/Sensors.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 7a0a2d83..38fe2567 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1688,9 +1688,8 @@ bool Sensors::serialInit(u_int pms_type, unsigned long speed_baud, int pms_rx, i Serial1.begin(speed_baud, SERIAL_8N1, pms_rx, pms_tx, false); _serial = &Serial1; break; - - case SERIALPORT2: #ifdef Serial2 + case SERIALPORT2: DEBUG("-->[SLIB] UART COMM port \t: Serial2"); if (pms_type == SENSORS::SSPS30) Serial2.begin(speed_baud); From 1a14be013f6850b4ab5176b588572f3a3fd2aec1 Mon Sep 17 00:00:00 2001 From: Roberbike Date: Sat, 28 Jan 2023 01:28:19 +0100 Subject: [PATCH 09/17] test sps30 by i2c --- src/Sensors.cpp | 5 ++++- src/Sensors.hpp | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 38fe2567..5816e7fb 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1614,9 +1614,12 @@ void Sensors::startI2C() { #ifdef M5ATOM enableWire1(); #endif -#if not defined(M5STICKCPLUS) && not defined(M5COREINK) && not defined(M5ATOM) +#if not defined(M5STICKCPLUS) && not defined(M5COREINK) && not defined(M5ATOM) && not defined(ESP32C3) Wire.begin(); #endif +#ifdef ESP32C3 + Wire.begin(18,19) +#endif } void Sensors::enableWire1() { diff --git a/src/Sensors.hpp b/src/Sensors.hpp index 40725750..14de410d 100644 --- a/src/Sensors.hpp +++ b/src/Sensors.hpp @@ -69,6 +69,9 @@ #define PMS_RX 3 #define PMS_TX 1 #define DHT_SENSOR_PIN 19 +#elif ESP32C3 +#define PMS_RX 20 +#define PMS_TX 21 #else // **DEFAULT** for legacy CanAirIO devices: #define PMS_RX 17 // D1MIN1 / TTGOT7 / ESP32DEVKIT, also for main ESP32 dev boards use it From 1dad7857173c73151aece5450f86f02dee54ea8b Mon Sep 17 00:00:00 2001 From: roberbike Date: Sat, 28 Jan 2023 01:57:01 +0100 Subject: [PATCH 10/17] Update Sensors.cpp mistake with sda scl exchangued --- src/Sensors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 5816e7fb..582a491a 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1618,7 +1618,7 @@ void Sensors::startI2C() { Wire.begin(); #endif #ifdef ESP32C3 - Wire.begin(18,19) + Wire.begin(19,18) #endif } From 695e516e2124d623826595515943c23a79e98548 Mon Sep 17 00:00:00 2001 From: Roberbike Date: Sat, 28 Jan 2023 01:57:53 +0100 Subject: [PATCH 11/17] test sps30 --- src/Sensors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 5816e7fb..582a491a 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1618,7 +1618,7 @@ void Sensors::startI2C() { Wire.begin(); #endif #ifdef ESP32C3 - Wire.begin(18,19) + Wire.begin(19,18) #endif } From 97109d3d81c9ad61c6d5a438dbdadf5d28c3c848 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sat, 28 Jan 2023 11:29:17 +0100 Subject: [PATCH 12/17] added table of platforms supported --- README.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 354fd548..0a76ffb0 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,22 @@ NOTE: Panasonic via UART in ESP8266 maybe needs select in detection | BME280 | i2c | Auto | STABLE | | BMP280 | i2c | Auto | TESTING | | BME680 | i2c | Auto | STABLE | -| DHTxx | TwoWire | Auto | DEPRECATED | +| DHTxx | TwoWire | Auto | DISABLED | + +NOTE: DHT22 is supported but is not recommended. Please see the documentation. + +### Platforms supported + +| Platform | Variants | Notes | Status | +|:----------------------- |:-----:|:-------:|:----------:| +| ESP32 | WROVER* | ESP32Devkit and similar (recommended) | STABLE | +| ESP32S3 | LilyGo TDisplay | In testing | UNSTABLE | +| ESP32C3 | Devkit v3 | In testing | UNSTABLE | +| ESP8266 | 12 | D1MINI tested and similar (old) | STABLE | +| Atmelsam | seeed_wio_terminal | Only works via i2c on left port | STABLE | +| Arduino | Atmel | Some third party libraries fails | IN PROGRESS | + -NOTE: DHT22 is supported but is not recommended # Features From 39f3e2764f9f16037b61c1718e3336f73edf9f80 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sat, 28 Jan 2023 11:49:57 +0100 Subject: [PATCH 13/17] v0.6.4 esp32c3/s3 initial support and some improvements --- doxygen.conf | 2 +- library.json | 2 +- library.properties | 2 +- platformio.ini | 19 ++++++++++++++++++- src/Sensors.hpp | 4 ++-- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/doxygen.conf b/doxygen.conf index f75dfc00..eec6e389 100644 --- a/doxygen.conf +++ b/doxygen.conf @@ -38,7 +38,7 @@ PROJECT_NAME = "CanAirIO Sensors Library" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 0.6.1 +PROJECT_NUMBER = 0.6.4 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/library.json b/library.json index 371c92dc..ec2727ba 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "CanAirIO Air Quality Sensors Library", - "version": "0.6.3", + "version": "0.6.4", "homepage":"https://canair.io", "keywords": [ diff --git a/library.properties b/library.properties index eb06cbc2..bc1f67f2 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=CanAirIO Air Quality Sensors Library -version=0.6.3 +version=0.6.4 author=@hpsaturn, CanAirIO project maintainer=Antonio Vanegas url=https://github.com/kike-canaries/canairio_sensorlib diff --git a/platformio.ini b/platformio.ini index 015c7ee1..1339e9ed 100644 --- a/platformio.ini +++ b/platformio.ini @@ -36,7 +36,7 @@ lib_deps = [common] framework = ${env.framework} -upload_speed = ${env.upload_speed} +; upload_speed = ${env.upload_speed} monitor_speed = ${env.monitor_speed} build_flags = ${env.build_flags} lib_deps = ${env.lib_deps} @@ -76,6 +76,23 @@ extends = esp32_common board = esp32-c3-devkitm-1 build_src_filter = -<*> + +[env:esp32s3] +extends = esp32_common +platform = espressif32 @ 5.0.0 +board = esp32-s3-devkitc-1 +build_src_filter = -<*> + +platform_packages = framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#2.0.3 +build_flags = + ${env.build_flags} + -DBOARD_HAS_PSRAM + -DARDUINO_USB_MODE=1 + -DARDUINO_USB_CDC_ON_BOOT=1 + +board_build.partitions = default_8MB.csv +board_build.arduino.memory_type = qspi_opi +board_build.flash_size = 8MB +board_build.psram_type = opi + [env:atmelsam] extends = atmelsam_common build_src_filter = -<*> + diff --git a/src/Sensors.hpp b/src/Sensors.hpp index 40725750..4413d3ba 100644 --- a/src/Sensors.hpp +++ b/src/Sensors.hpp @@ -18,8 +18,8 @@ #include #include -#define CSL_VERSION "0.6.3" -#define CSL_REVISION 371 +#define CSL_VERSION "0.6.4" +#define CSL_REVISION 372 /*************************************************************** * 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 From 82c015c70c3cefa6beaa40ff34e87f626315a25f Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sat, 28 Jan 2023 12:49:23 +0100 Subject: [PATCH 14/17] improved documentation and fix some typo issues for release --- README.md | 21 ++++----------------- platformio.ini | 10 +++++----- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 0a76ffb0..b73607b2 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ void setup() { - // Also you can access to sub library objects, and perform for example calls like next: + // Also you can access to sub-library objects, and perform for example calls like next: // sensors.sps30.sleep() // sensors.bme.readPressure(); @@ -160,21 +160,8 @@ void loop() { } ``` -## Output - -On your serial monitor you should have something like that: - -```bash --->[SETUP] Detecting sensors.. --->[SETUP] Sensor configured: SENSIRION --->[MAIN] PM1.0: 002 PM2.5: 004 PM10: 006 --->[MAIN] PM1.0: 002 PM2.5: 002 PM10: 002 --->[MAIN] PM1.0: 002 PM2.5: 002 PM10: 002 -``` - ## Multivariable demo - In this [demo](https://www.youtube.com/watch?v=-5Va47Bap48) on two different devices with multiple sensors, you can choose the possible sub sensors units or variables: [![CanAirIO multivariable demo](https://img.youtube.com/vi/-5Va47Bap48/0.jpg)](https://www.youtube.com/watch?v=-5Va47Bap48) @@ -184,7 +171,6 @@ In this [demo](https://www.youtube.com/watch?v=uxlmP905-FE) on a simple sketch y [![CanAirIO Sensors Lib DEMO with M5CoreInk](https://img.youtube.com/vi/i15iEF47CbY/0.jpg)](https://youtu.be/i15iEF47CbY) - ## Multivariable alternative implementation The last version added new getters to have the current status of each unit of each sensor connected to the device in real time. Also you can retrieve the list of device names and other stuff: @@ -390,10 +376,11 @@ Also you can make a donation, be a patreon or buy a device: # Projects using this Library - [CanAirIO Device](https://github.com/kike-canaries/canairio_firmware): ESP32 Air quality device for mobile and fixed stations. (PM2.5 and CO2) -- [Medidor de CO2](https://emariete.com/medidor-co2-display-tft-color-ttgo-t-display-sensirion-scd30): Un medidor de CO2 de alta calidad con pantalla en color. (CO2) +- [Medidor de CO2](https://emariete.com/medidor-co2-display-tft-color-ttgo-t-display-sensirion-scd30): Un medidor de CO2 de alta calidad con pantalla en color. (CO2) +- [M5CoreInk Multi Sensor](https://github.com/hpsaturn/co2_m5coreink#readme): Wall CO2, T, H, P, Alt, sensor with low consumption (30 days) # Credits -Thanks to all collaborators and [CanAirIO](https://canair.io) community for testing and reports. +Thanks to all collaborators and [CanAirIO](https://canair.io) community for testing and reports. Visit us on [Telegram](https://t.me/canairio) --- diff --git a/platformio.ini b/platformio.ini index 1339e9ed..985ae402 100644 --- a/platformio.ini +++ b/platformio.ini @@ -43,7 +43,7 @@ lib_deps = ${env.lib_deps} [esp32_common] extends = common -platform = espressif32 @ 5.3.0 +platform = espressif32 board = esp32dev [esp8266_common] @@ -83,10 +83,10 @@ board = esp32-s3-devkitc-1 build_src_filter = -<*> + platform_packages = framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#2.0.3 build_flags = - ${env.build_flags} - -DBOARD_HAS_PSRAM - -DARDUINO_USB_MODE=1 - -DARDUINO_USB_CDC_ON_BOOT=1 + ${env.build_flags} + -DBOARD_HAS_PSRAM + -DARDUINO_USB_MODE=1 + -DARDUINO_USB_CDC_ON_BOOT=1 board_build.partitions = default_8MB.csv board_build.arduino.memory_type = qspi_opi From daa5965dd5b0f8becf79c3887d2d436ae30f97c4 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sat, 28 Jan 2023 13:08:25 +0100 Subject: [PATCH 15/17] fixed missing version of sps30 library on examples for CI --- examples/advanced_sensirion/platformio.ini | 2 +- library.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/advanced_sensirion/platformio.ini b/examples/advanced_sensirion/platformio.ini index 97cdf9f4..c70c80d7 100644 --- a/examples/advanced_sensirion/platformio.ini +++ b/examples/advanced_sensirion/platformio.ini @@ -33,7 +33,7 @@ lib_deps = adafruit/Adafruit SCD30 @ 1.0.9 adafruit/Adafruit BusIO @ 1.14.1 robtillaart/AM232X @ 0.4.5 - paulvha/sps30 @ 1.4.14 + paulvha/sps30 @ 1.4.16 wifwaf/MH-Z19 @ 1.5.4 jcomas/S8_UART @ 1.0.1 sensirion/Sensirion Core @ 0.6.0 diff --git a/library.json b/library.json index ec2727ba..6d817faf 100644 --- a/library.json +++ b/library.json @@ -83,7 +83,7 @@ {"name":"Adafruit SCD30", "owner":"adafruit","version":"1.0.9"}, {"name":"Adafruit BusIO", "owner":"adafruit","version":"1.14.1"}, {"name":"AM232X", "owner":"robtillaart", "version":"0.4.5"}, - {"name":"sps30", "owner":"paulvha","version":"1.4.14"}, + {"name":"sps30", "owner":"paulvha","version":"1.4.16"}, {"name":"MH-Z19", "owner":"wifwaf", "version":"1.5.4"}, {"name":"S8_UART", "owner":"jcomas", "version":"1.0.1"}, {"name":"Sensirion Core","owner":"sensirion","version":"0.6.0"}, From c58326e1ebd72754a8af6f26b40d500dedadc4d6 Mon Sep 17 00:00:00 2001 From: Roberbike Date: Sat, 28 Jan 2023 21:48:02 +0100 Subject: [PATCH 16/17] correccion --- src/Sensors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 582a491a..8e045e4c 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1618,7 +1618,7 @@ void Sensors::startI2C() { Wire.begin(); #endif #ifdef ESP32C3 - Wire.begin(19,18) + Wire.begin(19,18); #endif } From fd3e28537a00bd6e9ab84044b6e24bf0716225fd Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sun, 29 Jan 2023 12:13:07 +0100 Subject: [PATCH 17/17] fixed some issues on deprecation DHT11 methods and library --- platformio.ini | 3 +++ src/Sensors.cpp | 31 ++++++++++++++++--------------- src/Sensors.hpp | 32 +++++++++++++------------------- 3 files changed, 32 insertions(+), 34 deletions(-) diff --git a/platformio.ini b/platformio.ini index 985ae402..0fb9b2ed 100644 --- a/platformio.ini +++ b/platformio.ini @@ -14,6 +14,9 @@ monitor_speed = 115200 monitor_filters = time build_flags = -D CORE_DEBUG_LEVEL=0 + ; -D DHT11_ENABLED=1 // Deprecated, please change this old sensor + ; -D DHT_SENSOR_TYPE=2 + ; -D DHT_SENSOR_PIN=19 lib_deps = adafruit/Adafruit Unified Sensor @ 1.1.7 diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 8e045e4c..5b81617e 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1,6 +1,5 @@ #include "Sensors.hpp" -DHT_nonblocking dht_sensor(DHT_SENSOR_PIN, DHT_SENSOR_TYPE); // Units and sensors registers @@ -46,7 +45,9 @@ void Sensors::loop() { _onErrorCb("[W][SLIB] Sensorslib error msg\t: No data from any sensor!"); } + #ifdef DHT11_ENABLED dhtRead(); // DHT2x sensors need check fastest + #endif } void Sensors::printHumTemp() { @@ -74,7 +75,11 @@ bool Sensors::readAllSensors() { bmp280Read(); bme680Read(); aht10Read(); + + #ifdef DHT11_ENABLED dhtRead(); + #endif + disableWire1(); printValues(); @@ -120,7 +125,11 @@ void Sensors::init(u_int pms_type, int pms_rx, int pms_tx) { am2320Init(); sht31Init(); aht10Init(); + + #ifdef DHT11_ENABLED dhtInit(); + #endif + printSensorsRegistered(true); } @@ -963,6 +972,8 @@ void Sensors::GCJA5Read() { unitRegister(UNIT::PM10); } +#ifdef DHT11_ENABLED +DHT_nonblocking dht_sensor(DHT_SENSOR_PIN, DHT_SENSOR_TYPE); /** * @deprecated Please don't use this sensor anymore */ @@ -980,15 +991,15 @@ bool Sensors::dhtIsReady(float *temperature, float *humidity) { /** * @deprecated Please don't use this sensor anymore */ -void Sensors::setDHTparameters(int dht_sensor_pin, int dht_sensor_type) { - DHT_nonblocking dht_sensor(DHT_SENSOR_PIN, DHT_SENSOR_TYPE); +void Sensors::dhtInit() { + sensorAnnounce(SENSORS::SDHTX); + dhtRead(); } /** * @deprecated Please don't use this sensor anymore */ void Sensors::dhtRead() { -#ifdef DHT11_ENABLED if (dhtIsReady(&dhttemp, &dhthumi) != true) return; temp = dhttemp - toffset; humi = dhthumi; @@ -997,8 +1008,8 @@ void Sensors::dhtRead() { DEBUG("-->[SLIB] DHTXX read\t\t: done!"); unitRegister(UNIT::TEMP); unitRegister(UNIT::HUM); -#endif } +#endif void Sensors::onSensorError(const char *msg) { DEBUG(msg); @@ -1537,16 +1548,6 @@ void Sensors::GCJA5Init() { sensorRegister(SENSORS::SGCJA5); } -/** - * @deprecated Please don't use this sensor anymore - */ -void Sensors::dhtInit() { -#ifdef DHT11_ENABLED - sensorAnnounce(SENSORS::SDHTX); - dhtRead(); -#endif -} - // Altitude compensation for CO2 sensors without Pressure atm or Altitude compensation void Sensors::CO2correctionAlt() { diff --git a/src/Sensors.hpp b/src/Sensors.hpp index 6be14a66..53aa225d 100644 --- a/src/Sensors.hpp +++ b/src/Sensors.hpp @@ -13,11 +13,14 @@ #include #include #include -#include #include #include #include +#ifdef DHT11_ENABLED +#include +#endif + #define CSL_VERSION "0.6.4" #define CSL_REVISION 372 @@ -28,47 +31,36 @@ #ifdef WEMOSOLED #define PMS_RX 13 // config for Wemos board & TTGO18650 #define PMS_TX 15 // some old TTGO18650 have PMS_RX 18 & PMS_TX 17 -#define DHT_SENSOR_PIN 23 // default DHT sensor pin #elif HELTEC #define PMS_RX 17 // config for Heltec board, ESP32Sboard & ESPDUINO-32. Use Uart2 #define PMS_TX 18 // some old ESP32Sboard have PMS_RX 27 & PMS_TX 25. Jump Uart2 tx from 16 to 18. !6 used by Oled. -#define DHT_SENSOR_PIN 23 #elif TTGO_TQ #define PMS_RX 13 #define PMS_TX 18 -#define DHT_SENSOR_PIN 23 #elif M5COREINK #define PMS_RX 13 // config for backward header in M5CoreInk #define PMS_TX 14 -#define DHT_SENSOR_PIN 25 #elif TTGO_TDISPLAY #define PMS_RX 13 #define PMS_TX 12 -#define DHT_SENSOR_PIN 17 #elif ESP32PICOD4 #define PMS_RX 19 #define PMS_TX 18 -#define DHT_SENSOR_PIN 12 #elif ESP32GENERIC #define PMS_RX RX #define PMS_TX TX -#define DHT_SENSOR_PIN 12 #elif M5STICKCPLUS #define PMS_RX 36 // provisional for M5StickCPlus board for now #define PMS_TX 0 -#define DHT_SENSOR_PIN 34 #elif M5COREINK #define PMS_RX 13 #define PMS_TX 14 -#define DHT_SENSOR_PIN 34 #elif M5ATOM #define PMS_RX 23 #define PMS_TX 33 -#define DHT_SENSOR_PIN 19 #elif M5PICOD4 #define PMS_RX 3 #define PMS_TX 1 -#define DHT_SENSOR_PIN 19 #elif ESP32C3 #define PMS_RX 20 #define PMS_TX 21 @@ -76,7 +68,6 @@ #else // **DEFAULT** for legacy CanAirIO devices: #define PMS_RX 17 // D1MIN1 / TTGOT7 / ESP32DEVKIT, also for main ESP32 dev boards use it #define PMS_TX 16 -#define DHT_SENSOR_PIN 23 // default DHT sensor pin #endif // I2C pins for M5COREINK and M5STICKCPLUS @@ -85,9 +76,6 @@ #define EXT_I2C_SDA 32 #define EXT_I2C_SCL 33 -// DHT sensor type -#define DHT_SENSOR_TYPE DHT_TYPE_22 - // Read UART sensor retry. #define SENSOR_RETRY 1000 // Max Serial characters @@ -192,8 +180,11 @@ class Sensors { AHTxx aht10; // SHT31 Adafruit_SHT31 sht31; + + #ifdef DHT11_ENABLED // DHT sensor float dhthumi, dhttemp; + #endif // Mhz19 sensor MHZ19 mhz19; // SCD30 sensor @@ -232,8 +223,6 @@ class Sensors { void setDebugMode(bool enable); - void setDHTparameters(int dht_sensor_pin = DHT_SENSOR_PIN, int dht_sensor_type = DHT_SENSOR_TYPE); - bool isUARTSensorConfigured(); int getUARTDeviceTypeSelected(); @@ -311,8 +300,11 @@ class Sensors { void printSensorsRegistered(bool debug = false); private: + + #ifdef DHT11_ENABLED /// DHT library uint32_t delayMS; + #endif /// For UART sensors (autodetected available serial) Stream *_serial; /// Callback on some sensors error. @@ -379,10 +371,12 @@ class Sensors { void GCJA5Init(); void GCJA5Read(); - + + #ifdef DHT11_ENABLED void dhtInit(); void dhtRead(); bool dhtIsReady(float *temperature, float *humidity); + #endif // UART sensors methods: