Advertisement
martinius96

Untitled

Jun 10th, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. #include <Arduino.h>
  2. #include <ESP8266WiFi.h>
  3. #include <ESP8266HTTPClient.h>
  4. const char *ssid =  "sid";
  5. const char *pass =  "myssecret";
  6. WiFiClient client;
  7. HTTPClient http;
  8. void setup() {
  9.   Serial.begin(9600);
  10.   delay(100);
  11.   Serial.print("Connecting to ");
  12.   Serial.println(ssid);
  13.   WiFi.begin(ssid, pass);
  14.  
  15.  while (WiFi.status() != WL_CONNECTED) {
  16.     delay(500);
  17.     Serial.print(".");
  18.    
  19.   }
  20.   Serial.println("");
  21.   Serial.println("WiFi connected");
  22. }
  23.  
  24. int httpCode = 0;
  25. void loop() {
  26.  
  27.  
  28.   String url = "http://192.168.1.13:83/dev/sps/io/0f7d5586-039c-3ba2-fffffe345eb0bf31/on";
  29.   http.begin(url);
  30.   http.setAuthorization("admin", "password");
  31.   httpCode = http.GET();
  32.   if (httpCode == HTTP_CODE_OK) {
  33.  
  34.   }
  35.   http.end();
  36. delay(2000);
  37.   String url2 = "http://192.168.1.13:83/dev/sps/io/0f7d5586-039c-3ba2-fffffe345eb0bf31/off";
  38.   http.begin(url2);
  39.   http.setAuthorization("admin", "password");
  40.   httpCode = http.GET();
  41.     if (httpCode == HTTP_CODE_OK) {
  42.     Serial.print("Feuchtigkeit sent to Loxone. ");
  43.   }
  44.   http.end();
  45.   Serial.println("Waiting... 10sec....");
  46.   delay(10000);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement