I am using a slightly modified version of this sketch:
https://github.com/Theb-1/ESP8266-wifi-light-dimmer
It works well but the MQTT part does not have a reconnect function. Consequently, I added a simple reconnect loop with a timer:
if (!mqttClient.connected() && currentMillis - previousMillis >= recoonectinterval) {
setupMQTTClient();
previousMillis = currentMillis;
}
This works somewhat, meaning approximately every second time the it reconnects successfully and the rest result in a wdt reset. It seems to hang in this part:
connectResult = mqttClient.connect("ESP" + ESP.getChipId(), mqtt_user, mqtt_password);
Do any of you have any solution to this? I tried adding yield () both before and after the "connectResult" but without luck.
Thank you!