1

Firmware version

AT+GMR

AT version:0.21.0.0
SDK version:0.9.5

OK

Connection

ESP8266(ESP-01) <> Arduino Uno  
GND  <> GND  
3V3 <> 3.3V  
EN(CH_PD) <> 3.3V  
TX  <> D2  
RX <>  D3  

ps) I know I must not connect RX directly to Arduino's D3.
When I level down ESP8266's RX 5V to 3.3V, ESP8266 didn't work.
But when directly, It works well.
I supply power to Arduino Uno and ESP8266 by usb from PC.

Arduino Code

    #include <SoftwareSerial.h>
    #include <ESP8266.h>        //다운 후 libraries폴더에 저장한 라이브러리

    SoftwareSerial esp8266Serial = SoftwareSerial(2, 3); 
    ESP8266 wifi = ESP8266(esp8266Serial);

    #define SSID "MYSSID"
    #define PWD "MYPWD"

    void setup() {
      Serial.begin(9600);
      esp8266Serial.begin(9600);  // ESP8266

      wifi.begin();
      wifi.setTimeout(1000);

      // test
      Serial.print("test: ");
      Serial.println(getStatus(wifi.test()));

      // restart
      Serial.print("restart: ");
      Serial.println(getStatus(wifi.restart()));
      Serial.print("quitAP: ");
      Serial.println(getStatus(wifi.quitAP()));

      // joinAP
      Serial.print("joinAP: ");
      Serial.println(getStatus(wifi.joinAP(SSID, PWD)));

      // getAP
      Serial.print("getAP: ");
      Serial.println(getStatus(wifi.getAP(SSID)));

      // getIP
      Serial.print("getIP: ");
      IPAddress ip;
      Serial.println(getStatus(wifi.getIP(ESP8266_WIFI_STATION, ip)));
      Serial.print("IP: ");
      Serial.println(ip);

      // connect with webserver 

      Serial.print("connect: ");
      Serial.println(getStatus(wifi.connect(ESP8266_PROTOCOL_TCP, IPAddress(192, 168, 0, 52), 3000)));
      getConnectionStatue(wifi);

      // send to webserver
      Serial.print("send: ");

      Serial.println(getStatus(wifi.send("GET /?id=arduino HTTP/1.0\r\nHost: http://192.168.0.52:3000\r\n\r\n")));
    }

    void loop()
    {
      // read data
      unsigned int id;
      int length;
      int totalRead;
      char buffer[11] = {};
      if ((length = wifi.available()) > 0) {
        id = wifi.getId();
        totalRead = wifi.read(buffer, 1000);
        if (length > 0) {
          Serial.println((char*)buffer);
        }
      }
    }

    void getConnectionStatue(ESP8266 wifi) {
      // getConnectionStatus
      ESP8266ConnectionStatus connectionStatus;
      ESP8266Connection connections[5];
      unsigned int connectionCount;
      Serial.print("getConnectionStatus: ");
      Serial.print(getStatus(wifi.getConnectionStatus(connectionStatus,                                         connections, connectionCount)));
      Serial.print(" : ");
      Serial.println(connectionCount);
      for (int i = 0; i < connectionCount; i++) {
        Serial.print(" - Connection: ");
        Serial.print(connections[i].id);
        Serial.print(" - ");
        Serial.print(getProtocol(connections[i].protocol));
        Serial.print(" - ");
        Serial.print(connections[i].ip);
        Serial.print(":");
        Serial.print(connections[i].port);
        Serial.print(" - ");
        Serial.println(getRole(connections[i].role));
      }
    }

    String getStatus(bool status)
    {
      if (status)
        return "OK";

      return "KO";
    }

    String getStatus(ESP8266CommandStatus status)
    {
      switch (status) {
        case ESP8266_COMMAND_INVALID:
          return "INVALID";
          break;

        case ESP8266_COMMAND_TIMEOUT:
          return "TIMEOUT";
          break;

        case ESP8266_COMMAND_OK:
          return "OK";
          break;

        case ESP8266_COMMAND_NO_CHANGE:
          return "NO CHANGE";
          break;

        case ESP8266_COMMAND_ERROR:
          return "ERROR";
          break;

        case ESP8266_COMMAND_NO_LINK:
          return "NO LINK";
          break;

        case ESP8266_COMMAND_TOO_LONG:
          return "TOO LONG";
          break;

        case ESP8266_COMMAND_FAIL:
          return "FAIL";
          break;

        default:
          return "UNKNOWN COMMAND STATUS";
          break;
      }
    }

    String getRole(ESP8266Role role)
    {
      switch (role) {
        case ESP8266_ROLE_CLIENT:
          return "CLIENT";
          break;

        case ESP8266_ROLE_SERVER:
          return "SERVER";
          break;

        default:
          return "UNKNOWN ROLE";
          break;
      }
    }

    String getProtocol(ESP8266Protocol protocol)
    {
      switch (protocol) {
        case ESP8266_PROTOCOL_TCP:
          return "TCP";
          break;

        case ESP8266_PROTOCOL_UDP:
          return "UDP";
          break;

        default:
          return "UNKNOWN PROTOCOL";
          break;
      }
    }

Response

    test: OK
    restart: OK
    quitAP: OK
    joinAP: TIMEOUT
    getAP: OK
    getIP: OK
    IP: 192.168.0.55
    connect: OK
    getConnectionStatus: OK : 1
     - Connection: 0 - TCP - 192.168.0.52:3000 - CLIENT
    send: OK

There is no response
On server, the request ESP8266 sent didn't come.
I have no Idea...........

Addition

I send AT commands directly to ESP8266 by Arduino IDE

connection

ESP8266(ESP-01) <> Arduino Uno  
GND  <> GND  
3V3 <> 3.3V  
EN(CH_PD) <> 3.3V  
TX  <> TX  
RX <>  TX 

response

AT


OK
AT+CIPSTART="TCP","192.168.0.52",3000

CONNECT

OK
AT+CIPSEND=74


OK
> GET /?id=arduino HTTP/1.0\r\nHost:http://192.168.0.52:3000\r\n\r\n



busy s...

SEND OK
CLOSED

AT+CIPSTART="TCP","192.168.0.52",3000

CONNECT

OK
AT+CIPSEND=39


OK
> GET http://192.168.0.52/id?=arduino\r\n\r\nbusy s...

SEND OK
CLOSED

AT+CIPSTART="TCP","192.168.0.52",3000

CONNECT

OK
AT+CIPSEND=39


OK
> GET http://192.168.0.52/id?=arduino\r\n\r\n
busy s...

SEND OK

Sometime connection CLOSED after sending the request, sometime connection alive.

  • 2
    the 3.3 V pin on Arduino can't supply enough power to esp for wifi transmission – Juraj Oct 20 '17 at 7:25
  • @Juraj then How can I supply power to esp? Connecting another 3.3V to ESP8266 will be enough? – Hyuck-Jun Lee Oct 20 '17 at 8:14
  • sorry I don't know. I bought an esp on a 5 V adapter board with level shifters and the 5 V pin on Uno can supply the required power – Juraj Oct 20 '17 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.