diff --git a/README.md b/README.md index 9a2dafb..7c9aa4f 100644 --- a/README.md +++ b/README.md @@ -1,129 +1,42 @@ -# Smart Mirror · Arduino USB Monitor v3 +# "SmartMirror" - Projektwochen am TGBBZ Dillingen -## Projektstruktur +## Repo-Strktur ``` -usb_monitor_v3/ -├── settings.json ← zentrale Konfiguration -├── USBRead.py ← serielle Leseschicht + Parser -├── Notification.py ← SMTP- + WhatsApp-Alerting -├── Dashboard.py ← Flask App Factory -├── gunicorn.conf.py ← Gunicorn-Konfiguration -├── requirements.txt -├── templates/ -│ ├── base.html ← Jinja2 Basis-Layout -│ └── dashboard.html ← Smart-Mirror-Dashboard -└── static/ - ├── css/ - │ └── mirror.css ← Smart-Mirror-Stylesheet - └── js/ - └── dashboard.js ← Polling, Chart, Uhr, Sensor-Tiles +arduino/ + arduino/arduino.ino + Arduino-Skript, um die Sensordaten auszulesen und sie per USB + an den Raspberry Pi zu übertragen +raspi/ + raspi/templates + Jinja basierte HTML-Templates + raspi/static + Ordner mit frontend (CSS, JS) Dateien + raspi/Dashboard.py + Stellt das Flask-basierte Web-Dashboard bereit + raspi/USBRead.py + Liest in regelmäßigen Intervallen die USB-Gerätedatei (/dev/ttyACM0) aus + und stellt die Daten Dashboard.py und Notification.py bereit + raspi/Notification.py + Dient als SMTP-Client, der Benachrichtigungen über E-Mail und Messanger + versendet# + raspi/gunicorn.conf.py + Startup-Datei für den WSGI-Webserver Gunicorn, der das Flask Web-Dashboard + bereitstellt + raspi/requirements.txt + requirements.txt für pip (lieste der benötigten Python-Abhängigkeiten) + raspi/settings.json + Zentrale Konfigurationsdatei zur Konfiguration der Raspi-Skripte + raspi/README.md + +docs/ + aufbau.png + Übersicht über den logischen Aufbau des Setups + verkabelung.txt + Übersicht über die phyische Verkabelung + ``` ---- +## Logischer Aufbau -## Installation - -```bash -pip install -r requirements.txt - -# Nur bei whatsapp.provider = "twilio": -pip install twilio -``` - ---- - -## Starten - -```bash -# Gunicorn (Produktion, Port 80 → sudo nötig) -sudo gunicorn -c gunicorn.conf.py "Dashboard:create_app()" - -# Ohne Root (Port in settings.json auf z.B. 8080 setzen) -gunicorn -c gunicorn.conf.py "Dashboard:create_app()" - -# Flask direkt (Entwicklung) -python Dashboard.py -``` - ---- - -## settings.json — Referenz - -### `usb` -| Schlüssel | Beschreibung | -|----------------------|--------------------------------------------------| -| `port` | Gerätepfad, z.B. `/dev/ttyACM0` | -| `baud_rate` | Baudrate | -| `reconnect_delay_s` | Sekunden bis Reconnect-Versuch | -| `buffer_size` | Maximale Einträge im Ring-Buffer | - -### `dashboard` -| Schlüssel | Beschreibung | -|----------------------|--------------------------------------------------| -| `host` | Bind-Adresse (`0.0.0.0` = alle Interfaces) | -| `port` | HTTP-Port | -| `poll_interval_ms` | Browser-Polling-Intervall in ms | -| `title` | Titel im Header und Browser-Tab | - -### `smtp` -| Schlüssel | Beschreibung | -|----------------------|--------------------------------------------------| -| `enabled` | `true` / `false` — Kanal an/aus | -| `host` | SMTP-Hostname | -| `port` | SMTP-Port (587 STARTTLS, 465 SSL) | -| `use_tls` | `true` → STARTTLS, `false` → direktes SSL | -| `username` | Login | -| `password` | Passwort | -| `from_address` | Absender | -| `to_addresses` | Empfänger-Array | -| `cooldown_s` | Mindestabstand zwischen Alerts (pro Sensor) | - -### `whatsapp` -| Schlüssel | Beschreibung | -|----------------------|--------------------------------------------------| -| `enabled` | `true` / `false` | -| `provider` | `"twilio"` oder `"callmebot"` | -| `cooldown_s` | Mindestabstand WhatsApp-Alerts (pro Sensor) | - -**Twilio** (`whatsapp.twilio`): -- Account SID + Auth Token aus der Twilio Console -- `from_number`: `"whatsapp:+14155238886"` (Sandbox) oder eigene Nummer -- `to_numbers`: Array mit `"whatsapp:+49..."` -- Einmalige Sandbox-Aktivierung: https://www.twilio.com/console/sms/whatsapp/sandbox - -**CallMeBot** (`whatsapp.callmebot`) — kostenlos, kein Account: -- API-Key einmalig aktivieren: https://www.callmebot.com/blog/free-api-whatsapp-messages/ -- `to_numbers`: Array mit Rufnummern im Format `"+49151..."` - -### `sensors` -Jeder Eintrag im Array beschreibt einen Messkanal: - -| Schlüssel | Beschreibung | -|--------------------|-------------------------------------------------------| -| `name` | Anzeigename | -| `field_index` | Index im `values`-Array (0-basiert) | -| `unit` | Einheit (Anzeige), z.B. `"°C"` | -| `threshold_high` | Oberer Grenzwert (`null` = kein) | -| `threshold_low` | Unterer Grenzwert (`null` = kein) | -| `notify_on_high` | E-Mail + WA senden bei Überschreitung | -| `notify_on_low` | E-Mail + WA senden bei Unterschreitung | - ---- - -## Arduino-Ausgabeformate (automatisch erkannt) - -| Format | Beispiel | -|--------------|--------------------------------| -| Numerisch | `23.5 67.1 4.92` | -| Key=Value | `temp=23.5,hum=67.1,volt=4.92` | -| JSON | `{"temp":23.5,"hum":67.1}` | - ---- - -## Smart Mirror Betrieb - -Für den Einsatz als Smart Mirror empfiehlt sich: -- Chromium im Kiosk-Modus: `chromium-browser --kiosk http://localhost` -- Bildschirm-Timeout deaktivieren: `xset s off && xset -dpms` -- Autostart via `/etc/rc.local` oder systemd (siehe README v2) +!(logischer-aufbau)[] diff --git a/Logischer Aufbau - SmartMirror (Lucidchart).png b/docs/aufbau.png similarity index 100% rename from Logischer Aufbau - SmartMirror (Lucidchart).png rename to docs/aufbau.png diff --git a/verkabelung.txt b/docs/verkabelung.txt similarity index 100% rename from verkabelung.txt rename to docs/verkabelung.txt