/** * BasicHTTPClient.ino * * Created on: 24.05.2015 * */ #include #include #include #include #define USE_SERIAL Serial ESP8266WiFiMulti WiFiMulti; void setup() { USE_SERIAL.begin(115200); // USE_SERIAL.setDebugOutput(true); USE_SERIAL.println(); USE_SERIAL.println(); USE_SERIAL.println(); for(uint8_t t = 4; t > 0; t--) { USE_SERIAL.printf("[SETUP] WAIT %d...\n", t); USE_SERIAL.flush(); delay(1000); } WiFiMulti.addAP("TLU", ""); pinMode(5, OUTPUT); } void loop() { // wait for WiFi connection if((WiFiMulti.run() == WL_CONNECTED)) { HTTPClient http; http.begin("http://www.tlu.ee/~jaagup/veeb1/tuluke1.txt"); //HTTP int httpCode = http.GET(); if(httpCode > 0) { if(httpCode == HTTP_CODE_OK) { String payload = http.getString(); USE_SERIAL.println(payload); if(payload=="sees"){ digitalWrite(5, HIGH); } else{ digitalWrite(5, LOW); } } } else { USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str()); } http.end(); } delay(10000); }