From f7e85a92e8172801218671b3d8c3f942ee3e5146 Mon Sep 17 00:00:00 2001 From: Achim Date: Thu, 29 Feb 2024 17:58:14 +0700 Subject: [PATCH 01/10] Uped version Nr. Renamed examples. --- examples/{ONE_I-9PSL/ONE_I-9PSL.ino => ONE/ONE.ino} | 2 +- library.properties | 2 +- src/AirGradient.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename examples/{ONE_I-9PSL/ONE_I-9PSL.ino => ONE/ONE.ino} (99%) diff --git a/examples/ONE_I-9PSL/ONE_I-9PSL.ino b/examples/ONE/ONE.ino similarity index 99% rename from examples/ONE_I-9PSL/ONE_I-9PSL.ino rename to examples/ONE/ONE.ino index fc99d541..ead45dd2 100644 --- a/examples/ONE_I-9PSL/ONE_I-9PSL.ino +++ b/examples/ONE/ONE.ino @@ -1,4 +1,4 @@ -/* + /* This is the code for the AirGradient ONE open-source hardware indoor Air Quality Monitor with an ESP32-C3 Microcontroller. diff --git a/library.properties b/library.properties index 2941f5b6..0c53a510 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=AirGradient Air Quality Sensor -version=3.0.4 +version=3.0.5 author=AirGradient maintainer=AirGradient sentence=ESP32-C3 / ESP8266 library for air quality monitor measuring PM, CO2, Temperature, TVOC and Humidity with OLED display. diff --git a/src/AirGradient.cpp b/src/AirGradient.cpp index d5969fa9..cf5c43a2 100644 --- a/src/AirGradient.cpp +++ b/src/AirGradient.cpp @@ -1,6 +1,6 @@ #include "AirGradient.h" -#define AG_LIB_VER "3.0.4" +#define AG_LIB_VER "3.0.5" AirGradient::AirGradient(BoardType type) : pms5003(type), pms5003t_1(type), pms5003t_2(type), s8(type), sgp41(type), From 852fdc43609abc0f09f57ff09e1670dff9db23c7 Mon Sep 17 00:00:00 2001 From: Achim Date: Thu, 29 Feb 2024 17:58:58 +0700 Subject: [PATCH 02/10] Renamed example file. --- examples/{BASIC_v4/BASIC_v4.ino => BASIC/BASIC.ino} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{BASIC_v4/BASIC_v4.ino => BASIC/BASIC.ino} (100%) diff --git a/examples/BASIC_v4/BASIC_v4.ino b/examples/BASIC/BASIC.ino similarity index 100% rename from examples/BASIC_v4/BASIC_v4.ino rename to examples/BASIC/BASIC.ino From 236c5bab84cbf145e65aeec322682f58da86f81c Mon Sep 17 00:00:00 2001 From: Achim Date: Thu, 29 Feb 2024 18:15:22 +0700 Subject: [PATCH 03/10] Added offline mode after LED test. --- examples/ONE/ONE.ino | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/ONE/ONE.ino b/examples/ONE/ONE.ino index ead45dd2..84edd96c 100644 --- a/examples/ONE/ONE.ino +++ b/examples/ONE/ONE.ino @@ -1,4 +1,4 @@ - /* +/* This is the code for the AirGradient ONE open-source hardware indoor Air Quality Monitor with an ESP32-C3 Microcontroller. @@ -744,7 +744,7 @@ void setup() { agServer.begin(); /** Run LED test on start up */ - displayShowText("Press now for", "LED test", ""); + displayShowText("Press now for", "LED test &", "offline mode"); bool test = false; uint32_t stime = millis(); while (1) { @@ -760,9 +760,10 @@ void setup() { } if (test) { ledTest(); + } else { + connectToWifi(); } - /** WIFI connect */ - connectToWifi(); + /** * Send first data to ping server and get server configuration @@ -1168,12 +1169,12 @@ static void factoryConfigReset(void) { if (ms >= 2000) { // Show display message: For factory keep for x seconds // Count display. - displayShowText("For factory reset", "keep pressed", "for 8 sec"); + displayShowText("Factory reset", "keep pressed", "for 8 sec"); int count = 7; while (ag.button.getState() == ag.button.BUTTON_PRESSED) { delay(1000); - displayShowText("For factory reset", "keep pressed", + displayShowText("Factory reset", "keep pressed", "for " + String(count) + " sec"); count--; // ms = (uint32_t)(millis() - factoryBtnPressTime); From b4d6006678ac7cdd9f9a8ee4dc79596b71f06178 Mon Sep 17 00:00:00 2001 From: Achim Date: Thu, 29 Feb 2024 18:30:52 +0700 Subject: [PATCH 04/10] Changed PM polling frequency for Open Air to 2s --- examples/Open_Air/Open_Air.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Open_Air/Open_Air.ino b/examples/Open_Air/Open_Air.ino index e07b822e..38d98aab 100644 --- a/examples/Open_Air/Open_Air.ino +++ b/examples/Open_Air/Open_Air.ino @@ -98,7 +98,7 @@ enum { #define SENSOR_CO2_CALIB_COUNTDOWN_MAX 5 /** sec */ #define SENSOR_TVOC_UPDATE_INTERVAL 1000 /** ms */ #define SENSOR_CO2_UPDATE_INTERVAL 5000 /** ms */ -#define SENSOR_PM_UPDATE_INTERVAL 5000 /** ms */ +#define SENSOR_PM_UPDATE_INTERVAL 2000 /** ms */ #define SENSOR_TEMP_HUM_UPDATE_INTERVAL 2000 /** ms */ #define DISPLAY_DELAY_SHOW_CONTENT_MS 2000 /** ms */ #define WIFI_HOTSPOT_PASSWORD_DEFAULT \ From a59d5a1bb8510f85a306daf14a879489cc364ad9 Mon Sep 17 00:00:00 2001 From: AirGradient <68736665+airgradienthq@users.noreply.github.com> Date: Thu, 29 Feb 2024 20:05:16 +0700 Subject: [PATCH 05/10] Update check.yml Adjusted new name for example files --- .github/workflows/check.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 61e78f50..4b1c0290 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -5,8 +5,8 @@ jobs: fail-fast: false matrix: example: - - "BASIC_v4" - - "ONE_I-9PSL" + - "BASIC" + - "ONE" - "Open_Air" - "TestCO2" - "TestPM" From a867e9af38f88dd563fa0cb8efcd76c9f41114fc Mon Sep 17 00:00:00 2001 From: Phat Nguyen Date: Fri, 1 Mar 2024 19:51:58 +0700 Subject: [PATCH 06/10] revert SENSOR_TEMP_HUM_UPDATE_INTERVAL value --- examples/Open_Air/Open_Air.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Open_Air/Open_Air.ino b/examples/Open_Air/Open_Air.ino index 38d98aab..4d34abc4 100644 --- a/examples/Open_Air/Open_Air.ino +++ b/examples/Open_Air/Open_Air.ino @@ -99,7 +99,7 @@ enum { #define SENSOR_TVOC_UPDATE_INTERVAL 1000 /** ms */ #define SENSOR_CO2_UPDATE_INTERVAL 5000 /** ms */ #define SENSOR_PM_UPDATE_INTERVAL 2000 /** ms */ -#define SENSOR_TEMP_HUM_UPDATE_INTERVAL 2000 /** ms */ +#define SENSOR_TEMP_HUM_UPDATE_INTERVAL 5000 /** ms */ #define DISPLAY_DELAY_SHOW_CONTENT_MS 2000 /** ms */ #define WIFI_HOTSPOT_PASSWORD_DEFAULT \ "cleanair" /** default WiFi AP password \ From 4798e44cb7c532b38caa77c248cfe7904aa9287a Mon Sep 17 00:00:00 2001 From: Phat Nguyen Date: Fri, 1 Mar 2024 21:56:21 +0700 Subject: [PATCH 07/10] MDNS replace board with model --- examples/ONE/ONE.ino | 15 ++++++++++++--- examples/Open_Air/Open_Air.ino | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/examples/ONE/ONE.ino b/examples/ONE/ONE.ino index 84edd96c..d2f51f6d 100644 --- a/examples/ONE/ONE.ino +++ b/examples/ONE/ONE.ino @@ -710,8 +710,10 @@ bool hasSensorSGP = true; bool hasSensorSHT = true; int pmFailCount = 0; uint32_t factoryBtnPressTime = 0; +String mdnsModelName = ""; AgSchedule dispLedSchedule(DISP_UPDATE_INTERVAL, displayAndLedBarUpdate); -AgSchedule configSchedule(SERVER_CONFIG_UPDATE_INTERVAL, updateServerConfiguration); +AgSchedule configSchedule(SERVER_CONFIG_UPDATE_INTERVAL, + updateServerConfiguration); AgSchedule serverSchedule(SERVER_SYNC_INTERVAL, sendDataToServer); AgSchedule co2Schedule(SENSOR_CO2_UPDATE_INTERVAL, co2Update); AgSchedule pmsSchedule(SENSOR_PM_UPDATE_INTERVAL, pmUpdate); @@ -764,7 +766,6 @@ void setup() { connectToWifi(); } - /** * Send first data to ping server and get server configuration */ @@ -1069,7 +1070,10 @@ static void webServerInit(void) { webServer.on("/metrics", HTTP_GET, webServerMetricsGet); webServer.begin(); MDNS.addService("http", "tcp", 80); - MDNS.addServiceTxt("http", "_tcp", "board", ag.getBoardName()); + if (agServer.getModelName().isEmpty() != true) { + MDNS.addServiceTxt("http", "_tcp", "model", agServer.getModelName()); + mdnsModelName = agServer.getModelName(); + } MDNS.addServiceTxt("http", "_tcp", "serialno", getDevId()); MDNS.addServiceTxt("http", "_tcp", "fw_ver", ag.getVersion()); @@ -1777,6 +1781,11 @@ static void updateServerConfiguration(void) { Serial.println("Connect to new mqtt broker failed"); } } + + if (mdnsModelName != agServer.getModelName()) { + MDNS.addServiceTxt("http", "_tcp", "model", agServer.getModelName()); + mdnsModelName = agServer.getModelName(); + } } } diff --git a/examples/Open_Air/Open_Air.ino b/examples/Open_Air/Open_Air.ino index 4d34abc4..bbdf6558 100644 --- a/examples/Open_Air/Open_Air.ino +++ b/examples/Open_Air/Open_Air.ino @@ -726,7 +726,9 @@ bool hasSensorPMS1 = true; bool hasSensorPMS2 = true; bool hasSensorSGP = true; uint32_t factoryBtnPressTime = 0; -AgSchedule configSchedule(SERVER_CONFIG_UPDATE_INTERVAL, updateServerConfiguration); +String mdnsModelName = ""; +AgSchedule configSchedule(SERVER_CONFIG_UPDATE_INTERVAL, + updateServerConfiguration); AgSchedule serverSchedule(SERVER_SYNC_INTERVAL, sendDataToServer); AgSchedule co2Schedule(SENSOR_CO2_UPDATE_INTERVAL, co2Update); AgSchedule pmsSchedule(SENSOR_PM_UPDATE_INTERVAL, pmUpdate); @@ -1188,6 +1190,11 @@ static void updateServerConfiguration(void) { Serial.println("Connect to new mqtt broker failed"); } } + + if (mdnsModelName != agServer.getModelName()) { + MDNS.addServiceTxt("http", "_tcp", "model", agServer.getModelName()); + mdnsModelName = agServer.getModelName(); + } } } @@ -1330,7 +1337,10 @@ static void webServerInit(void) { webServer.on("/measures/current", HTTP_GET, webServerMeasureCurrentGet); webServer.begin(); MDNS.addService("http", "tcp", 80); - MDNS.addServiceTxt("http", "_tcp", "board", ag.getBoardName()); + if (mdnsModelName != agServer.getModelName()) { + MDNS.addServiceTxt("http", "_tcp", "model", agServer.getModelName()); + mdnsModelName = agServer.getModelName(); + } MDNS.addServiceTxt("http", "_tcp", "serialno", getDevId()); MDNS.addServiceTxt("http", "_tcp", "fw_ver", ag.getVersion()); From 1eb43f684bcdc0f02772debf05af1662e5b03245 Mon Sep 17 00:00:00 2001 From: Achim Date: Sat, 2 Mar 2024 13:41:08 +0700 Subject: [PATCH 08/10] Fix SHT read error. --- examples/ONE/ONE.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/ONE/ONE.ino b/examples/ONE/ONE.ino index d2f51f6d..dba7ed92 100644 --- a/examples/ONE/ONE.ino +++ b/examples/ONE/ONE.ino @@ -97,7 +97,7 @@ enum { #define SENSOR_CO2_CALIB_COUNTDOWN_MAX 5 /** sec */ #define SENSOR_TVOC_UPDATE_INTERVAL 1000 /** ms */ #define SENSOR_CO2_UPDATE_INTERVAL 5000 /** ms */ -#define SENSOR_PM_UPDATE_INTERVAL 5000 /** ms */ +#define SENSOR_PM_UPDATE_INTERVAL 2000 /** ms */ #define SENSOR_TEMP_HUM_UPDATE_INTERVAL 2000 /** ms */ #define DISPLAY_DELAY_SHOW_CONTENT_MS 2000 /** ms */ #define WIFI_HOTSPOT_PASSWORD_DEFAULT \ @@ -819,6 +819,7 @@ void loop() { } if (hasSensorSHT) { + delay(100); tempHumSchedule.run(); } @@ -2238,6 +2239,7 @@ static void sendDataToServer(void) { * @brief Update temperature and humidity value */ static void tempHumUpdate(void) { + Serial.println("Try SHT"); if (ag.sht.measure()) { temp = ag.sht.getTemperature(); From c1228bbd06f3bee3bb7a1f9c23c776ef0d072a7c Mon Sep 17 00:00:00 2001 From: Achim Date: Sat, 2 Mar 2024 14:05:00 +0700 Subject: [PATCH 09/10] Changed measurement and update intervalls --- examples/ONE/ONE.ino | 7 +++---- library.properties | 2 +- src/AirGradient.cpp | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/ONE/ONE.ino b/examples/ONE/ONE.ino index dba7ed92..35925378 100644 --- a/examples/ONE/ONE.ino +++ b/examples/ONE/ONE.ino @@ -90,13 +90,13 @@ enum { #define WIFI_CONNECT_RETRY_MS 10000 /** ms */ #define LED_BAR_COUNT_INIT_VALUE (-1) /** */ #define LED_BAR_ANIMATION_PERIOD 100 /** ms */ -#define DISP_UPDATE_INTERVAL 5000 /** ms */ -#define SERVER_CONFIG_UPDATE_INTERVAL 30000 /** ms */ +#define DISP_UPDATE_INTERVAL 2500 /** ms */ +#define SERVER_CONFIG_UPDATE_INTERVAL 15000 /** ms */ #define SERVER_SYNC_INTERVAL 60000 /** ms */ #define MQTT_SYNC_INTERVAL 60000 /** ms */ #define SENSOR_CO2_CALIB_COUNTDOWN_MAX 5 /** sec */ #define SENSOR_TVOC_UPDATE_INTERVAL 1000 /** ms */ -#define SENSOR_CO2_UPDATE_INTERVAL 5000 /** ms */ +#define SENSOR_CO2_UPDATE_INTERVAL 4000 /** ms */ #define SENSOR_PM_UPDATE_INTERVAL 2000 /** ms */ #define SENSOR_TEMP_HUM_UPDATE_INTERVAL 2000 /** ms */ #define DISPLAY_DELAY_SHOW_CONTENT_MS 2000 /** ms */ @@ -2239,7 +2239,6 @@ static void sendDataToServer(void) { * @brief Update temperature and humidity value */ static void tempHumUpdate(void) { - Serial.println("Try SHT"); if (ag.sht.measure()) { temp = ag.sht.getTemperature(); diff --git a/library.properties b/library.properties index 0c53a510..82ed8a0e 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=AirGradient Air Quality Sensor -version=3.0.5 +version=3.0.6 author=AirGradient maintainer=AirGradient sentence=ESP32-C3 / ESP8266 library for air quality monitor measuring PM, CO2, Temperature, TVOC and Humidity with OLED display. diff --git a/src/AirGradient.cpp b/src/AirGradient.cpp index cf5c43a2..0cff9802 100644 --- a/src/AirGradient.cpp +++ b/src/AirGradient.cpp @@ -1,6 +1,6 @@ #include "AirGradient.h" -#define AG_LIB_VER "3.0.5" +#define AG_LIB_VER "3.0.6" AirGradient::AirGradient(BoardType type) : pms5003(type), pms5003t_1(type), pms5003t_2(type), s8(type), sgp41(type), From d78205aa20caccfbbcd8f106f1364be4a3a7aa96 Mon Sep 17 00:00:00 2001 From: Achim Date: Sat, 2 Mar 2024 15:04:30 +0700 Subject: [PATCH 10/10] Changed measurement and update interval for Open Air. Added fw version to logs. --- examples/ONE/ONE.ino | 3 ++- examples/Open_Air/Open_Air.ino | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/ONE/ONE.ino b/examples/ONE/ONE.ino index 35925378..e3612608 100644 --- a/examples/ONE/ONE.ino +++ b/examples/ONE/ONE.ino @@ -736,7 +736,8 @@ void setup() { u8g2.begin(); /** Show boot display */ - displayShowText("One V9", "Lib Ver: " + ag.getVersion(), ""); + Serial.println("Firmware Version: "+ag.getVersion()); + displayShowText("One V9", "FW Ver: " + ag.getVersion(), ""); delay(DISPLAY_DELAY_SHOW_CONTENT_MS); /** Init sensor */ diff --git a/examples/Open_Air/Open_Air.ino b/examples/Open_Air/Open_Air.ino index bbdf6558..1ad7690f 100644 --- a/examples/Open_Air/Open_Air.ino +++ b/examples/Open_Air/Open_Air.ino @@ -77,7 +77,7 @@ enum { APP_SM_SERVER_LOST, /** Connected to WiFi network but the server cannot be reached through the internet, e.g. blocked by firewall */ - APP_SM_SENSOR_CONFIG_FAILED, /** Server is reachable but there is some + APP_SM_SENSOR_CONFIG_FAILED, /** Server is reachabFirmware nodele but there is some configuration issue to be fixed on the server side */ APP_SM_NORMAL, @@ -92,12 +92,12 @@ enum { #define LED_BAR_COUNT_INIT_VALUE (-1) /** */ #define LED_BAR_ANIMATION_PERIOD 100 /** ms */ #define DISP_UPDATE_INTERVAL 5000 /** ms */ -#define SERVER_CONFIG_UPDATE_INTERVAL 30000 /** ms */ +#define SERVER_CONFIG_UPDATE_INTERVAL 15000 /** ms */ #define SERVER_SYNC_INTERVAL 60000 /** ms */ #define MQTT_SYNC_INTERVAL 60000 /** ms */ #define SENSOR_CO2_CALIB_COUNTDOWN_MAX 5 /** sec */ #define SENSOR_TVOC_UPDATE_INTERVAL 1000 /** ms */ -#define SENSOR_CO2_UPDATE_INTERVAL 5000 /** ms */ +#define SENSOR_CO2_UPDATE_INTERVAL 4000 /** ms */ #define SENSOR_PM_UPDATE_INTERVAL 2000 /** ms */ #define SENSOR_TEMP_HUM_UPDATE_INTERVAL 5000 /** ms */ #define DISPLAY_DELAY_SHOW_CONTENT_MS 2000 /** ms */ @@ -906,6 +906,8 @@ void boardInit(void) { failedHandler("Init I2C failed"); } + Serial.println("Firmware Version: "+ag.getVersion()); + ag.watchdog.begin(); ag.button.begin(); ag.statusLed.begin(); @@ -953,7 +955,7 @@ void boardInit(void) { } } - Serial.printf("Firmware node: %s\r\n", getFwMode(fw_mode)); + Serial.printf("Firmware Mode: %s\r\n", getFwMode(fw_mode)); } void failedHandler(String msg) { @@ -1409,13 +1411,13 @@ static String getServerSyncData(bool localServer) { if ((fw_mode == FW_MODE_PPT) || (fw_mode == FW_MODE_PST)) { if (hasSensorSGP) { - if (tvocIndex > 0) { + if (tvocIndex >= 0) { root["tvoc_index"] = tvocIndex; } if (tvocRawIndex >= 0) { root["tvoc_raw"] = tvocRawIndex; } - if (noxIndex > 0) { + if (noxIndex >= 0) { root["nox_index"] = noxIndex; } }