diff --git a/.github/workflows/release3.yml b/.github/workflows/release3.yml index c83c15b4..3ae761df 100644 --- a/.github/workflows/release3.yml +++ b/.github/workflows/release3.yml @@ -1,11 +1,11 @@ -name: Release V2.4 +name: Release V2.5 # # # # # # # # # # # # To create new release, just push a new tag with the format v* (v1.0, v2.0, v2.1, v2.2, etc) # # In a terminal in platformIO do, for example: -# git tag -a v0.8.005 -m "For general release v0.8.005" -# git push origin v0.8.005 +# git tag -a v0.10.005 -m "For general release v0.10.005" +# git push origin v0.10.005 # # # # # # # # # # # on: @@ -206,4 +206,5 @@ jobs: PORT: 21 ARGS: --verbose - name: Clean eMariete.com Cache - run: curl https://emariete.com/clean_cache.php + # run: curl https://emariete.com/clean_cache_wp_rocket.php + run: curl https://emariete.com/clean_cache_litespeed.php diff --git a/CO2_Gadget.ino b/CO2_Gadget.ino index 5b55ac34..5e262cde 100644 --- a/CO2_Gadget.ino +++ b/CO2_Gadget.ino @@ -323,8 +323,10 @@ void processPendingCommands() { } void initGPIO() { + #ifdef GREEN_PIN pinMode(GREEN_PIN, OUTPUT); digitalWrite(GREEN_PIN, LOW); + #endif pinMode(BLUE_PIN, OUTPUT); digitalWrite(BLUE_PIN, LOW); pinMode(RED_PIN, OUTPUT); @@ -333,12 +335,14 @@ void initGPIO() { void outputsRelays() { if ((!outputsModeRelay) || (co2 == 0)) return; // Don't turn on relays until there is CO2 Data + #ifdef GREEN_PIN if (co2 >= co2OrangeRange) { digitalWrite(GREEN_PIN, GREEN_PIN_LOW); } if (co2 < co2OrangeRange) { digitalWrite(GREEN_PIN, GREEN_PIN_HIGH); } + #endif if (co2 >= co2OrangeRange) { digitalWrite(BLUE_PIN, BLUE_PIN_HIGH); } @@ -356,20 +360,26 @@ void outputsRelays() { void outputsRGBLeds() { if ((outputsModeRelay) || (co2 == 0)) return; // Don't turn on led until there is CO2 Data if (co2 > co2RedRange) { - digitalWrite(RED_PIN, RED_PIN_HIGH); + #ifdef GREEN_PIN digitalWrite(GREEN_PIN, GREEN_PIN_LOW); + #endif + digitalWrite(RED_PIN, RED_PIN_HIGH); digitalWrite(BLUE_PIN, BLUE_PIN_LOW); return; } if (co2 >= co2OrangeRange) { - digitalWrite(BLUE_PIN, BLUE_PIN_LOW); + #ifdef GREEN_PIN digitalWrite(GREEN_PIN, GREEN_PIN_HIGH); + #endif + digitalWrite(BLUE_PIN, BLUE_PIN_LOW); digitalWrite(RED_PIN, RED_PIN_HIGH); return; } + #ifdef GREEN_PIN digitalWrite(GREEN_PIN, GREEN_PIN_HIGH); - digitalWrite(BLUE_PIN, GREEN_PIN_LOW); - digitalWrite(RED_PIN, GREEN_PIN_LOW); + #endif + digitalWrite(BLUE_PIN, BLUE_PIN_LOW); + digitalWrite(RED_PIN, RED_PIN_LOW); } void outputsLoop() { diff --git a/CO2_Gadget_Sensors.h b/CO2_Gadget_Sensors.h index 8d1dd23c..878b145f 100644 --- a/CO2_Gadget_Sensors.h +++ b/CO2_Gadget_Sensors.h @@ -55,6 +55,32 @@ void onSensorDataOk() { void onSensorDataError(const char *msg) { Serial.println(msg); } +// To move into the sensorlib +uint16_t getSCD4xFeatureSet() { + uint16_t featureSet = 0; + uint16_t error = 0; + error = sensors.scd4x.stopPeriodicMeasurement(); + error = sensors.scd4x.getFeatures(featureSet); + if (error != 0) { + Serial.println("-->[SENS] SCD4x getFeatures error: " + String(error)); + } else { + uint8_t typeOfSensor = ((featureSet & 0x1000) >> 12); + switch (typeOfSensor) { + case 0: + Serial.println("-->[SENS] SCD4x Sensor Type: SCD40"); + break; + case 1: + Serial.println("-->[SENS] SCD4x Sensor Type: SCD41"); + break; + default: + Serial.println("-->[SENS] SCD4x Sensor Type: Unknown (probably unsupported SCD42 obsolete sensor)"); + break; + } + } + sensors.scd4x.startPeriodicMeasurement(); + return featureSet; +} + void initSensors() { const int8_t None = -1, AUTO = 0, MHZ19 = 4, CM1106 = 5, SENSEAIRS8 = 6, DEMO = 127; if (firstCO2SensorInit) { @@ -125,6 +151,11 @@ void initSensors() { if (!sensorsGetMainDeviceSelected().isEmpty()) { Serial.println("-->[SENS] Sensor configured: " + sensorsGetMainDeviceSelected()); + + // Temporary getFeatureSet() for SCD4x. To be moved into the sensorlib + if (sensorsGetMainDeviceSelected() == "SCD4X") { + Serial.println("-->[SENS] SCD4x Feature Set: " + String(getSCD4xFeatureSet())); + } } } diff --git a/CO2_Gadget_WIFI.h b/CO2_Gadget_WIFI.h index 2402c1ca..d38daa5d 100644 --- a/CO2_Gadget_WIFI.h +++ b/CO2_Gadget_WIFI.h @@ -573,9 +573,13 @@ void initWebServer() { inputString = request->getParam(PARAM_INPUT_2)->value(); if (checkStringIsNumerical(inputString)) { Serial.printf("-->[WiFi] Received /settings command CalibrateCO2 with parameter %s\n", inputString); - calibrationValue = inputString.toInt(); - pendingCalibration = true; - request->send(200, "text/plain", "OK. Recalibrating CO2 sensor to " + inputString); + if ((inputString.toInt() >= 400) && (inputString.toInt() <= 2000)) { + calibrationValue = inputString.toInt(); + pendingCalibration = true; + request->send(200, "text/plain", "OK. Recalibrating CO2 sensor to " + inputString); + } else { + request->send(200, "text/plain", "Error. CO2 calibration value must be between 400 and 2000"); + } } }; }); diff --git a/README.md b/README.md index 3ab55a86..7c780f27 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,14 @@ [![Telegram Group](https://img.shields.io/endpoint?color=neon&style=flat-square&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Femariete_chat)](https://t.me/emariete_chat) ![Twitter Follow](https://img.shields.io/twitter/follow/e_mariete?style=social) + + + + +
+ Don't forget to star ⭐ this repository +
+ # CO2-Gadget An advanced fimware for CO2 Monitor/Meter. It's really flexible, you can use this firmware with **any supported CO2 Monitor/Meter** based on ESP32 (99,99% of them). @@ -58,15 +66,15 @@ Supporting any other ESP32 board is very easy. Yoy just have to setup the pines These are the GPIOs used by each predefined board: -| Flavor | Display | RX/TX | I2C | UP/DWN | GPIO EN | GPIO Green | GPIO Orange | GPIO Red | GPIO Battery | GPIO Neopixel | GPIO Buzzer -|:-----------------------|:----------------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:| -| TTGO_TDISPLAY TFT | TFT 240×135 | 13/12 | 21/22 | 35/0 | -- | 25 | 32 | 33 | 34 | 26 | 2 -| TTGO_TDISPLAY_SANDWICH | TFT 240×135 | 13/12 | 22/21 | 35/0 | -- | 25 | 32 | 33 | 34 | 26 | 2 -| TDISPLAY_S3 | TFT 320x170 | 18/17 | 42/43 | 14/0 | -- | 02 | 03 | 01 | 04 | 16 | 2 -| esp32dev_OLED SSH1106 | SSH1106 128×64 | 17/16 | 21/22 | 15/0 | -- | 25 | 32 | 33 | 34 | 26 | 2 -| esp32dev | No display | 17/16 | 21/22 | 15/0 | -- | 25 | 32 | 33 | 34 | 26 | 2 -| esp32dev-sandwich | No display | 17/16 | 22/21 | 15/0 | -- | 25 | 32 | 33 | 34 | 26 | 2 -| esp32dev-ST7789_240x320 | ST7789_240x320 | 17/16 | 21/22 | 19/0 | -- | 25 | 32 | 33 | 34 | 26 | 2 +| Flavor | Display | RX/TX | I2C | UP/DWN | GPIO Orange | GPIO Red | GPIO Battery | GPIO Neopixel | GPIO Buzzer +|:-----------------------|:----------------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:| +| TTGO_TDISPLAY TFT | TFT 240×135 | 13/12 | 21/22 | 35/0 | 32 | 33 | 34 | 26 | 2 +| TTGO_TDISPLAY_SANDWICH | TFT 240×135 | 13/12 | 22/21 | 35/0 | 32 | 33 | 34 | 26 | 2 +| TDISPLAY_S3 | TFT 320x170 | 18/17 | 42/43 | 14/0 | 03 | 01 | 04 | 16 | 2 +| esp32dev_OLED SSH1106 | SSH1106 128×64 | 17/16 | 21/22 | 15/0 | 32 | 33 | 34 | 26 | 2 +| esp32dev | No display | 17/16 | 21/22 | 15/0 | 32 | 33 | 34 | 26 | 2 +| esp32dev-sandwich | No display | 17/16 | 22/21 | 15/0 | 32 | 33 | 34 | 26 | 2 +| esp32dev-ST7789_240x320 | ST7789_240x320 | 17/16 | 21/22 | 19/0 | 32 | 33 | 34 | 26 | 2 - Flavour: Name of the firmware variant. - Display: Display supported by each flavour. @@ -74,7 +82,6 @@ These are the GPIOs used by each predefined board: - I2C: Pins (GPIO) corresponding to the I2C bus for connection of I2C sensors and displays. - UP / DWN: Pins (GPIO) to which to connect the "Up" and "Down" buttons. They are optional as CO2 Gadget is fully functional with no buttons attached. - EN: Pin (GPIO) that supplies an ENABLE signal for switching the sensors on and off (reserved for future use). -- Green GPIO: Pin (GPIO) corresponding to the output before reaching the orange level (for relays, alarms, and RGB LED). - GPIO Orange: Pin (GPIO) corresponding to the output when the orange level is reached (for relays, alarms, and RGB LED). - GPIO Red: Pin (GPIO) corresponding to the output when the orange level is reached (for relays, alarms, and RGB LED). - GPIO Battery: Pin for battery voltage measurement. diff --git a/platformio.ini b/platformio.ini index 9d18156e..940cc6d4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -37,9 +37,10 @@ lib_deps = bblanchon/ArduinoJson @ ^7.0.1 neu-rah/ArduinoMenu library @ ^4.21.4 lennarthennigs/Button2 @ ^1.6.5 - ; hpsaturn/CanAirIO Air Quality Sensors Library @ ^0.7.3 ; Temprary remove until Issue with Sensors::setTempOffset(float offset) for SCD30 #155 is resolved + https://github.com/melkati/arduino-i2c-scd4x.git#featureset + ; hpsaturn/CanAirIO Air Quality Sensors Library @ ^0.7.3 ; Temporary remove until Issue with Sensors::setTempOffset(float offset) for SCD30 #155 is resolved https://github.com/melkati/canairio_sensorlib.git#fixOffset - https://github.com/Sensirion/arduino-upt-core.git#b2c0e76 + https://github.com/Sensirion/arduino-upt-core.git#b2c0e76 ; Temprorary fix for arduino-ble-gadget incompatility with last version arduino-upt-core library https://github.com/melkati/arduino-ble-gadget.git https://github.com/melkati/Improv-WiFi-Library.git ; neu-rah/streamFlow @ 0.0.0-alpha+sha.bf16ce8926 ; Needed for -D MENU_DEBUG @@ -60,7 +61,7 @@ build_flags = -D MQTT_BROKER_SERVER="\"192.168.1.145"\" -D CO2_GADGET_VERSION="\"0.10."\" - -D CO2_GADGET_REV="\"000"\" + -D CO2_GADGET_REV="\"005"\" -D CORE_DEBUG_LEVEL=0 -DCACHE_DIR=".pio/build" -DBUZZER_PIN=2 ; ESP32 pin GPIO13 connected to piezo buzzer @@ -75,9 +76,6 @@ build_flags = -DRED_PIN=33 ; GPIO to go HIGH on red color range -DRED_PIN_LOW=0 -DRED_PIN_HIGH=1 ; Should the RED_PIN_HIGH go high or low at threshold - -DGREEN_PIN=25 ; GPIO to go HIGH bellow range (goes LOW at orange range) - -DGREEN_PIN_LOW=0 - -DGREEN_PIN_HIGH=1 ; Should the GREEN_PIN_HIGH go high or low bellow orange threshold -DPIN_HYSTERESIS=100 ; Hysteresis PPM to avoid pins going ON and OFF continuously. TODO : Minimum time to switch -DBUZZER_HYSTERESIS=50 ; Hysteresis PPM to avoid BUZZER ON and OFF -DWIFI_PRIVACY ; Comment to show WiFi password in serial and the menu (intended for debugging) @@ -265,7 +263,6 @@ build_flags = -UENABLE_PIN ; ENABLE_PIN not supported in T-Display S3 -UENABLE_PIN_HIGH ; ENABLE_PIN not supported in T-Display S3 -DRED_PIN=01 ; GPIO to go HIGH on red color range - -DGREEN_PIN=02 ; GPIO to go HIGH bellow range (goes LOW at orange range) -DBLUE_PIN=03 ; GPIO to go HIGH on orange color range -DSUPPORT_TFT -DLV_LVGL_H_INCLUDE_SIMPLE