I want to setup a Wifi connection with a NodeMCU to control WS2812 LEDs but the program does not connect to my Wifi - the code compiles fine with no errors.
Thank for the answers. Yes, I'm getting the dots and afterwards a "WiFi failed." The SSID and and the passwort are correct and I specifically set the network tpo 2.4 GHz only.
I added the line ahsrabrifat suggested but still end up with "WiFi failed."
I was waiting for someone else with more programming skills to join in...
We don't have your entire sketch, just the snippet of post #1, so it's not clear for me if the error comes from another line in your code or from a function inside one of the libraries. But the compiler rages against a conversion between a constant pointer and a pointer. So my next step would be to change
const char* ssid = "Guest"; // Change this
const char* password = "xxxxxx"; // And this
to
char* ssid = "Guest"; // Change this
char* password = "xxxxxx"; // And this
Nevertheless, I first did a reset for the controller and played around with the code that was not working:
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.disconnect(); // Disconnect from any previous connection
delay(100); // Small delay to settle
Serial.println("Scanning for networks...");
int numberOfNetworks = WiFi.scanNetworks();
if (numberOfNetworks == 0) {
Serial.println("No networks found.");
} else {
Serial.println();
Serial.print(numberOfNetworks);
Serial.println(" network(s) found:");
Serial.println("-----------------------");
for (int i = 0; i < numberOfNetworks; ++i) {
Serial.print("Network name: ");
Serial.println(WiFi.SSID(i));
Serial.print("Signal strength (RSSI): ");
Serial.println(WiFi.RSSI(i));
Serial.println("-----------------------");
}
}
}
void loop() {}
The issue was the
delay(100); // Small delay to settle
After I set it to
delay(2000);
I got first the response
WL_DISCONNECTED = 7
and afterwards
WL_CONNECTED = 1
With regards to the the problem in the first posting I figured there is a part in the code that passes the ssid and passwort, took that out and the Wifi connects fine.