Esp8266 nodemcu and apple homekit

Hi all,
I have esp8266 installed with homekit library

Everything works really well till modem restarts

As checked esp8266 reconnects wifi but homekit doesn’t restart and goes ‘no response’

I have to manually restart esp8266 to make it work everytime.

Is it possible to restart homekit when wifi disconnect and reconnect or simple restart esp8266 when wifi disconnect and reconnect?

Thanks

see 'No Response' after reboot/ssid_off WiFi router · Issue #139 · Mixiaoxiao/Arduino-HomeKit-ESP8266 · GitHub

Thanks i tried already reading it but in homekit library there is no code with mdns

In that article says removing stop mdns will solve issue but in my case there is not at all mdns code present.

How i can command to restart esp if wifi disconnect and reconnect

ESP.restart(); tells your ESP to reboot, it's a clean reboot (versus ESP.reset() is a hard reset but can leave some of the registers in the old state)

And how to trigger if wifi disconnect/reconnect?

something like this in the loop (probably) will check the status and attempt to reconnect every 20 seconds

wl_status_t checkWifi() {
  static unsigned long lastConnect=-20000ul; 

  // checking for WIFI connection
  if ((WiFi.status() != WL_CONNECTED) && (millis() – lastConnect >= 20000ul)) {
    Serial.println("Damned. Got disconnected. Reconnecting to WIFI network");
    WiFi.disconnect();
    WiFi.reconnect();
    lastConnect = millis();
  }
  return WiFi.status();
}


void loop() {
  checkWifi() ;
  // other stuff here
}
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.