title: How can I fix timeout in Arduino with ESP8266?
body: <p>I am working with Arduino Uno and ESP8266.</p>
  
  <p>I connected ESP8266 with Arduino Uno, 
  and downloaded ESP8266 library(<a href="https://github.com/Diaoul/arduino-ESP8266" rel="nofollow">https://github.com/Diaoul/arduino-ESP8266</a>)..</p>
  
  <p>'joinAP' was OK and 'connect' was also OK.</p>
  
  <p>But the problem was http request.</p>
  
  <p>"getStatus(wifi.send("GET / HTTP/1.0\r\n\r\n"))" in setup code always showed me 'TIMEOUT'.</p>
  
  <p>Below is my code.</p>
  
  <p>Please save my code..</p>
  
  <pre><code>#include &lt;SoftwareSerial.h&gt;
  #include "ESP8266.h"
  
  #define SSID "SSID"
  #define PASS "PASS"
  #define DST_IP "www.google.com"
  
  SoftwareSerial esp8266Serial = SoftwareSerial(2, 3);
  ESP8266 wifi = ESP8266(esp8266Serial);
  
  void setup()
  {
  Serial.begin(9600);
  
  // ESP8266
  esp8266Serial.begin(9600);
  wifi.begin();
  wifi.setTimeout(10);
  
  /****************************************/
  /******       Basic commands       ******/
  /****************************************/
  // test
  Serial.print("test: ");
  Serial.println(getStatus(wifi.test()));
  
  // restart
  Serial.print("restart: ");
  Serial.println(getStatus(wifi.restart()));
  
  // getVersion
  char version[16] = {};
  Serial.print("getVersion: ");
  Serial.print(getStatus(wifi.getVersion(version, 16)));
  Serial.print(" : ");
  Serial.println(version);
  
  
  // getWifiMode
  ///*
  ESP8266WifiMode mode;
  Serial.print("getWifiMode: ");
  Serial.println(getStatus(wifi.getMode(&amp;mode)));//*/
  Serial.print("Wifi mode&gt;&gt;:"); 
  Serial.println(mode);
  if( mode != ESP8266_WIFI_STATION)
  {
  // setWifiMode
  Serial.print("setWifiMode: ");
  // Serial.println(getStatus(wifi.setMode(ESP8266_WIFI_ACCESSPOINT)));
  Serial.println(getStatus(wifi.setMode(ESP8266_WIFI_STATION )));
  }
  else
  Serial.println("already ESP8266_WIFI_STATION mode");
  
  /****************************************/
  /******        WiFi commands       ******/
  /****************************************/
  // joinAP
  Serial.print("joinAP: ");
  Serial.println(getStatus(wifi.joinAP(SSID, PASS)));
  
  
  /****************************************/
  /******       TCP/IP commands      ******/
  /****************************************/
  // connect
  Serial.print("connect: ");
  Serial.println(getStatus(wifi.connect(ESP8266_PROTOCOL_TCP, DST_IP, 80)));
  
  // send
  Serial.print("send: ");
  Serial.println(getStatus(wifi.send("GET / HTTP/1.0\r\n\r\n")));
  
  }
  
  void loop()
  {
  /****************************************/
  /******        WiFi commands       ******/
  /****************************************/
  
  // read data
  unsigned int id;
  int length;
  int totalRead;
  char buffer[300] = {};
  
  if ((length = wifi.available()) &gt; 0) {
    id = wifi.getId();
    totalRead = wifi.read(buffer, 300);
  
    if (length &gt; 0) {
      Serial.print("Received ");
      Serial.print(totalRead);
      Serial.print("/");
      Serial.print(length);
      Serial.print(" bytes from client ");
      //Serial.print("from client ");
      Serial.print(id);
      Serial.print(": ");
      Serial.println((char*)buffer);
    }
    }
   }
  
  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;
  }
  }
  </code></pre>