ESP32 firmware for a Telegram-connected doorbell with door release control.
- Instant Telegram alerts when the button is pressed.
- Optional inline Telegram button to trigger door release.
- Working-hours policy for both notifications and release authorization.
- Offline press logging with replay/summary when back online.
- Input debounce and anti-spam cooldown controls.
main: Full feature set (doorbell notifications + door unlock flow).notification-only: Doorbell notification mode only, no door unlock feature.
If you only want doorbell notifications without door unlock, use the notification-only branch.
- ESP32 board supported by PlatformIO (project tested on
esp32doit-devkit-v1). - Momentary doorbell button wired to the configured GPIO.
- Relay module (only if using door unlock).
- VS Code + PlatformIO extension.
- Telegram bot token and chat ID.
- Clone the repository and open it in VS Code.
- Configure Telegram by following
docs/telegram-bot-setup.md. - Create
include/credentials.hfrominclude/credentials.example.h. - Create
include/working_hours.hfrominclude/working_hours.example.h. - Review
include/config.hfor pin mapping and cooldown settings. - Build and upload with PlatformIO.
include/credentials.h is gitignored and should never be committed.
pio run
pio run -t upload
pio device monitor -b 115200include/config.hBTN_PIN: doorbell input pin.DEBOUNCE_MS: button debounce time.BTN_EVENT_COOLDOWN_MS: minimum accepted press interval.PRESS_NOTIFY_COOLDOWN_MS: anti-spam window for notifications.RELAY_PIN,RELAY_ACTIVE_LOW,RELAY_PULSE_MS: unlock relay behavior.
include/working_hours.hWORK_TZ: timezone.WORK_HOURS: allowed time windows.WORK_ALLOW_BEFORE_SYNC,WORK_VALID_EPOCH: policy before valid NTP time.
- Boots, connects Wi-Fi, syncs time, mounts local storage, and starts schedule services.
- Sends online/offline status around working-hours transitions.
- During working hours:
- Button press sends Telegram alert.
- Door release callback is accepted.
- Outside working hours:
- Presses are queued.
- Door release is rejected.
esp32_doorbell/
docs/
telegram-bot-setup.md
include/
config.h
credentials.example.h
credentials.h
working_hours.example.h
working_hours.h
work_hours_types.h
lib/
src/
main.cpp
app/
App.cpp, App.h
BusinessHours.cpp, BusinessHours.h
Button.cpp, Button.h
Net.cpp, Net.h
Notifier.cpp, Notifier.h
OfflineLog.cpp, OfflineLog.h
Relay.cpp, Relay.h
Scheduler.cpp, Scheduler.h
TimeSvc.cpp, TimeSvc.h
platformio.ini
README.md
- TLS currently uses
setInsecure()for Telegram requests. - For production deployments, use proper certificate validation.
- Rotate bot token immediately if exposure is suspected.