-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
Good evening everyone,
I have several ESP32 (DOIT DEVKIT V1) boards on the home wifi, each with the purposes of monitoring a voltage and reporting that over time.
I use Arduino based on Mac with the most recent version of the ESP32 environment, loaded up using the 1.0.2 version of the ESP32 from Board manager. This issue has persisted over the last weveral versions of the Arduino IDE (1.8.8 - 1.8.9)
Over the last 6 months or so, I've been having issues with the mDNS falling offline after a variable length of time. All the while I've had several of the devices on the same WiFi network at the same time, with different 'host' names. Sometimes I can access the device through it's WebServer using the last known IP address, sometimes not.
When starting mDNS using the typical Arduino example method:
MDNS.begin("uniqueDeviceName");
it seems that after 'a while' on the wifi, the devices tend to fall offline from an mDNS and WebServer point of view.
I noticed from here:
https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/protocols/mdns.html
that there are many more setup options that are involved with setting up the mDNS service from the ESP-IDF process.
For the Arduino implementation, are these other settings automated? If so, do they all get a similar name, or are their names device specific?
(like these?)
mdns_service_instance_name_set(blahlblahblah); mdns_service_txt_set(blahlblahblah);
My question is this .. are there any of the 'other settings' aside from the
MDNS.begin(hostname);
Arduino method that, when setup automatically through the Arduino implementation, might clash with one another when more devices are on a WiFi network together?
Thanks in advance for the help.
My current workaround, just started today, which is showing some signs of success is to have the devices restart their WiFi connections as follows every 1 minute (update, shifted to every 5 minutes and still OK).
There must be a better way ??
if (timeNow >= timeToRefresh) {
WiFi.disconnect(true);
delay(3000);
WiFi.mode(WIFI_AP_STA);
WiFi.softAPConfig(softAPAddress, gateway, subnet);
WiFi.softAP(wifiNameString, softPASS);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
log_print(".");
}
if (!mdns_hostname_set(bonjourAddress)) { // check to see if the instance is alive
log_println("we're going to shut down the mdns instance");
// trying to shut down the mdns stuff 'properly' before starting it up again
mdns_service_remove("_http", "_tcp");
mdns_free();
} else {
log_println("no mdns instance to shut down");
}
// then initialize mDNS service using the ESP-IDF methods
esp_err_t err = mdns_init();
if (err) {
printf("MDNS Init failed: %d\n", err);
return false;
}
mdns_service_add(bonjourAddress, "_http", "_tcp", 80, NULL, 0);
}
UPDATE:
I've extended the refresh rate to once every 30 minutes and it seems to be working out OK .. next will be 60 minutes, I'll update as results unfold.