Hello there,
I'm trying to let my ESP8266 v1 module read a webpage and print it to the serial monitor. On the monitor I see a status '200 OK' so its seems like he's getting the page but he doesn't really print the page and further info. The code and a piece of monitored ouput are below:
#include "SoftwareSerial.h"
String ssid ="Onderbeke";
String password="SvenOnderbeke";
SoftwareSerial esp8266(3,2);
String data;
String server = "www.kljzomergem.be";
String uri = "/data.html";
String tmpResp = "";
boolean DEBUG = true;
int TD = 1500;
void setup() {
esp8266.begin(115200);
Serial.begin(115200);
sendData("AT+RST\r\n",TD,DEBUG); // reset module
String cmd = "AT+CWJAP=\"" +ssid+"\",\"" + password + "\"";
sendData(cmd,TD,DEBUG);
}
void loop () {
esp8266.println("AT+CIPSTART=\"TCP\",\"" + server + "\",80");//start a TCP connection.
delay(100);
if( esp8266.find("OK")) Serial.println("TCP connection ready");
delay(100);
String postRequest =
"GET " + uri + " HTTP/1.0\r\n" +
"Host: " + server + "\r\n" +
"Connection: close\r\n\r\n";
String sendCmd = "AT+CIPSEND=";
esp8266.print(sendCmd);
esp8266.println(postRequest.length() );
delay(100);
if(esp8266.find(">")) {
Serial.println("Sending..");
esp8266.print(postRequest);
delay(100);
if( esp8266.find("SEND OK")) {
Serial.println("Packet sent");
delay(100);
while (esp8266.available()) {
tmpResp = esp8266.readString();
Serial.println(tmpResp);
}
esp8266.println("AT+CIPCLOSE");
}
}
}
String sendData(String command, const int timeout, boolean debug){
String response = "";
esp8266.print(command);
long int time = millis();
while( (time+timeout) > millis()){
while(esp8266.available()){
char c = esp8266.read();
response+=c;
}
}
if(debug){
Serial.print(response);
}
return response;
}
+IPD,220:HTTP/1.1 100 OK
Date=
Sending..
TCP connection ready
Sending..
TCP connection ready
Sending..
Packet sent
+IPD,221:HTTP/1.1 200 OK
Date: G
Sending..
Packet sent
+IPD,220:HTTP/1.1 200 OK
Date:
Sending..
TCP connection ready
Sending..
Packet sent