Skip to content

Commit d030080

Browse files
authored
Merge pull request #7631 from Erriez/feature/documentation-wifi-multi
Add WiFi Multi to readme.rst
2 parents 85ba53a + 9c9e193 commit d030080

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

doc/esp8266wifi/readme.rst

+33
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,39 @@ The Client class creates `clients <https://en.wikipedia.org/wiki/Client_(computi
156156

157157
Check out the separate section with `list of functions <client-class.rst>`__
158158

159+
WiFi Multi
160+
~~~~~~~~~~
161+
162+
`ESP8266WiFiMulti.h` can be used to connect to a WiFi network with strongest WiFi signal (RSSI). This requires registering one or more access points with SSID and password. It automatically switches to another WiFi network when the WiFi connection is lost.
163+
164+
Example:
165+
166+
.. code:: cpp
167+
#include <ESP8266WiFiMulti.h>
168+
169+
ESP8266WiFiMulti wifiMulti;
170+
171+
// WiFi connect timeout per AP. Increase when connecting takes longer.
172+
const uint32_t connectTimeoutMs = 5000;
173+
174+
void setup()
175+
{
176+
// Set in station mode
177+
WiFi.mode(WIFI_STA);
178+
179+
// Register multi WiFi networks
180+
wifiMulti.addAP("ssid_from_AP_1", "your_password_for_AP_1");
181+
wifiMulti.addAP("ssid_from_AP_2", "your_password_for_AP_2");
182+
wifiMulti.addAP("ssid_from_AP_3", "your_password_for_AP_3");
183+
}
184+
185+
void loop()
186+
{
187+
// Maintain WiFi connection
188+
if (wifiMulti.run(connectTimeoutMs) == WL_CONNECTED) {
189+
...
190+
}
191+
}
159192
160193
BearSSL Client Secure and Server Secure
161194
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)