-->
Page 1 of 1

Help getting response from website

PostPosted: Wed Aug 12, 2015 6:40 am
by PhillyNJ
Hi, I have an ESP8266-01 and I am communicating via an Arduino. The Arduino code sends the AT commands and I send the ESP8266 response to an OLED Display. I am able to get an IP and connect to the server (Linked). When I send AT+CIPSEND=4,400, I can see the ">". I then send the GET request, but I am not getting a response. I can confirm, the page exists. What am I doing wrong?


Code: Select all#include <Adafruit_ssd1306syp.h>

#define SDA_PIN A4
#define SCL_PIN A5

//Define the pin for the on board LED
int led = 13;
Adafruit_ssd1306syp display(SDA_PIN, SCL_PIN);


void setup()
{
  display.initialize();
  display.clear();
  display.setCursor(0, 0);
  display.println("Connect TX..");
  display.update();
  pinMode(led, OUTPUT);
  delay(5000);
  Serial.begin(115200);
  // Set up Wifi
  Serial.println("AT");
  delay(800);

  if (Serial.find("OK")) {

    display.println("WIFI Ok:");
    display.update();
    Serial.println("AT+CIFSR");
    delay(800);

    display.println(Serial.readString());
    display.update();
    delay(2000);
    display.clear();
    display.update();

  } else {
    display.println("WIFI Failed to initialize");
  }


}

void loop()
{
  Serial.println("AT+CIPMUX=1");
  delay(300);

  getResponse();
  Serial.println("AT+CIPSTART=4,\"TCP\",\"192.168.1.250\",8081");
  delay(2000);
  getResponse();
  Serial.println("AT+CIPSEND=4,400");
  delay(2000);
  getResponse();
  String data;
  data = "GET /index.html HTTP/1.1\r\n";
  data += "Host: 192.168.1.250 \r\n";
  data += "Content-Length: 400 \r\n";
  data += "content-type:application/x-www-form-urlencoded;charset=utf-8\r\n";
  Serial.println(data);
  delay (2000);
  getResponse();
  delay (2000);
  Serial.println("AT+CIPCLOSE=4");
  getResponse();
  delay(5000);
  display.setCursor(0, 0);
}

void getResponse() {

  display.clear();
  display.update();
  display.setCursor(0, 0);
  display.println(Serial.readString());
  display.update();
  Serial.flush();
}