Display more teleinfo information

This commit is contained in:
Mathieu Maret 2022-09-24 22:43:15 +02:00
parent 7cac6f89f1
commit 0847e89960
5 changed files with 22 additions and 12 deletions

View File

@ -6,16 +6,16 @@
int TeleinfoSetup(); int TeleinfoSetup();
int TeleinfoProcess(std::vector<struct mqttInfo> &batchInfo); int TeleinfoProcess(std::vector<struct mqttInfo> &batchInfo);
int TeleinfoProcess(float &iinst, float &papp, float &base); int TeleinfoProcess(float &iinst, float &papp, float &base);
int TeleinfoProcess(float &iinst, float &papp, float &base,
std::vector<struct mqttInfo> &batchInfo);
#else #else
int TeleinfoSetup() { int TeleinfoSetup() {
SKETCH_DEBUG_PRINTLN("Teleinfo is disabled at build time"); SKETCH_DEBUG_PRINTLN("Teleinfo is disabled at build time");
return -1; return -1;
}; };
inline int TeleinfoProcess(std::vector<struct mqttInfo> &){ int TeleinfoProcess(float &, float &, float &,
std::vector<struct mqttInfo> &){
return 0; return 0;
}; }
int TeleinfoProcess(float &, float &, float &){
return 0;
};
#endif #endif

View File

