Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By jenseisen
#20464 Ah! Thanks!
So I need to do some kind of watchdogging myself. I expected the mqtt-function itself keeps that going.

I am curious how other mqtt-clients handling this. Maybe I do some tests when I have time.
User avatar
By cal
#20476 Moin,

I wonder how that can work reliably using the arduino busy loop coding model.
From what I read:
The espduino is based on espressif sdk, too.
The sdk uses some cooperative task model and events where work is done on the next task when the current task ends.
If one task occupies the cpu for more than 10ms wifi may suffer.
Feeding the watchdog does keep the wdt reset away but that seems not to help wifi.
I read the espduino majn loop does some esp specific magic on each round of the loop.
So I would assume that a long running loop iteration may break that and even trigger a wdt reset.


Or is there some extra magic sauce in the espduino I don't know?

Cal
User avatar
By rmhome
#20576 I have something as simple as this which seem to work fine (I run mosquitto on an rPi2 which I occasionally reboot).

if (mqttCheck()) {
mqttClient.publish(mqttTopic + "/Status", "begin");
//mqttClient.subscribe("espin");
}

bool mqttCheck()
{
if (!mqttClient.connected())
return mqttClient.connect(ClientID);
else
return true;
}