Search code examples
arduinoarduino-unoat-commandesp8266arduino-esp8266

Error on sending AT+CWJAP_DEF commands to ESP8266


I am trying to send AT commands to ESP8266 to get connected with internet with the Wifi.

When I am sending AT and AT+RST command on serial monitor then I am getting OK and ready response which seems perfect.

Then I am sending AT+CWLAP to get list of available wifi networks which is also executing correctly.

AT+CWLAP

+CWLAP:(3,"Moto",-42,"a4:70:d6:7a:fa:6c",1,25,0)
+CWLAP:(4,"PRANJAL",-95,"1c:a5:32:3d:f5:c4",1,-16,0)
+CWLAP:(2,"VIHAN",-94,"c8:3a:35:2f:1d:81",1,-21,0)
+CWLAP:(3,"Tenda",-93,"c8:3a:35:20:a9:b1",9,-4,0)

OK

Then I sent AT+CWMODE? which is also perfect.

AT+CWMODE?

+CWMODE:1

OK

Now I am trying to connect ESP8266 with above listed Wifi with this command, it is sending an ERROR on serial monitor.

AT+CWJAP_DEF="Moto","reset1234"

Error

⸮=IRe"Moto","reset1234"

ERROR

Can anyone suggest me what could be the reason of this issue ?

#include "SoftwareSerial.h"

SoftwareSerial esp8266(2, 3); // RX, TX

void setup()
{
  Serial.begin(9600); // serial port used for debugging
  esp8266.begin(9600);  // your ESP's baud rate might be different
}

void loop()
{
  if(esp8266.available())  // check if the ESP is sending a message
  {
    while(esp8266.available())
    {
      char c = esp8266.read();  // read the next character.

      Serial.write(c);  // writes data to the serial monitor
    }
  }

  if(Serial.available())
  {
    delay(10);  // wait to let all the input command in the serial buffer

    // read the input command in a string
    String cmd = "";
    while(Serial.available())
    {
      cmd += (char)Serial.read();
    }
    // send to the esp8266
    esp8266.println(cmd); 
  }
}

enter image description here


Solution

  • Alright! I just tried to connect with different wifi and it got connected with it. It was some kinda issue with mobile hotspot.