// Library #include // WiFi settings const char* ssid = "Livebox-37cc"; const char* password = "8A6060920A8A86896F770F2C47"; // Time to sleep (in seconds): const int sleepTimeS = 10; // Host const char* host = "192.168.1.3"; const int httpPort = 81; void setup() { // Serial Serial.begin(9600); Serial.println("ESP8266 in normal mode"); // Connect to WiFi WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); // Print the IP address Serial.println(WiFi.localIP()); // Logging data to cloud Serial.print("Connecting to "); Serial.println(host); // Use WiFiClient class to create TCP connections WiFiClient client; if (!client.connect(host, httpPort)) { Serial.println("connection failed"); return; } // This will send the request to the server client.print(String("GET /json.htm?type=command¶m=getSunRiseSet") + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"); delay(10); // 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"); // Sleep Serial.println("ESP8266 in sleep mode"); ESP.deepSleep(sleepTimeS * 1000000); } void loop() { }// Library