Arduino Uno + ESP-01 AT Command #1

arduino-uno-esp-01-at-comm

#include <SoftwareSerial.h>
SoftwareSerial esp8266(6,7); //Rx ==> Pin 6; TX ==> Pin7
#define speed8266 115200
void setup()
{
esp8266.begin (speed8266);
Serial.begin(speed8266);
Serial.println(“ESP8266 Setup test – use AT commands”);
}
void loop()
{
while(esp8266.available())
{
Serial.write(esp8266.read());
}
while(Serial.available())
{
esp8266.write(Serial.read());
}
}

arduino-uno-esp-01-at-command-test

+++++

// cr:http://www.instructables.com/id/Using-ESP-01-and-Arduino-UNO/
// cr:https://create.arduino.cc/projecthub/mjrobot/iot-made-easy-w-uno-esp-01-thingspeak-mit-app-inventor-da6a50
#include <SoftwareSerial.h>
SoftwareSerial esp8266(6,7); //Rx ==> Pin 6; TX ==> Pin7
#define speed8266 115200
#define TIMEOUT 5000 // mS
void setup()
{
esp8266.begin (speed8266);
Serial.begin(speed8266);
// send command connect wifi
SendCommand(“AT+RST”, “Ready”);
delay(5000);
SendCommand(“AT+CWMODE=1″,”OK”);

// sss=ssid ,ppp=password
SendCommand(“AT+CWJAP=\”sss\”,\”ppp\””, “OK”);
Serial.println(“ESP8266 Setup test – use AT commands”);
}
void loop()
{
while(esp8266.available())
{
Serial.write(esp8266.read());
}
while(Serial.available())
{
esp8266.write(Serial.read());
}
}
boolean SendCommand(String cmd, String ack){
esp8266.println(cmd); // Send “AT+” command to module
if (!echoFind(ack)) // timed out waiting for ack string
return true; // ack blank or ack found
}

boolean echoFind(String keyword){
byte current_char = 0;
byte keyword_length = keyword.length();
long deadline = millis() + TIMEOUT;
while(millis() < deadline){
if (esp8266.available()){
char ch = esp8266.read();
Serial.write(ch);
if (ch == keyword[current_char])
if (++current_char == keyword_length){
Serial.println();
return true;
}
}
}
return false; // Timed out
}

credit:https://create.arduino.cc/projecthub/mjrobot/iot-made-easy-w-uno-esp-01-thingspeak-mit-app-inventor-da6a50