Chat freely about anything...

User avatar
By Ariyani Dwi R
#50495 Hello.
I want to send ultrasonic sensor's data to my website by using esp8266 01 module. but that module can't connect to wifi. i don't know why. but i think there is something wrong with the code.
Anybody can help me please? :(
Here the function is
boolean connectWiFi(){
//set ESP8266 mode with AT commands
Serial.println("AT+CWMODE=1");
ser.println("AT+CWMODE=1");
delay(2000);

//build connection command
String cmd="AT+CWJAP=\"";
cmd+=SSID;
cmd+="\",\"";
cmd+=PASS;
cmd+="\"";

//connect to WiFi network
Serial.println(cmd);
ser.println(cmd);
delay(5000);

//if connected return true, else false
if(ser.find("OK")){
Serial.println("Success");

return true;
}else{
Serial.println("Failed");

return false;
}
}

When i open the serial monitor, it's always "Failed" appeared.