String off = "http://192.168.1.143/relay_off";
String on = "http://192.168.1.143/relay_on";
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
HTTPClient sender;
WiFiClient wifiClient;
const char* ssid = "xyz";
const char* password = "1234";
void setup() {
Serial.begin(115200);
Serial.println();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(200);
Serial.print(".");
}
Serial.println("\rVerbunden!");
if (sender.begin(wifiClient, on)) {
Serial.println("Befehl = " + on);
int httpCode = sender.GET();
if (httpCode > 0) {
if (httpCode == HTTP_CODE_OK)Serial.println(sender.getString());
} else Serial.printf("HTTP - Error: ", sender.errorToString(httpCode).c_str());
} else Serial.printf("HTTP - Verbindung konnte nicht hergestellt werden!");
}
void loop(){
sender.setURL(off);
delay(1999);
sender.setURL(on);
delay(1999);
}
Danke!