diff --git a/tools/esp8266/README.md b/tools/esp8266/README.md index cdb120cd5..18086d4fb 100644 --- a/tools/esp8266/README.md +++ b/tools/esp8266/README.md @@ -54,7 +54,11 @@ For now the following inverters should work out of the box: ## USED LIBRARIES -- `Time` -- `RF24` -- `PubSubClient` +- `ESP8266WiFi` 1.0 +- `DNSServer` 1.1.0 +- `Ticker` 1.0 +- `ESP8266HTTPUpdateServer` 1.0 +- `Time` 1.6.1 +- `RF24` 1.4.2 +- `PubSubClient` 2.8 diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index 06d2f33b0..51aa2ff16 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -14,6 +14,7 @@ app::app() : Main() { mSerialTicker = 0xffff; mSerialInterval = 0; mMqttActive = false; + mMqttNewDataAvail = false; mTicker = 0; mRxTicker = 0; @@ -181,7 +182,7 @@ void app::loop(void) { mMqtt.loop(); if(checkTicker(&mTicker, 1000)) { - if(mMqttActive) { + if(mMqttNewDataAvail) { if(++mMqttTicker >= mMqttInterval) { mMqttTicker = 0; mMqtt.isConnected(true); @@ -190,17 +191,17 @@ void app::loop(void) { Inverter<> *iv = mSys->getInverterByPos(id); if(NULL != iv) { for(uint8_t i = 0; i < iv->listLen; i++) { - if(0.0f != iv->getValue(i)) { - snprintf(topic, 30, "%s/ch%d/%s", iv->name, iv->assign[i].ch, fields[iv->assign[i].fieldId]); - snprintf(val, 10, "%.3f", iv->getValue(i)); - mMqtt.sendMsg(topic, val); - yield(); - } + snprintf(topic, 30, "%s/ch%d/%s", iv->name, iv->assign[i].ch, fields[iv->assign[i].fieldId]); + snprintf(val, 10, "%.3f", iv->getValue(i)); + mMqtt.sendMsg(topic, val); + yield(); + } } } snprintf(val, 10, "%d", ESP.getFreeHeap()); mMqtt.sendMsg("free_heap", val); + mMqttNewDataAvail = false; } } @@ -342,6 +343,7 @@ void app::processPayload(bool retransmit) { iv->addValue(i, payload); } iv->doCalculations(); + mMqttNewDataAvail = true; } } } diff --git a/tools/esp8266/app.h b/tools/esp8266/app.h index 23734965c..9fb6c0e8b 100644 --- a/tools/esp8266/app.h +++ b/tools/esp8266/app.h @@ -102,6 +102,7 @@ class app : public Main { bool mMqttActive; uint16_t mSerialTicker; uint16_t mSerialInterval; + bool mMqttNewDataAvail; }; #endif /*__APP_H__*/