sonstiges:tuerklingel
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
sonstiges:tuerklingel [2023-09-29 21:58] – [Empfänger mit Netzteil versorgen] schuballaa | sonstiges:tuerklingel [2025-02-05 20:12] (aktuell) – [Sender in Haustelefon einbauen] schuballaa | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
====== Türklingel ====== | ====== Türklingel ====== | ||
- | |||
===== Übersicht ===== | ===== Übersicht ===== | ||
Zeile 10: | Zeile 9: | ||
**Optional: | **Optional: | ||
- | Es könnte zu jeder zeit an sender und oder Empfängern eine Li-ion Akku (via JST) angeschlossen werden und somit auch mobil betrieben werden z.b bei Veranstaltungen die im Hinnenhof stattfinden um kein Klingeln zu verpassen. | + | Es könnte zu jeder zeit an den Empfängern eine Li-ion Akku (via JST) angeschlossen werden und somit auch mobil betrieben werden z.b bei Veranstaltungen die im Hinnenhof stattfinden um kein Klingeln zu verpassen. |
**Achtung bei Powerbanks!** | **Achtung bei Powerbanks!** | ||
Da sich die meisten Powerbanks bei geringer Last ausschalten, | Da sich die meisten Powerbanks bei geringer Last ausschalten, | ||
- | |||
===== Sprechanlage ===== | ===== Sprechanlage ===== | ||
Zeile 21: | Zeile 19: | ||
Die Sprechanlage nutzt ein 2-Draht-Bussystem vom Typ [[http:// | Die Sprechanlage nutzt ein 2-Draht-Bussystem vom Typ [[http:// | ||
- | Das Haustelefon ist vom Typ STR HT 3033. | + | Das Haustelefon ist vom Typ STR HT 3033. |
+ | |||
+ | Das Steuergerät ist ein SP 333 ({{: | ||
- | Das Steuergerät ist ein SP 333 ({{: | ||
===== Pinout ===== | ===== Pinout ===== | ||
Zeile 30: | Zeile 29: | ||
Die Belegung lässt sich durch ein Foto einer Relaisbox {{: | Die Belegung lässt sich durch ein Foto einer Relaisbox {{: | ||
- | {{: | + | {{: |
- | {{: | + | |
Mechanisch konnten die passenden Steckerweibchen nicht ermittelt werden. Daher greifen wir das Signal über zwei IC-Beinchen-Einsätze gedrehter IC-Sockel ab, die in den Steckverbindern verlässlich halten. | Mechanisch konnten die passenden Steckerweibchen nicht ermittelt werden. Daher greifen wir das Signal über zwei IC-Beinchen-Einsätze gedrehter IC-Sockel ab, die in den Steckverbindern verlässlich halten. | ||
Zeile 39: | Zeile 37: | ||
Da uns keine Leitung zwischen den Räumen Bornstr. 14-15 sowie 16-17 zur Verfügung steht, mussten wir auf eine [[http:// | Da uns keine Leitung zwischen den Räumen Bornstr. 14-15 sowie 16-17 zur Verfügung steht, mussten wir auf eine [[http:// | ||
- | Wenn geklingelt wird, zieht ein n channel mosfet den Pin 4 des [[https:// | + | Änderungen am 04.02.2025: |
+ | |||
+ | Der Mosfet (siehe Bild) hat nicht mehr das Klingel Signal zum ESPNOW Sender weitergeleitet. Daher dedektiere ich das Klingelsignal nun über einen H11LX (Optokoppler) der beim Klingeln den Pin 04 LOW setzt und ein ESPNOW signal zu den Empfängern | ||
+ | |||
+ | Zusätzlich habe ich den Empfängern mit einem Watchchdog und ein auto restart (jede Minute) ausgestattet. | ||
+ | |||
+ | Nachtrag am 05.02.2025: | ||
+ | |||
+ | Es kam gelegentlich zu Fehlauslösungen. Daher habe ich in der Software eingestellt, | ||
===== Sender in Haustelefon einbauen ===== | ===== Sender in Haustelefon einbauen ===== | ||
- | Der Sender ist ein ESP32 Lolin Lite welcher auf ein Trigger auf Pin 4 wartet | + | Der Sender ist ein ESP32 Lolin Lite welcher auf ein Trigger auf Pin 4 wartet. |
{{https:// | {{https:// | ||
Zeile 52: | Zeile 58: | ||
Sender: | Sender: | ||
+ | < | ||
- | #include < | + | #include < |
- | #include < | + | #include < |
#include < | #include < | ||
- | // Set your new MAC Address\\ | + | // Set your new MAC Address |
uint8_t newMACAddress[] = {0x30, 0xAF, 0xA0, 0x05, 0x1D, 0x63}; | uint8_t newMACAddress[] = {0x30, 0xAF, 0xA0, 0x05, 0x1D, 0x63}; | ||
- | + | uint8_t broadcastAddress1[] = {0x30, 0xAF, 0xA1, 0x05, 0x1D, 0x63}; | |
- | // REPLACE WITH YOUR ESP RECEIVER' | + | |
- | uint8_t broadcastAddress1[] = {0x30, 0xAF, 0xA1, 0x05, 0x1D, 0x63};\\ | + | |
uint8_t broadcastAddress2[] = {0x30, 0xAF, 0xA2, 0x05, 0x1D, 0x63}; | uint8_t broadcastAddress2[] = {0x30, 0xAF, 0xA2, 0x05, 0x1D, 0x63}; | ||
- | typedef struct bell_struct {\\ | + | unsigned long TestpreviousMillis = 0; |
- | uint64_t trigger;\\ | + | unsigned long DebugpreviousMillis = 0; |
+ | |||
+ | const long Testinterval = 60000; | ||
+ | const long Debuginterval = 1000; | ||
+ | |||
+ | int testPin = 33; | ||
+ | int triggerPin = 4; | ||
+ | |||
+ | int testmode = 0; | ||
+ | int testmodeState = 0; | ||
+ | int triggerState = 0; | ||
+ | |||
+ | typedef struct bell_struct { | ||
+ | uint64_t trigger; | ||
} bell_struct; | } bell_struct; | ||
Zeile 72: | Zeile 90: | ||
esp_now_peer_info_t peerInfo; | esp_now_peer_info_t peerInfo; | ||
- | // callback | + | // Variable, die von der ISR gesetzt wird |
- | void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {\\ | + | volatile bool bellTriggered = false; |
- | char macStr[18];\\ | + | |
- | Serial.print(" | + | // Callback |
- | // Copies the sender mac address to a string\\ | + | void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) { |
- | snprintf(macStr, | + | char macStr[18]; |
- | | + | snprintf(macStr, |
- | Serial.print(macStr); | + | |
- | Serial.print(" | + | |
- | Serial.println(status == ESP_NOW_SEND_SUCCESS ? " | + | |
+ | Serial.print(" | ||
+ | Serial.println(status == ESP_NOW_SEND_SUCCESS ? " | ||
} | } | ||
- | void setup() {\\ | + | void setup() { |
- | Serial.begin(115200); | + | Serial.begin(115200); |
- | WiFi.mode(WIFI_STA); | + | |
- | // Set the ESP32 Board MAC Address.\\ | + | |
- | esp_wifi_set_mac(WIFI_IF_STA, | + | esp_wifi_set_mac(WIFI_IF_STA, |
+ | Serial.print(" | ||
+ | Serial.println(WiFi.macAddress()); | ||
- | // Print the new MAC Address.\\ | + | if (esp_now_init() != ESP_OK) { |
- | Serial.print("[NEW] ESP32 Board MAC Address: | + | Serial.println("Error initializing ESP-NOW"); |
- | Serial.println(WiFi.macAddress()); | + | ESP.restart(); |
+ | } | ||
- | if (esp_now_init() != ESP_OK) {\\ | + | esp_now_register_send_cb(OnDataSent); |
- | Serial.println(" | + | |
- | ESP.restart();\\ | + | |
- | } | + | |
- | esp_now_register_send_cb(OnDataSent); | + | // Register first peer |
+ | peerInfo.channel = 0; | ||
+ | peerInfo.encrypt = false; | ||
+ | memcpy(peerInfo.peer_addr, | ||
+ | if (esp_now_add_peer(& | ||
+ | Serial.println(" | ||
+ | return; | ||
+ | } | ||
- | // register | + | |
- | peerInfo.channel = 0;\\ | + | memcpy(peerInfo.peer_addr, |
- | peerInfo.encrypt = false;\\ | + | if (esp_now_add_peer(& |
- | // register first peer\\ | + | Serial.println(" |
- | memcpy(peerInfo.peer_addr, | + | return; |
- | if (esp_now_add_peer(& | + | } |
- | Serial.println(" | + | |
- | return;\\ | + | |
- | } | + | |
- | // register second peer\\ | + | |
- | memcpy(peerInfo.peer_addr, | + | |
- | if (esp_now_add_peer(& | + | |
- | | + | |
- | | + | |
} | } | ||
- | // Set pin 4 as an interrupt\\ | + | // Minimal Interrupt-Service-Routine |
- | pinMode(4, INPUT_PULLUP);\\ | + | void triggerbell() { |
- | attachInterrupt(digitalPinToInterrupt(4), | + | |
} | } | ||
- | void triggerbell() {\\ | + | void testbell() { |
- | bell.trigger = 8562190430; | + | bell.trigger = 4042190430; |
- | esp_err_t result = esp_now_send(0, | + | |
- | + | ||
- | if (result == ESP_OK) {\\ | + | |
- | Serial.println(" | + | |
- | } else {\\ | + | |
- | Serial.println(" | + | |
- | } | + | |
- | Serial.print("[NEW] ESP32 Board MAC Address: | + | if (result == ESP_OK) { |
- | Serial.println(WiFi.macAddress()); | + | |
+ | } else { | ||
+ | | ||
+ | } | ||
+ | Serial.print(" | ||
+ | Serial.println(WiFi.macAddress()); | ||
} | } | ||
void loop() { | void loop() { | ||
+ | unsigned long currentMillis = millis(); | ||
+ | testmodeState = digitalRead(testPin); | ||
+ | triggerState = digitalRead(triggerPin); | ||
+ | |||
+ | // Verarbeitung, | ||
+ | if (bellTriggered) { | ||
+ | bellTriggered = false; // Zurücksetzen der Flag-Variable | ||
+ | |||
+ | // Senden des Klingelsignals | ||
+ | bell.trigger = 8562190430; | ||
+ | |||
+ | esp_err_t result = esp_now_send(0, | ||
+ | |||
+ | if (result == ESP_OK) { | ||
+ | Serial.println(" | ||
+ | } else { | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | Serial.print(" | ||
+ | Serial.println(WiFi.macAddress()); | ||
+ | } | ||
+ | |||
+ | // Testmodus umschalten | ||
+ | if (testmodeState == 0 && testmode == 0) { | ||
+ | Serial.println(" | ||
+ | testmode = 1; | ||
+ | TestpreviousMillis = Testinterval + currentMillis; | ||
+ | } | ||
+ | |||
+ | if (testmodeState == 1 && testmode == 1) { | ||
+ | Serial.println(" | ||
+ | testmode = 0; | ||
+ | TestpreviousMillis = Testinterval + currentMillis; | ||
+ | } | ||
+ | |||
+ | // Debugging-Ausgabe | ||
+ | if (currentMillis - DebugpreviousMillis> | ||
+ | DebugpreviousMillis = currentMillis; | ||
+ | Serial.print(" | ||
+ | Serial.print(testmodeState); | ||
+ | Serial.print(" | ||
+ | Serial.println(triggerState); | ||
+ | } | ||
+ | |||
+ | // Testklingelsignal im Testmodus senden | ||
+ | if (currentMillis - TestpreviousMillis> | ||
+ | TestpreviousMillis = currentMillis; | ||
+ | if (testmode == 1) { | ||
+ | Serial.println(" | ||
+ | testbell(); | ||
+ | } else { | ||
+ | Serial.println(" | ||
+ | } | ||
+ | } | ||
} | } | ||
+ | |||
+ | </ | ||
Empfänger1 | Empfänger1 | ||
- | #include < | + | < |
- | #include < | + | #include < |
+ | #include < | ||
#include < | #include < | ||
+ | #include < | ||
- | // Set MAC Address this device (bell receiver 1)\\ | + | // Set MAC Address this device (bell receiver 1) |
uint8_t newMACAddress[] = {0x30, 0xAF, 0xA1, 0x05, 0x1D, 0x63}; | uint8_t newMACAddress[] = {0x30, 0xAF, 0xA1, 0x05, 0x1D, 0x63}; | ||
- | |||
uint8_t addr[] = {0x30, 0xAF, 0xA0, 0x05, 0x1D, 0x63}; | uint8_t addr[] = {0x30, 0xAF, 0xA0, 0x05, 0x1D, 0x63}; | ||
+ | unsigned long lastPrintoutTime = 0; | ||
+ | unsigned long lastRebootTime = 0; | ||
+ | unsigned long lastDebugTime = 0; | ||
+ | const unsigned long DebugIntervall = 1000; | ||
+ | const unsigned long REBOOT_INTERVAL = 60000; // Periodischer Neustart nach 60 Sekunden | ||
- | unsigned long lastPrintoutTime = 0;\\ | + | bool isTriggered = false; |
- | bool isTriggered = false;\\ | + | |
unsigned long lastTriggeredTime = 0; | unsigned long lastTriggeredTime = 0; | ||
- | typedef struct bell_struct {\\ | + | int selftest = 0; |
- | uint64_t trigger;\\ | + | |
+ | typedef struct bell_struct { | ||
+ | uint64_t trigger; | ||
} bell_struct; | } bell_struct; | ||
- | //Create a struct_message called myData\\ | + | // Create a struct_message called myData |
bell_struct myData; | bell_struct myData; | ||
- | void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, | + | // |
- | memcpy(& | + | // |
- | Serial.print("Bytes received: | + | //got this watchdog code from Andreas Spiess |
- | Serial.println(len); | + | |
- | Serial.print(" | + | Ticker secondTick; |
- | Serial.println(myData.trigger);\\ | + | volatile int watchdogCount = 0; |
- | if (memcmp(mac, addr, 6) == 0) { // Check if expected Mac Addr\\ | + | |
- | | + | void ISRwatchdog() { |
- | if (myData.trigger == 8562190430) {\\ | + | |
- | Serial.println(" | + | if (watchdogCount> |
- | | + | Serial.println(" |
- | }\\ | + | |
- | }\\ | + | } |
} | } | ||
+ | //END WATCHDOG | ||
- | void setup() { | + | void printRestartReason() { |
+ | esp_reset_reason_t reason = esp_reset_reason(); | ||
+ | Serial.print(" | ||
+ | switch (reason) { | ||
+ | case ESP_RST_POWERON: | ||
+ | case ESP_RST_EXT: | ||
+ | case ESP_RST_SW: Serial.println(" | ||
+ | case ESP_RST_PANIC: | ||
+ | case ESP_RST_INT_WDT: | ||
+ | case ESP_RST_TASK_WDT: | ||
+ | case ESP_RST_WDT: | ||
+ | case ESP_RST_DEEPSLEEP: | ||
+ | case ESP_RST_BROWNOUT: | ||
+ | case ESP_RST_SDIO: | ||
+ | default: Serial.println(" | ||
+ | } | ||
+ | } | ||
- | Serial.begin(115200); | + | void OnDataRecv(const esp_now_recv_info_t *info, const uint8_t *incomingData, |
+ | memcpy(& | ||
+ | | ||
+ | Serial.println(len); | ||
+ | Serial.print(" | ||
+ | Serial.println(myData.trigger); | ||
- | Serial.println(); | + | // Prüfen, ob die MAC-Adresse übereinstimmt |
+ | if (memcmp(info-> | ||
+ | | ||
+ | if (myData.trigger == 8562190430) { | ||
+ | Serial.println(" | ||
+ | triggerbell(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
- | WiFi.mode(WIFI_STA); | + | void setup() { |
+ | Serial.begin(115200); | ||
+ | Serial.println(); | ||
+ | secondTick.attach(1, | ||
+ | printRestartReason(); | ||
- | Serial.print(" | + | WiFi.mode(WIFI_STA); |
- | Serial.println(WiFi.macAddress()); | + | |
+ | Serial.println(WiFi.macAddress()); | ||
- | // ESP32 Board add-on before version < 1.0.5\\ | + | |
- | //esp_wifi_set_mac(ESP_IF_WIFI_STA, & | + | Serial.print(" |
+ | Serial.println(WiFi.macAddress()); | ||
- | // ESP32 Board add-on after version > 1.0.5\\ | + | pinMode(LED_BUILTIN, |
- | esp_wifi_set_mac(WIFI_IF_STA, & | + | |
- | Serial.print("[NEW] ESP32 Board MAC Address: | + | if (selftest == 1) { |
- | Serial.println(WiFi.macAddress()); | + | |
+ | | ||
+ | digitalWrite(4, | ||
+ | delay(100); | ||
+ | digitalWrite(4, | ||
+ | digitalWrite(LED_BUILTIN, | ||
+ | delay(100); | ||
+ | } else { | ||
+ | | ||
+ | } | ||
- | pinMode(LED_BUILTIN, | + | WiFi.mode(WIFI_STA); |
- | pinMode(4, OUTPUT); | + | |
- | digitalWrite(LED_BUILTIN, | + | // ESP-NOW initialisieren |
- | digitalWrite(4, | + | if (esp_now_init() != ESP_OK) { |
- | delay(100);\\ | + | |
- | digitalWrite(4, LOW);\\ | + | |
- | digitalWrite(LED_BUILTIN, | + | } |
- | delay(100); | + | |
- | //Set device as a Wi-Fi Station\\ | + | esp_now_register_recv_cb(OnDataRecv); |
- | WiFi.mode(WIFI_STA); | + | |
- | //Init ESP-NOW\\ | + | lastRebootTime |
- | if (esp_now_init() != ESP_OK) {\\ | + | |
- | Serial.println("Error initializing ESP-NOW" | + | |
- | ESP.restart(); | + | |
} | } | ||
- | // Once ESPNow is successfully Init, we will register for recv CB to\\ | + | void triggerbell() { |
- | // get recv packer info\\ | + | if (!isTriggered || (millis() - lastTriggeredTime> |
- | esp_now_register_recv_cb(OnDataRecv);\\ | + | isTriggered = true; |
+ | lastTriggeredTime = millis(); | ||
+ | digitalWrite(LED_BUILTIN, LOW); | ||
+ | | ||
+ | |||
+ | delay(100); | ||
+ | digitalWrite(4, | ||
+ | digitalWrite(LED_BUILTIN, | ||
+ | Serial.println(" | ||
+ | } | ||
} | } | ||
- | \\ | + | void loop() { |
- | void triggerbell() {\\ | + | |
- | if (!isTriggered || (millis() - lastTriggeredTime > 10000)) {\\ | + | |
- | isTriggered = true;\\ | + | |
- | lastTriggeredTime = millis(); | + | |
- | digitalWrite(LED_BUILTIN, | + | // Reset der `isTriggered`-Variable nach 5 Sekunden |
- | digitalWrite(4, | + | |
- | | + | |
- | digitalWrite(4, LOW);\\ | + | } |
- | | + | |
- | | + | |
- | }\\ | + | |
- | } | + | |
- | void loop() {\\ | + | |
- | // Print out the `isTriggered` variable every second\\ | + | if (millis() - lastRebootTime> REBOOT_INTERVAL) { |
- | if (millis() - lastPrintoutTime | + | Serial.println("Performing periodic reboot..."); |
- | Serial.print("isTriggered: | + | ESP.restart(); |
- | | + | } |
- | | + | |
- | }\\ | + | if (millis() - lastDebugTime> DebugIntervall) { |
- | \\ | + | |
- | // Reset the `isTriggered` variable after 5 seconds\\ | + | |
- | if (millis() - lastTriggeredTime | + | Serial.println(isTriggered); |
- | | + | |
- | }\\ | + | |
- | \\ | + | watchdogCount = 0; |
} | } | ||
+ | |||
+ | </ | ||
Empfänger2 | Empfänger2 | ||
+ | < | ||
- | #include < | + | #include < |
- | #include < | + | #include < |
#include < | #include < | ||
+ | #include < | ||
- | // Set MAC Address this device (bell receiver 2)\\ | + | // Set MAC Address this device (bell receiver 2) |
uint8_t newMACAddress[] = {0x30, 0xAF, 0xA2, 0x05, 0x1D, 0x63}; | uint8_t newMACAddress[] = {0x30, 0xAF, 0xA2, 0x05, 0x1D, 0x63}; | ||
- | |||
uint8_t addr[] = {0x30, 0xAF, 0xA0, 0x05, 0x1D, 0x63}; | uint8_t addr[] = {0x30, 0xAF, 0xA0, 0x05, 0x1D, 0x63}; | ||
+ | unsigned long lastPrintoutTime = 0; | ||
+ | unsigned long lastRebootTime = 0; | ||
+ | unsigned long lastDebugTime = 0; | ||
+ | const unsigned long DebugIntervall = 1000; | ||
+ | const unsigned long REBOOT_INTERVAL = 60000; // Periodischer Neustart nach 60 Sekunden | ||
- | unsigned long lastPrintoutTime = 0;\\ | + | bool isTriggered = false; |
- | bool isTriggered = false;\\ | + | |
unsigned long lastTriggeredTime = 0; | unsigned long lastTriggeredTime = 0; | ||
- | typedef struct bell_struct {\\ | + | int selftest = 0; |
- | uint64_t trigger;\\ | + | |
+ | typedef struct bell_struct { | ||
+ | uint64_t trigger; | ||
} bell_struct; | } bell_struct; | ||
- | //Create a struct_message called myData\\ | + | // Create a struct_message called myData |
bell_struct myData; | bell_struct myData; | ||
- | void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, | + | // |
- | memcpy(& | + | // |
- | Serial.print("Bytes received: | + | //got this watchdog code from Andreas Spiess |
- | Serial.println(len); | + | |
- | Serial.print(" | + | Ticker secondTick; |
- | Serial.println(myData.trigger);\\ | + | volatile int watchdogCount = 0; |
- | if (memcmp(mac, addr, 6) == 0) { // Check if expected Mac Addr\\ | + | |
- | | + | void ISRwatchdog() { |
- | if (myData.trigger == 8562190430) {\\ | + | |
- | Serial.println(" | + | if (watchdogCount> |
- | | + | Serial.println(" |
- | }\\ | + | |
- | }\\ | + | } |
} | } | ||
+ | //END WATCHDOG | ||
- | void setup() { | + | void printRestartReason() { |
+ | esp_reset_reason_t reason = esp_reset_reason(); | ||
+ | Serial.print(" | ||
+ | switch (reason) { | ||
+ | case ESP_RST_POWERON: | ||
+ | case ESP_RST_EXT: | ||
+ | case ESP_RST_SW: Serial.println(" | ||
+ | case ESP_RST_PANIC: | ||
+ | case ESP_RST_INT_WDT: | ||
+ | case ESP_RST_TASK_WDT: | ||
+ | case ESP_RST_WDT: | ||
+ | case ESP_RST_DEEPSLEEP: | ||
+ | case ESP_RST_BROWNOUT: | ||
+ | case ESP_RST_SDIO: | ||
+ | default: Serial.println(" | ||
+ | } | ||
+ | } | ||
- | Serial.begin(115200); | + | void OnDataRecv(const esp_now_recv_info_t *info, const uint8_t *incomingData, |
+ | memcpy(& | ||
+ | | ||
+ | Serial.println(len); | ||
+ | Serial.print(" | ||
+ | Serial.println(myData.trigger); | ||
- | Serial.println(); | + | // Prüfen, ob die MAC-Adresse übereinstimmt |
+ | if (memcmp(info-> | ||
+ | | ||
+ | if (myData.trigger == 8562190430) { | ||
+ | Serial.println(" | ||
+ | triggerbell(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
- | WiFi.mode(WIFI_STA); | + | void setup() { |
+ | Serial.begin(115200); | ||
+ | Serial.println(); | ||
+ | secondTick.attach(1, | ||
+ | printRestartReason(); | ||
- | Serial.print(" | + | WiFi.mode(WIFI_STA); |
- | Serial.println(WiFi.macAddress()); | + | |
+ | Serial.println(WiFi.macAddress()); | ||
- | // ESP32 Board add-on before version < 1.0.5\\ | + | |
- | //esp_wifi_set_mac(ESP_IF_WIFI_STA, & | + | Serial.print(" |
+ | Serial.println(WiFi.macAddress()); | ||
- | // ESP32 Board add-on after version > 1.0.5\\ | + | pinMode(LED_BUILTIN, |
- | esp_wifi_set_mac(WIFI_IF_STA, & | + | |
- | Serial.print("[NEW] ESP32 Board MAC Address: | + | if (selftest == 1) { |
- | Serial.println(WiFi.macAddress()); | + | |
+ | | ||
+ | digitalWrite(4, | ||
+ | delay(100); | ||
+ | digitalWrite(4, | ||
+ | digitalWrite(LED_BUILTIN, | ||
+ | delay(100); | ||
+ | } else { | ||
+ | | ||
+ | } | ||
- | pinMode(LED_BUILTIN, | + | WiFi.mode(WIFI_STA); |
- | pinMode(4, OUTPUT); | + | |
- | digitalWrite(LED_BUILTIN, | + | // ESP-NOW initialisieren |
- | digitalWrite(4, | + | if (esp_now_init() != ESP_OK) { |
- | delay(100);\\ | + | |
- | digitalWrite(4, LOW);\\ | + | |
- | digitalWrite(LED_BUILTIN, | + | } |
- | delay(100); | + | |
- | //Set device as a Wi-Fi Station\\ | + | esp_now_register_recv_cb(OnDataRecv); |
- | WiFi.mode(WIFI_STA); | + | |
- | //Init ESP-NOW\\ | + | lastRebootTime |
- | if (esp_now_init() != ESP_OK) {\\ | + | |
- | Serial.println("Error initializing ESP-NOW" | + | |
- | ESP.restart(); | + | |
} | } | ||
- | // Once ESPNow is successfully Init, we will register for recv CB to\\ | + | void triggerbell() { |
- | // get recv packer info\\ | + | if (!isTriggered || (millis() - lastTriggeredTime> |
- | esp_now_register_recv_cb(OnDataRecv);\\ | + | isTriggered = true; |
+ | lastTriggeredTime = millis(); | ||
+ | digitalWrite(LED_BUILTIN, LOW); | ||
+ | | ||
+ | |||
+ | delay(100); | ||
+ | digitalWrite(4, | ||
+ | digitalWrite(LED_BUILTIN, | ||
+ | Serial.println(" | ||
+ | } | ||
} | } | ||
- | \\ | + | void loop() { |
- | void triggerbell() {\\ | + | |
- | if (!isTriggered || (millis() - lastTriggeredTime > 10000)) {\\ | + | |
- | isTriggered = true;\\ | + | |
- | lastTriggeredTime = millis(); | + | |
- | digitalWrite(LED_BUILTIN, | + | // Reset der `isTriggered`-Variable nach 5 Sekunden |
- | digitalWrite(4, | + | |
- | | + | |
- | digitalWrite(4, LOW);\\ | + | } |
- | | + | |
- | | + | |
- | }\\ | + | |
- | } | + | |
- | void loop() {\\ | + | |
- | // Print out the `isTriggered` variable every second\\ | + | if (millis() - lastRebootTime> REBOOT_INTERVAL) { |
- | if (millis() - lastPrintoutTime | + | Serial.println("Performing periodic reboot..."); |
- | Serial.print("isTriggered: | + | ESP.restart(); |
- | | + | } |
- | | + | |
- | }\\ | + | if (millis() - lastDebugTime> DebugIntervall) { |
- | \\ | + | |
- | // Reset the `isTriggered` variable after 5 seconds\\ | + | |
- | if (millis() - lastTriggeredTime | + | Serial.println(isTriggered); |
- | | + | |
- | }\\ | + | |
- | \\ | + | watchdogCount = 0; |
} | } | ||
+ | |||
+ | </ | ||
sonstiges/tuerklingel.1696017510.txt.gz · Zuletzt geändert: 2023-09-29 21:58 von schuballaa