documentation
This commit is contained in:
@@ -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;
|
||||
@@ -28,6 +28,8 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
|
||||
btStop(); // turn off bluetooth
|
||||
|
||||
Serial.println("Connect dfplayer");
|
||||
Serial1.begin(9600, SERIAL_8N1, 18, 19); // speed, type, TX, RX
|
||||
dfPlayer.begin(Serial1);
|
||||
@@ -65,13 +67,6 @@ void loop() {
|
||||
WiFiClient client = server.available(); // Listen for incoming clients
|
||||
|
||||
if (client) {
|
||||
|
||||
// get player status
|
||||
String playerStatus = "<i>not available</i>";
|
||||
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("<!DOCTYPE html><html>");
|
||||
@@ -142,11 +141,6 @@ void loop() {
|
||||
client.println("<body><h1>Doorbell</h1>");
|
||||
client.println("<p>Volume: <a href=\"/setvolume/" + String(volume-1) + "\"><button class=\"button2\">−</button></a> " + String(volume) + " <a href=\"/setvolume/" + String(volume+1) + "\"><button class=\"button2\">+</button></a></p>");
|
||||
client.println("<p><a href=\"/bell/on\"><button class=\"button\">Ring</button></a></p>");
|
||||
|
||||
client.println("<p style='font-size:80%'>Status dfplayer: ");
|
||||
client.println(playerStatus);
|
||||
client.println("</p>");
|
||||
|
||||
client.println("</body></html>");
|
||||
|
||||
// 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";
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user