@ -42,7 +42,8 @@ int TeleinfoProcess(std::vector<struct mqttInfo> &batchInfo)
return 0; return 0;
} }
int TeleinfoProcess(float &iinst, float &papp, float &base ) int TeleinfoProcess(float &iinst, float &papp, float &base,
std::vector<struct mqttInfo> &batchInfo)
{ {
int c; int c;
@ -55,12 +56,15 @@ int TeleinfoProcess(float &iinst, float &papp, float &base )
while (me) { while (me) {
if (strcmp(me->name, "IINST") == 0) { if (strcmp(me->name, "IINST") == 0) {
iinst = atof(me->value); iinst = atof(me->value);
batchInfo.push_back({iinst, TELEINFO_IINST_FEED_FORMAT, 0, 0});
} }
if (strcmp(me->name, "PAPP") == 0) { if (strcmp(me->name, "PAPP") == 0) {
papp = atof(me->value); papp = atof(me->value);
batchInfo.push_back({papp, TELEINFO_PAPP_FEED_FORMAT, 0, 0});
} }
if (strcmp(me->name, "BASE") == 0) { if (strcmp(me->name, "BASE") == 0) {
base = atof(me->value); base = atof(me->value);
batchInfo.push_back({base, TELEINFO_BASE_FEED_FORMAT, 0, 0});
} }
me = me->next; me = me->next;
} }

View File

@ -45,6 +45,9 @@ void WebHandleRoot() {
#endif #endif
#ifdef CONFIG_ENABLE_DRY_SENSOR #ifdef CONFIG_ENABLE_DRY_SENSOR
"Dryness " + String((dryness * 100) / 1024) + "%<br/>" "Dryness " + String((dryness * 100) / 1024) + "%<br/>"
#endif
#ifdef CONFIG_ENABLE_TELEINFO
"<h6>Power Consumption</h6> Base " + String(teleBase, 2) +"Kwh<br/> AC Power " + telePapp +"VA<br/> Instant Current" + teleIinst +"A<br/>"
#endif #endif
"</fieldset>" + gpioControlHTML + gpioObserved + pwmControlHTML + "<fieldset>" "</fieldset>" + gpioControlHTML + gpioObserved + pwmControlHTML + "<fieldset>"
"<legend>Settings</legend>" "<legend>Settings</legend>"
@ -119,8 +122,8 @@ void WebHandleSetup() {
"<div><label for=\"ip\">Ip :</label><br/><input type=\"text\" name=\"ip\" value=\"" + (conf.ip == 0 ? WiFi.localIP().toString() : IPAddress(conf.ip).toString()) + "\" /> </div>" "<div><label for=\"ip\">Ip :</label><br/><input type=\"text\" name=\"ip\" value=\"" + (conf.ip == 0 ? WiFi.localIP().toString() : IPAddress(conf.ip).toString()) + "\" /> </div>"
"<div><label for=\"gw\">Gateway :</label><br/><input type=\"text\" name=\"gw\" value=\"" + (conf.gw == 0 ? WiFi.gatewayIP().toString() : IPAddress(conf.gw).toString()) + "\" /> </div>" "<div><label for=\"gw\">Gateway :</label><br/><input type=\"text\" name=\"gw\" value=\"" + (conf.gw == 0 ? WiFi.gatewayIP().toString() : IPAddress(conf.gw).toString()) + "\" /> </div>"
"<div><label for=\"mask\">Netmask :</label><br/><input type=\"text\" name=\"mask\" value=\"" + (conf.mask == 0 ? WiFi.subnetMask().toString() : IPAddress(conf.mask).toString()) + "\" /> </div>" "<div><label for=\"mask\">Netmask :</label><br/><input type=\"text\" name=\"mask\" value=\"" + (conf.mask == 0 ? WiFi.subnetMask().toString() : IPAddress(conf.mask).toString()) + "\" /> </div>"
"<div><label for=\"mask\">DNS :</label><br/><input type=\"text\" name=\"dns\" value=\"" + (conf.dns == 0 ? WiFi.dnsIP().toString() : IPAddress(conf.dns).toString()) + "\" /> </div>" "<div><label for=\"mask\">DNS :</label><br/><input type=\"text\" name=\"dns\" value=\"" + (conf.dns == 0 ? (WiFi.dnsIP().isSet() ? WiFi.dnsIP().toString():"") : IPAddress(conf.dns).toString()) + "\" /> </div>"
"<div><label for=\"mask\">DNS2 :</label><br/><input type=\"text\" name=\"dns2\" value=\"" + (conf.dns2 == 0 ? WiFi.dnsIP(1).toString() : IPAddress(conf.dns2).toString()) + "\" /> </div>" "<div><label for=\"mask\">DNS2 :</label><br/><input type=\"text\" name=\"dns2\" value=\"" + (conf.dns2 == 0 ? (WiFi.dnsIP(1).isSet() ? WiFi.dnsIP(1).toString():"") : IPAddress(conf.dns2).toString()) + "\" /> </div>"
"</fieldset>" "</fieldset>"
"<fieldset>" "<fieldset>"
"<legend>MQTT:</legend>" "<legend>MQTT:</legend>"

View File

@ -66,6 +66,7 @@ double temp, pressure;
float dhtTemp, dhtHumidity; float dhtTemp, dhtHumidity;
float bme680T, bme680P, bme680H, bme680G, bme680A; float bme680T, bme680P, bme680H, bme680G, bme680A;
float bme680BSECT, bme680BSECP, bme680BSECH, bme680BSECIaq, bme680BSECIaqAcc; float bme680BSECT, bme680BSECP, bme680BSECH, bme680BSECIaq, bme680BSECIaqAcc;
float teleIinst, telePapp, teleBase;
int dryness; int dryness;
uint8_t mode; uint8_t mode;
int reconfig = 0; int reconfig = 0;
@ -363,7 +364,9 @@ void loop() {
batchInfo.push_back({bme680BSECIaq, BME680_IAQ_FEED_FORMAT, 0, 0}); batchInfo.push_back({bme680BSECIaq, BME680_IAQ_FEED_FORMAT, 0, 0});
batchInfo.push_back({bme680BSECIaqAcc, BME680_IAQ_ACC_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) if (mode == BOOTMODE_NORMAL)
MqttBatchPublish(batchInfo, conf.mqttUser, conf.host); MqttBatchPublish(batchInfo, conf.mqttUser, conf.host);
nbCycle = 0; nbCycle = 0;

View File

@ -44,7 +44,7 @@
// Long press on this button will put device in setup mode at runtime // Long press on this button will put device in setup mode at runtime
#define CONFIG_SETUP_BUTTON 0 #define CONFIG_SETUP_BUTTON 0
// Teleinfo https://github.com/hallard/LibTeleinfo/ // Teleinfo https://github.com/hallard/LibTeleinfo/
#define CONFIG_ENABLE_TELEINFO #define CONFIG_ENABLE_TELEINFO
/* DEFAULT VALUE ALSO DEFINED IN CONFIG.H */ /* DEFAULT VALUE ALSO DEFINED IN CONFIG.H */
@ -52,10 +52,10 @@
#define CONFIG_SETUP_GPIO 14 //D5 #define CONFIG_SETUP_GPIO 14 //D5
// Time to sleep between 2 webserver request (increase it reduce battery usage but increase latency) // 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 // 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 // Name of the SSID when in AP mode for configuration
#define CONFIG_SSID_NAME "ESPConfiguratorBureau" #define CONFIG_SSID_NAME "ESPConfiguratorBureau"