From 0847e899607855531d357de8443fd065837ea6a6 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Sat, 24 Sep 2022 22:43:15 +0200 Subject: [PATCH] Display more teleinfo information --- WifiControlSensor/Teleinfo.h | 10 +++++----- WifiControlSensor/Teleinfo.ino | 6 +++++- WifiControlSensor/WebServer.ino | 7 +++++-- WifiControlSensor/WifiControlSensor.ino | 5 ++++- WifiControlSensor/config_device.h | 6 +++--- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/WifiControlSensor/Teleinfo.h b/WifiControlSensor/Teleinfo.h index 23183c3..ce4aa7e 100644 --- a/WifiControlSensor/Teleinfo.h +++ b/WifiControlSensor/Teleinfo.h @@ -6,16 +6,16 @@ int TeleinfoSetup(); int TeleinfoProcess(std::vector &batchInfo); int TeleinfoProcess(float &iinst, float &papp, float &base); +int TeleinfoProcess(float &iinst, float &papp, float &base, + std::vector &batchInfo); #else int TeleinfoSetup() { SKETCH_DEBUG_PRINTLN("Teleinfo is disabled at build time"); return -1; }; -inline int TeleinfoProcess(std::vector &){ +int TeleinfoProcess(float &, float &, float &, + std::vector &){ return 0; -}; -int TeleinfoProcess(float &, float &, float &){ - return 0; -}; +} #endif diff --git a/WifiControlSensor/Teleinfo.ino b/WifiControlSensor/Teleinfo.ino index ce0439a..6566cb4 100644 --- a/WifiControlSensor/Teleinfo.ino +++ b/WifiControlSensor/Teleinfo.ino @@ -42,7 +42,8 @@ int TeleinfoProcess(std::vector &batchInfo) return 0; } -int TeleinfoProcess(float &iinst, float &papp, float &base ) +int TeleinfoProcess(float &iinst, float &papp, float &base, + std::vector &batchInfo) { int c; @@ -55,12 +56,15 @@ int TeleinfoProcess(float &iinst, float &papp, float &base ) while (me) { if (strcmp(me->name, "IINST") == 0) { iinst = atof(me->value); + batchInfo.push_back({iinst, TELEINFO_IINST_FEED_FORMAT, 0, 0}); } if (strcmp(me->name, "PAPP") == 0) { papp = atof(me->value); + batchInfo.push_back({papp, TELEINFO_PAPP_FEED_FORMAT, 0, 0}); } if (strcmp(me->name, "BASE") == 0) { base = atof(me->value); + batchInfo.push_back({base, TELEINFO_BASE_FEED_FORMAT, 0, 0}); } me = me->next; } diff --git a/WifiControlSensor/WebServer.ino b/WifiControlSensor/WebServer.ino index d18dc93..5fac7f2 100644 --- a/WifiControlSensor/WebServer.ino +++ b/WifiControlSensor/WebServer.ino @@ -45,6 +45,9 @@ void WebHandleRoot() { #endif #ifdef CONFIG_ENABLE_DRY_SENSOR "Dryness " + String((dryness * 100) / 1024) + "%
" +#endif +#ifdef CONFIG_ENABLE_TELEINFO + "
Power Consumption
Base " + String(teleBase, 2) +"Kwh
AC Power " + telePapp +"VA
Instant Current" + teleIinst +"A
" #endif "" + gpioControlHTML + gpioObserved + pwmControlHTML + "
" "Settings" @@ -119,8 +122,8 @@ void WebHandleSetup() { "

" "

" "

" - "

" - "

" + "

" + "

" "
" "
" "MQTT:" diff --git a/WifiControlSensor/WifiControlSensor.ino b/WifiControlSensor/WifiControlSensor.ino index 4239db2..794ce62 100644 --- a/WifiControlSensor/WifiControlSensor.ino +++ b/WifiControlSensor/WifiControlSensor.ino @@ -66,6 +66,7 @@ double temp, pressure; float dhtTemp, dhtHumidity; float bme680T, bme680P, bme680H, bme680G, bme680A; float bme680BSECT, bme680BSECP, bme680BSECH, bme680BSECIaq, bme680BSECIaqAcc; +float teleIinst, telePapp, teleBase; int dryness; uint8_t mode; int reconfig = 0; @@ -363,7 +364,9 @@ void loop() { batchInfo.push_back({bme680BSECIaq, BME680_IAQ_FEED_FORMAT, 0, 0}); batchInfo.push_back({bme680BSECIaqAcc, BME680_IAQ_ACC_FEED_FORMAT, 0, 0}); } - TeleinfoProcess(batchInfo); + + TeleinfoProcess(teleIinst, telePapp, teleBase, batchInfo); + if (mode == BOOTMODE_NORMAL) MqttBatchPublish(batchInfo, conf.mqttUser, conf.host); nbCycle = 0; diff --git a/WifiControlSensor/config_device.h b/WifiControlSensor/config_device.h index 8f5280d..3156a5b 100644 --- a/WifiControlSensor/config_device.h +++ b/WifiControlSensor/config_device.h @@ -44,7 +44,7 @@ // Long press on this button will put device in setup mode at runtime #define CONFIG_SETUP_BUTTON 0 -// Teleinfo https://github.com/hallard/LibTeleinfo/ +// Teleinfo https://github.com/hallard/LibTeleinfo/ #define CONFIG_ENABLE_TELEINFO /* DEFAULT VALUE ALSO DEFINED IN CONFIG.H */ @@ -52,10 +52,10 @@ #define CONFIG_SETUP_GPIO 14 //D5 // Time to sleep between 2 webserver request (increase it reduce battery usage but increase latency) -//#define CONFIG_WEB_DELAY_MS 100 +#define CONFIG_WEB_DELAY_MS 800 // Get sensors value every X ms -#define CONFIG_SAMPLING_PERIOD_MS 3000 +#define CONFIG_SAMPLING_PERIOD_MS 30000 // Name of the SSID when in AP mode for configuration #define CONFIG_SSID_NAME "ESPConfiguratorBureau"