first commit

This commit is contained in:
lucas bamberg 2023-06-13 20:51:23 +02:00
commit 99f475ea26
2 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,54 @@
#include <NTPClient.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
// REPLACE WLAN SSID and PW
const char* ssid = "foo";
const char* password = "bar";
//const int RELAIS = D8; //WEMOS D1 PIN D8
const int RELAIS = D2;
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP);
// Variablen
String hour, minute, second;
int iHour, iMinute, iSecond, modulo;
void setup(){
Serial.begin(74880);
pinMode(RELAIS, OUTPUT); // Relais Pins als Ausgang deklarieren
WiFi.begin(ssid, password);
while ( WiFi.status() != WL_CONNECTED ) {
delay ( 500 );
Serial.print ( "." );
}
timeClient.begin();
}
void loop() {
Serial.println("Request NTP Server...");
timeClient.update();
hour = timeClient.getHours();
iHour = hour.toInt();
minute = timeClient.getMinutes();
iMinute = minute.toInt();
second = timeClient.getSeconds();
iSecond = second.toInt();
modulo = iSecond % 2;
Serial.println("Modulo = " + String(modulo));
// ACHTUNG BAMBELBURG -> Notiz an mich selbst: digitalWrite(RELAIS, HIGH) ist AUS!!!
Serial.println("Pin is High");
digitalWrite(RELAIS, HIGH);
delay(3000);
Serial.println("Pin is LOW");
digitalWrite(RELAIS, LOW);
delay(3000);
//if (modulo == 0) {
// digitalWrite(RELAIS, HIGH);
// Serial.println("AUS");
//} else {
// digitalWrite(RELAIS, LOW);
// Serial.println("AN!");
//}
//delay(4000);
}

0
README.md Normal file
View File