You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tried to upload data to a MQTT broker (local network; IObroker) but failed to update a value which was writeable in a first try. When using a different MQTT client (Windows based standalone program), I was able to change this value without issue. I also could see my ESP8266 client connecting to the brokar and - according to the feedback in the arduino program - update/broadcast the vaalue on the broker, which was/is false.
I monitored the logfile on the MQTT server side and always found the following log details whenever my ESP client tried to connect and change a value:
Solution and possible explanation:
To me it looks like the Adafruit library tries to keep the connection and stores some values in memory to achive this. However, my ESP8266 calls the function ESP.deepSleep() after submitting a value, is reset and then starts from scratch - and something happens here which I can't explain. Maybe the server also tries to keep the connection which is breaking up in an undesired way when the client goes into deep sleep mode.
The solution however is simple: Add mqtt.disconnect(); before calling deep sleep to close the connection in the correct way, which will not only result in the error in the log going away but also the value finally be published on the MQTT server
mqtt.disconnect();
ESP.deepSleep(120 * 1000000); // deep sleep for 120 secs
Maybe this problem and the solution could be added to the documentation as I am sure that a lot of people use MQTT on an ESP8266 to send data points to a server while keeping the ESP in deep sleep to conserver energy (and run them on battery).
The text was updated successfully, but these errors were encountered:
Issue:
Tried to upload data to a MQTT broker (local network; IObroker) but failed to update a value which was writeable in a first try. When using a different MQTT client (Windows based standalone program), I was able to change this value without issue. I also could see my ESP8266 client connecting to the brokar and - according to the feedback in the arduino program - update/broadcast the vaalue on the broker, which was/is false.
I monitored the logfile on the MQTT server side and always found the following log details whenever my ESP client tried to connect and change a value:
Solution and possible explanation:
To me it looks like the Adafruit library tries to keep the connection and stores some values in memory to achive this. However, my ESP8266 calls the function ESP.deepSleep() after submitting a value, is reset and then starts from scratch - and something happens here which I can't explain. Maybe the server also tries to keep the connection which is breaking up in an undesired way when the client goes into deep sleep mode.
The solution however is simple: Add mqtt.disconnect(); before calling deep sleep to close the connection in the correct way, which will not only result in the error in the log going away but also the value finally be published on the MQTT server
Maybe this problem and the solution could be added to the documentation as I am sure that a lot of people use MQTT on an ESP8266 to send data points to a server while keeping the ESP in deep sleep to conserver energy (and run them on battery).
The text was updated successfully, but these errors were encountered: