(ESP32) trigger something if the connexion to thingerIO is lost

Hi guys,

Basically i’m controlling a relay thanks to ThingerIO and an ESP32 and i want to make sure that if the connexion to ThingerIO and/or to Internet is lost the relay will eventually turn off (if it was on).
The thread bellow:

already discuss that topic but, correct me if i’m wrong, the solutions mentioned, are based on the fact that the ESP32’s wifi is connected to the AP… This is “unsafe” in my point of view because you can have a valid wifi connection to an AP that lost the Internet.

What would be the best approach to tackle that in your opinion?
I have red plenty of generic topics about that presenting different solutions (ping a website every x minutes / call a DNS server to have an address resolved …)
… but i’m wondering if there is not a solution “thingerIO centered” like an error raised if the ESP32<–>ThingerIO communication is broken for a certain time.

Thank you !

Here is the code i use for now


#include <ThingerESP32.h>
#include “arduino_secrets.h”


void setup() {
// open serial for debugging
pinMode(26 , OUTPUT);
thing.add_wifi(SSID, SSID_PASSWORD);

thing[“GPIO2”] << [](pson& in){
in = !(bool) digitalRead(26);
digitalWrite(26, in ? LOW : HIGH);

void loop() {


I would use this —> CODING GUIDE - Thinger.io Documentation

Any state different from THINGER_AUTHENTICATED may trigger the ‘no connection routine’

Hope this helps.