/*
* Simple HTTP get webclient test
*/
#include <ESP8266WiFi.h>
const char* ssid = "virginmedia545641";
const char* password = "mypassword";
const char* host = "192.168.0.10";
//const char* host = "www.adafruit.com";
String url = "/electronics/test.php";
//String url = "/testwifi/index.html";
const int httpPort = 80;
String remoteData;
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());
}
void loop() {
// Use WiFiClient class to create TCP connections
WiFiClient client;
unsigned long testStartTime = millis();
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(1);
// Read all the lines of the reply from server and print them to Serial
while(client.available()){
remoteData = client.readStringUntil('\r');
}
Serial.println(millis() - testStartTime);
//Serial.println(remoteData);
//delay(3000);
}
Moderator: igrr