pridana kontrola zmien hladiny a odosielanie notifikacie na Telegram

This commit is contained in:
2026-06-24 11:09:05 +02:00
parent a7bb99bf00
commit bcf0baf71c
3 changed files with 151 additions and 5 deletions

View File

@ -6,6 +6,7 @@ This repository contains a small ESP8266/ESP32 Arduino project for monitoring wa
- `arduino/arduino.ino` contains the Arduino sketch and main application logic.
- `server/log.php` accepts measurement POST requests and appends them as JSON Lines.
- `server/functions.inc.php` contains shared PHP helpers, including JSON responses, HTTP requests, and Telegram notifications.
- `data/YYYY.jsonl` is created at runtime for logged measurements and should not be treated as source code.
- `README.md` gives the high-level project purpose.
- `LICENSE` contains licensing information.
@ -29,12 +30,13 @@ arduino-cli upload -p COM3 --fqbn esp32:esp32:esp32 arduino
arduino-cli monitor -p COM3 -c baudrate=115200
php -l server/log.php
php -l server/functions.inc.php
```
- `compile` verifies the sketch builds for the selected board.
- `upload` flashes the firmware to the connected board.
- `monitor` opens the serial console used by debug output.
- `php -l` checks the PHP logging endpoint for syntax errors.
- `php -l` checks the PHP scripts for syntax errors.
Adjust `--fqbn` and `COM3` for the actual board and port.
@ -50,6 +52,8 @@ Prefer small functions with one responsibility. Keep hardware pins, URLs, timing
For PHP scripts, keep them framework-free unless the project grows. Return JSON responses, use explicit HTTP status codes, and keep generated log files under `data/`.
Keep shared PHP helpers in `server/functions.inc.php`. Use the existing `telegram()` helper for Telegram notifications, and wrap notification calls so delivery failures do not change the HTTP response or stop measurement logging.
## Hardware Notes
For ESP8266 conductive level sensing, use external pull-down resistors from each `PIN_LEVEL1..4` input to `GND`. The common electrode is driven to positive voltage only during measurement.
@ -70,9 +74,12 @@ Before committing firmware changes:
Before committing server changes:
- Run `php -l server/log.php`.
- Run `php -l server/functions.inc.php` when shared helpers change.
- Test that non-POST requests return HTTP 405 with `Allow: POST`.
- Test a form POST such as `level1=1&level2=0&level3=0&level4=1`.
- Verify that a single compact JSON object is appended to `data/YYYY.jsonl`.
- For notification changes, verify that Telegram messages are sent only when `level1..level4` differ from the previous saved measurement.
- Verify invalid level combinations such as `0100`, `1010`, and `1101` produce the measurement error notification without causing an HTTP error.
## Commit & Pull Request Guidelines