diff --git a/doorbell4-esp32/doorbell4-esp32.ino b/doorbell4-esp32/doorbell4-esp32.ino index e825f6a..e37f0c5 100644 --- a/doorbell4-esp32/doorbell4-esp32.ino +++ b/doorbell4-esp32/doorbell4-esp32.ino @@ -1,5 +1,5 @@ /** - * WiFi Doorbell for ESP32 + * WiFi Doorbell for ESP32 with dfplayer * by Tilman Liero * www.tilman.de **/ @@ -12,8 +12,8 @@ DFRobotDFPlayerMini dfPlayer; int volume = 22; -const char* ssid = "Pixel 4a TL"; -const char* password = "20170618sn"; +const char* ssid = "SSID"; +const char* password = "PASSWORD"; WiFiServer server(80); String header; @@ -27,6 +27,8 @@ void setup() // start serial output Serial.begin(115200); Serial.println(); + + btStop(); // turn off bluetooth Serial.println("Connect dfplayer"); Serial1.begin(9600, SERIAL_8N1, 18, 19); // speed, type, TX, RX @@ -63,15 +65,8 @@ void setup() void loop() { WiFiClient client = server.available(); // Listen for incoming clients - + if (client) { - - // get player status - String playerStatus = "not available"; - if (dfPlayer.available()) { - playerStatus = getPlayerStatus(dfPlayer.readType(), dfPlayer.read()); - } - String currentLine = ""; // make a String to hold incoming data from the client while (client.connected()) { // loop while the client's connected if (client.available()) { // if there's bytes to read from the client, @@ -125,10 +120,14 @@ void loop() { Serial.print("Volume set to "); Serial.println(volume); } - if (header.indexOf("GET /restart") >= 0) { + else if (header.indexOf("GET /restart") >= 0) { Serial.println("Restarting..."); ESP.restart(); } + else if (header.indexOf("GET /dfreset") >= 0) { + Serial.println("Reset dfplayer..."); + dfPlayer.reset(); + } // Display the HTML web page client.println(""); @@ -142,11 +141,6 @@ void loop() { client.println("

Doorbell

"); client.println("

Volume: " + String(volume) + "

"); client.println("

"); - - client.println("

Status dfplayer: "); - client.println(playerStatus); - client.println("

"); - client.println(""); // The HTTP response ends with another blank line @@ -194,38 +188,3 @@ void loop() { Serial.println(""); } } - -String getPlayerStatus(uint8_t type, int value) { - switch (type) { - case TimeOut: - return "Time Out!"; - case WrongStack: - return "Stack Wrong!"; - case DFPlayerCardInserted: - return "Card Inserted!"; - case DFPlayerCardRemoved: - return "Card Removed!"; - case DFPlayerCardOnline: - return "Card Online!"; - case DFPlayerPlayFinished: - return "Play Finished!"; - case DFPlayerError: - switch (value) { - case Busy: - return "Error: Card not found"; - case Sleeping: - return "Error: Sleeping"; - case SerialWrongStack: - return "Error: Get Wrong Stack"; - case CheckSumNotMatch: - return "Error: Check Sum Not Match"; - case FileIndexOut: - return "Error: File Index Out of Bound"; - case FileMismatch: - return "Error: Cannot Find File"; - case Advertise: - return "Error: In Advertise"; - } - } - return "unknown"; -} diff --git a/pro_micro_timed-key/pro_micro_timed-key.ino b/pro_micro_timed-key/pro_micro_timed-key.ino index e17f59d..5b44a04 100644 --- a/pro_micro_timed-key/pro_micro_timed-key.ino +++ b/pro_micro_timed-key/pro_micro_timed-key.ino @@ -1,8 +1,14 @@ // Presses a key every once in a while on Arduino Leonardo / Pro Micro (ATMega32U4) +/* + * Anmerkung: Der Pro Micro wurde beim Anstecken von Ubuntu nicht wahrgenommen. Nachdem ein bereits + * programmierter Pro Micro angesteckt war, wurde auch der neue korrekt identifiziert. + * Falls das nicht hilft, könnte der Reset-Ansatz helfen: https://forum.arduino.cc/t/pro-micro-not-showing-up-in-com-port/882257/4 + */ + #include "Keyboard.h" -const unsigned long waitTime = 300000; // 5 minutes +const unsigned long waitTime = 299000; // <5 minutes const int buttonPin = 2; void setup() { @@ -19,7 +25,7 @@ void loop() { Serial.println("click"); // press key - Keyboard.press(129); // https://www.arduino.cc/reference/en/language/functions/usb/keyboard/keyboardmodifiers/ + Keyboard.press(129); // Left Shift - https://www.arduino.cc/reference/en/language/functions/usb/keyboard/keyboardmodifiers/ delay(2); Keyboard.release(129); }