Today I changed something and I've gotten to the stage where I'm receiving a response from the wifi module in html. I pasted the html into a document to see what the message was and this is what I got http://imgur.com/4xQ0tYw . Does anyone know what is wrong. It claims I need a valid host header but I was under the impression that I provided them with one.
Here is my code for reference.
/*
* Simple HTTP get webclient test
*/
#include <ESP8266WiFi.h>
const char* ssid = "ii0C3B5Eprimary";
const char* password = "8ce0fcc6";
const char* host = "www.adafruit.com";
void setup() {
Serial.begin(115200);
delay(100);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
int value = 0;
void loop() {
delay(5000);
++value;
Serial.print("connecting to ");
Serial.println(host);
// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
client.println("GET /testwifi/index.html http/1.1");
delay(500);
// Read all the lines of the reply from server and print them to Serial
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}
Serial.println();
Serial.println("closing connection");
}