Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP8266WiFi.h>
- const char* ssid = "***********";
- const char* password = "*********";
- const char* host = "iot.com";
- String led = "/test.txt";
- String Tempdata = "";
- void setup() {
- delay(100);
- Serial.begin(9600);
- delay(10);
- WiFi.begin(ssid, password);
- int wifi_ctr = 0;
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- }
- }
- void loop() {
- String data;
- WiFiClient client;
- const int httpPort = 80;
- if (!client.connect(host, httpPort)) {
- return;
- }
- client.print(String("GET /") + led + " HTTP/1.1rn" +
- "Host: " + host + "rn" +
- "Connection: closernrn");
- delay(500);
- // int dir = 0;
- // char section[] = "header";
- while (client.available()) {
- data = "";
- data = client.readStringUntil('r');
- }
- data.remove(0, 1);
- if (Tempdata != data)
- {
- Tempdata = data;
- Serial.print(data);
- }
- }
Add Comment
Please, Sign In to add comment