I have a few boards used as data collectors, which are based on the ESP07S modules.
The sketch code is pretty standard with the usual WiFi connect code.
Now I have discovered that the devices seem not to connect to the strongest WiFi available and I wonder if there is a way to make them do that?
The data collected are sent by MQTT to a broker for handling and I have added an item for the WiFi strength so I can check it and it turns out that sometimes the device switches to an access point at a longer distance and hence a weaker signal. I have graphed the varying signal level from the database where it winds up and here is how it looks like for the last 10 days:
When I installed the system the WiFi stayed around -70 to -77 dBm or so for a while and operation was stable, but recently I have had several reboots (probably triggered by low WiFi signal) and then I discovered the low signal level...
The data collector is located outside my house and is about 15 m from it and it is supposed to use the closest access point located in the room inside of the closest part of the house. But it seems to connect to the AP at the far end of the house some 15 m farther away and thus getting a signal strength that is almost as low as -90 dBm
Both AP:s use the same SSID so it is not possible to change the connection by SSID value.
Is there a way to code the ESP07S such that it will scan the available AP:s using the same SSID and select the strongest one to connect to?
This is the current connect code used:
WiFi.mode(WIFI_STA);
WiFi.setPhyMode(WIFI_PHY_MODE_11G);
WiFi.hostname(MyHostname);
WiFi.begin(MySSID, MyPasswd);
The setPhyMode call was added in order to stabilize the connection in the presence of a more advanced WiFi router with automatic 2.4/5 Gb switching...