Post topics, source code that relate to the Arduino Platform

User avatar
By PhillyNJ
#25782 Hi, I am using a ESP8266-01 with the following code. I am able to send the ESP8266 response to an OLED display to ready. At this point I am able to get an IP address and connected to the server (linked), but my GET request doesn't seems to return anything. Am I constructing my GET correctly?

Code: Select all#include <Adafruit_ssd1306syp.h>

#define SDA_PIN A4
#define SCL_PIN A5

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();
}

User avatar
By PhillyNJ
#25851 Thanks. I am able to get a response of

Code: Select all+IPD,4,422


However, I am getting 400 Bad Request. Here is my request string:

Code: Select all  String data;
  data = "GET /index.html HTTP/1.1\r\n\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);


Thanks for the help
User avatar
By PhillyNJ
#25854 got it working with

Code: Select all String data;
  data = "GET /index.html HTTP/1.0\r\n\r\n";
  data += "Host: 192.168.1.250 \r\n";
  data += "Content-Length: 150 \r\n";
  data += "Content-Type:application/x-www-form-urlencoded;charset=utf-8\r\n";
  Serial.println(data);


Thanks again!