Hi.
I'm writing some sketch to control my esp8266. I have a problem, I can't transfer the value of SSID and password of my router to the esp8266. I need to connect it to my router. Please advice, how to do this:
#include <SoftwareSerial.h>
#define router "<dlink>"
#define PASS "<12345678>"
int x=555;
SoftwareSerial MySerial(2,3);
void setup() {
Serial.begin(9600);
MySerial.begin(9600);
Serial.println("Starting to configure WiFi module");
SendData("AT+CWMODE=3\r\n");
delay(2000);
// SendData("AT+RST\r\n");
delay(3000);
SendData("AT+CWJAP=router,PASS\r\n");
}
void loop() // выполняется циклически
{
while (MySerial.available())
{
char c = MySerial.read();
Serial.write(c);
}
}
String SendData(String command)
{
String response ="";
MySerial.print(command);
while(MySerial.available())
{
char c = MySerial.read();
response+=c;
}
Serial.print(response);
return response;
}
Also I have tried like this:
#define router "dlink"
#define PASS "12345678"