title: Can't establish a connection using ESP8266 and Arduino uno
body: <p>I'm using an Arduino Uno Rev3 with ESP8266 to connect into a network and send some data through TCP sockets. I'm using the following code to establish a connection</p>
  
  <pre><code>boolean connectWifi() {
    String cmd =  "AT+CWJAP=\"";
           cmd += SSID;
           cmd += "\",\"";
           cmd += PASS;
           cmd += "\"";
    Serial.flush();
    Serial.println(cmd);
    delay(5000);
    if(Serial.find("OK")) {
      Serial.println("Connected");
      return true;
    } else {
      Serial.println("Not connected");
      return false;
    }
  }
  </code></pre>
  
  <p>but everytime I call this function inside the arduino loop(), I receive "Not connected".</p>
  
  <p>I have already tried to connect direct from serial monitor running an empty code on Arduino and this AT command worked very well. Someone have any idea about what is wrong?</p>
  
  <p>Connections:</p>
  
  <p>(Used when I need to send commands right from arduino code)<br>
      Arduino  ------------  ESP8266<br>
      3.3v --------------------- vcc<br>
      gnd ---------------------- gnd<br>
      3.3v ------------------- CH_PD<br>
      TX ------------------------ RX<br>
      RX ------------------------ TX  </p>
  
  <p>(Used when I need to send commands right from arduino serial monitor)<br>
      Arduino  ------------  ESP8266<br>
      3.3v --------------------- vcc<br>
      gnd ---------------------- gnd<br>
      3.3v ------------------- CH_PD<br>
      TX ------------------------ TX<br>
      RX ------------------------ RX  </p>