Chat freely about anything...

User avatar
By Tomega3
#11281 I have an ESP8266 ESP-01 running the AT firmware from the espressif SDK95
AT+GMR
AT+GMR AT version:0.21.0.0
SDK version:0.9.5

OK

i am running a sketch on an arduino board called ESPToy
http://rayshobby.net/?p=10156
because its has 2 hardware serial ports and 4k of sram
The sketch connects to a web based weather data website
http://www.wunderground.com/weather/api/d/login.html or http://www.openweathermap.org

The sketch requires you to enter in your wifi SSID, PASSWORD, a LOCATION and a KEY which is provided for free from the weather web sites.
My sketch is attached.

The possible problem with the CIPSEND Get command appears when issuing subsequent AT command after having processed the reply from the weather data website.

The sketch issues a AT+CIPCLOSE command after processing the replied data.
It looks for an OK response to the AT+CIPCLOSE command and prints out the response to the command on a serial monitor.

I expect to see AT+CIPCLOSE OK but what I see is some portion of the web sites response to the GET request, if my receiver buffer is big enough, I can see the OK sometimes, otherwise the routine that looks for the OK timesout or reports buffer overflow condition, in either case I display the response from the esp-01 for the AT CIPLCLOSE command on the monitor.

Why would the response from a AT+CIPCLOSE command after a CIPSEND GET command reply with anything other than AT+CIPCLOSE OK ? Is this a bug or feature of the AT Firmware in the sdk95?

Thanks for you help.

attached sketch:
User avatar
By Tomega3
#11471 my arduino sketch needed to add a timeout test to the code that empties the esp buffer after it has found the json data it is looking for.

changed this code:
Code: Select all  dbg.print(F("\nMatching json data: "));
  dbg.println(json);                 // uncomment to see the json data
 
  // empty the esp serial buffer
  while(esp.available())
  {
      esp.read();
  }


to this:
Code: Select all  dbg.print(F("\nMatching json data: "));
  dbg.println(json);                 // uncomment to see the json data
 
  // empty the esp serial buffer
  dbg.println(F("\nEmpty the ESP serial buffer."));
  debug_read_esp(REPLYWAITTIME, true);               // change true to false to not print buffer contents on debug monitor
  dbg.println (F("\nESP Buffer empty!"));


here's to code for the debug_read_esp function
Code: Select all// read all data from ESP8266 until timeout
bool debug_read_esp(unsigned long timeout=10000, boolean printme=false)
{
  unsigned long t=millis();
  char c = 0;
  while(millis()<t+timeout)
  {
    while(esp.available())
    {
      c = (char)esp.read();
      if (printme)
      {
        dbg.print(c);
      }
    }
  }
  return true;
}