Skip to content

Commit

Permalink
Merge pull request #181 from melkati/development
Browse files Browse the repository at this point in the history
Merge Development Closes #180
  • Loading branch information
melkati authored Feb 20, 2024
2 parents f01a523 + 10c55b3 commit 9122da1
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 28 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/release3.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
18 changes: 14 additions & 4 deletions CO2_Gadget.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand All @@ -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() {
Expand Down
31 changes: 31 additions & 0 deletions CO2_Gadget_Sensors.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()));
}
}
}

Expand Down
10 changes: 7 additions & 3 deletions CO2_Gadget_WIFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
};
});
Expand Down
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<table>
<tr>
<td>
Don't forget to star ⭐ this repository
</td>
</tr>
</table>

# 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).
Expand Down Expand Up @@ -58,23 +66,22 @@ 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.
- RX / TX: Pins (GPIO) used for sensors connected by serial port.
- 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.
Expand Down
11 changes: 4 additions & 7 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9122da1

Please sign in to comment.