ESP8266 Developer Zone The Official ESP8266 Forum 2016-10-28T12:49:18+08:00 https://bbs.espressif.com:443/feed.php?f=16&t=2948 2016-10-28T12:49:18+08:00 2016-10-28T12:49:18+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2948&p=10322#p10322 <![CDATA[Re: AT+CIPSEND returns CLOSED SEND FAIL]]>
Can you directly connect to the ESP8266 using Rx and Tx lines and then send the commands using a UART terminal to check if you are still getting the error?
Seems like a timing issue to me.
Also, make sure your GET request is correctly formatted. Otherwise your server will usually close the connection abruptly.

Statistics: Posted by Guest — Fri Oct 28, 2016 12:49 pm


]]>
2016-10-28T05:11:50+08:00 2016-10-28T05:11:50+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2948&p=10313#p10313 <![CDATA[AT+CIPSEND returns CLOSED SEND FAIL]]> AT+PING on the same URL works but AT+CIPSEND fails with CLOSED SEND FAIL message.
Can some one look at the code attached and help me know what I am doing wrong here?

Code:

#include <SoftwareSerial.h>
SoftwareSerial ESP8266_Response(2,3);
#define DEBUG true
//AT+UART_DEF=9600,8,1,0,0
void setup() {
   ESP8266_Response.begin(9600);
   Serial.begin(9600);
   
   String s1="";
   s1=sendCommand("AT\r\n",2000,DEBUG);
   Serial.print(s1);
 
   s1=sendCommand("AT+RST\r\n",2000,DEBUG);
   Serial.print(s1);
   
   s1= sendCommand("ATE0\r\n",2000,DEBUG);
   Serial.print(s1);
   
   s1=sendCommand("AT+CWMODE=1\r\n",2000,DEBUG);
   Serial.print(s1);
   
   s1=sendCommand("AT+CWJAP=\"Satyam\",\"vivekvpandya\"\r\n",5000,DEBUG);   
   Serial.print(s1);
   
   sendCommand("AT+CIPMUX=0\r\n",3000,DEBUG);
   sendCommand("AT+CIFSR\r\n",3000,DEBUG);
   
   String siteResp=sendCommand("AT+CIPSTART=\"TCP\",\"dev-pdemo.pantheonsite.io\",80\r\n",5000,DEBUG);
   Serial.print(siteResp);
   
  String cmd = "GET /dustbin_list HTTP/1.1\r\nHost:dev-pdemo.pantheonsite.io\r\n\r\n";

  ESP8266_Response.print("AT+CIPSEND=");
  ESP8266_Response.println(cmd.length());
  delay(8000);
 if(ESP8266_Response.find(">"))
  {
     String s2 = sendCommand(cmd,5000,DEBUG);
     Serial.print(s2);
  } else {
   Serial.print("Could not find >");
  }
}

void loop()
{


}

String sendCommand(String command, const int timeout, boolean debug)
{
    String response = "";
           
    ESP8266_Response.print(command); // send the read character to the esp8266
   
    long int time = millis();
   
    while( (time+timeout) > millis())
    {
      while(ESP8266_Response.available())
      {
        char c = ESP8266_Response.read(); // read the next character.
        response+=c;
      } 
    }
   
    return response;
}


Thanks,
Vivek

Statistics: Posted by vivekvpandya — Fri Oct 28, 2016 5:11 am


]]>