Lichtklingel: Unterschied zwischen den Versionen

aus Metalab Wiki, dem offenen Zentrum für meta-disziplinäre Magier und technisch-kreative Enthusiasten.
Zur Navigation springenZur Suche springen
Zeile 53: Zeile 53:
 
     alarmo++;
 
     alarmo++;
 
     Serial.println(alarmo);
 
     Serial.println(alarmo);
   
+
     if(alarmo > 20){
 
 
     if(alarmo > 20 && WiFi.status()== WL_CONNECTED){
 
 
       if(WiFi.status() != WL_CONNECTED) {
 
       if(WiFi.status() != WL_CONNECTED) {
      WiFi.disconnect();
+
        WiFi.disconnect();
      WiFi.begin(ssid, password);
+
        WiFi.begin(ssid, password);
      Serial.println("Connecting");
+
        Serial.println("Connecting");
      while(WiFi.status() != WL_CONNECTED) {
+
        while(WiFi.status() != WL_CONNECTED) {
        delay(500);
+
          delay(500);
        Serial.print(".");
+
          Serial.print(".");
      }
+
        }
    Serial.println("");
+
        Serial.println("");
      Serial.print("Connected to WiFi network with IP Address: ");
+
        Serial.print("Connected to WiFi network with IP Address: ");
      Serial.println(WiFi.localIP());
+
        Serial.println(WiFi.localIP());
    }
+
      }  
 
       HTTPClient http;
 
       HTTPClient http;
  

Version vom 5. März 2022, 00:50 Uhr

Language: English
Subpages:
Lichtklingel hat keine Unterseiten.

Lichtklingel

Türklingel ist auditiv nicht barrierefrei für gehörlose und hörbehinderte Menschen.
Ebenso können Kopfhörernutzer*innen die Türklingel oftmals verpassen. Daher wurde die Glocke an das Cleanup-Lichtsignal angehängt. Jetzt leuchtet die Leuchtbirne im Hauptraum, Whateverlab und in der Bibliothek und schaltet sich nach 10 Sekunden ab.


Lichtklingel
Lichtklingel.jpg
Gestartet: 2022-03-02
Involvierte: fussel
Status: active
Beschreibung: Signalleuchte leuchtet, wenn wer an der Türe läutet.
Shutdownprozedur: Kann laufen gelassen werden
Zuletzt aktualisiert: 2022-03-05

Lichtklingel.gif

Schaltung

Code

#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid = "Metalab Secure";
const char* password = "********";
int alarmo = 0;

void setup() {
  Serial.begin(115200);
  Serial.println("start");
  pinMode(25,INPUT_PULLUP);
  WiFi.begin(ssid, password);
  while(WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(".");
    }
}

void loop() {


  if(digitalRead(25)==LOW){
    alarmo++;
    Serial.println(alarmo);
    if(alarmo > 20){
      if(WiFi.status() != WL_CONNECTED) {
        WiFi.disconnect();
        WiFi.begin(ssid, password);
        Serial.println("Connecting");
        while(WiFi.status() != WL_CONNECTED) {
          delay(500);
          Serial.print(".");
        }
        Serial.println("");
        Serial.print("Connected to WiFi network with IP Address: ");
        Serial.println(WiFi.localIP());
      }   
      HTTPClient http;

      //TURN ON Hauptraum-Alarm
      String serverPath = "http://hauptraumalarm/cm?cmnd=Power%20ON";
      http.begin(serverPath.c_str());
      int httpResponseCode = http.GET();
      http.end();
      //TURN ON WEL-Alarm
      serverPath = "http://welalarm/cm?cmnd=Power%20ON";
      http.begin(serverPath.c_str());
      httpResponseCode = http.GET();
      http.end();
      //TURN ON Bib-Alarm
      serverPath = "http://bibliothekalarm/cm?cmnd=Power%20ON";
      http.begin(serverPath.c_str());
      httpResponseCode = http.GET();
      http.end();
      
      //Wait 10 seconds
      delay(10000);

      //TURN OFF Hauptraum-Alarm
      serverPath = "http://hauptraumalarm/cm?cmnd=Power%20OFF";
      http.begin(serverPath.c_str());
      httpResponseCode = http.GET();
      http.end();
       //TURN OFF WEL-Alarm
      serverPath = "http://welalarm/cm?cmnd=Power%20OFF";
      http.begin(serverPath.c_str());
      httpResponseCode = http.GET();
      http.end();
      //TURN OFF Bib-Alarm
      serverPath = "http://bibliothekalarm/cm?cmnd=Power%20OFF";
      http.begin(serverPath.c_str());
      httpResponseCode = http.GET();
      http.end();

    WiFi.disconnect();
    alarmo = 0;
    }

  } else {
    alarmo--;
  }
  if(alarmo < 0){
    alarmo = 0;
  }
 
}