12-28-2022, 10:37 PM
Hello, you have to replace the WiFi with WiFiMulti
For ESP8266 declare the following lines on the top of the code
#include <ESP8266WiFiMulti.h>
ESP8266WiFiMulti WiFiMulti;
For ESP32 add the lines:
#include <WiFiMulti.h>
WiFiMulti WiFiMulti;
then replace the connection function with this
You can see some examples on the WebSockets library
For ESP8266 declare the following lines on the top of the code
#include <ESP8266WiFiMulti.h>
ESP8266WiFiMulti WiFiMulti;
For ESP32 add the lines:
#include <WiFiMulti.h>
WiFiMulti WiFiMulti;
then replace the connection function with this
Code:
//===================================================== connectToWiFiNetwork
void connectToWiFiNetwork(){
WiFiMulti.addAP("SSID", "passpasspass");
while(WiFiMulti.run() != WL_CONNECTED) {
delay(100);
}
Serial.println("\nWiFi connected");
}
You can see some examples on the WebSockets library