ESP32-based smart lock firmware that exposes a small HTTP JSON API over the local network. Built with PlatformIO and the Arduino framework.
- Board: ESP32 DOIT DevKit V1
- Lock pin: GPIO 25 (drives relay / solenoid —
HIGH= locked,LOW= unlocked) - Buzzer pin: GPIO 26 (feedback beeps)
- HTTP JSON API on port
1212(default recommended) - Token-based authentication (token sent in request body)
- Wi-Fi Station mode (connects to an existing network)
- Automatic fallback to Access Point mode if STA connection fails within 15 s
- Audible beep feedback on lock/unlock
- PlatformIO (CLI or VS Code extension)
- An ESP32 DOIT DevKit V1 (or compatible)
Edit the constants at the top of src/main.cpp before flashing:
const char* WIFI_SSID = "<your-wifi-ssid>";
const char* WIFI_PASSWORD = "<your-wifi-password>";
const char* AP_SSID = "<your-ssid>";
const char* AP_PASSWORD = "<ap-password>";
const char* AUTH_TOKEN = "<your-secret-token>";pio run # build
pio run -t upload # flash
pio device monitor # serial monitor @ 115200The device prints its IP to the serial monitor after connecting:
STA IP: 192.168.1.23
Full frontend integration guide is in docs/implementation.md.
Quick reference:
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | / |
no | Device info / ping |
| POST | /lock |
yes | Lock the device |
| POST | /unlock |
yes | Unlock the device |
| POST | /status |
yes | Get current state |
Authenticated requests send the token in the JSON body:
{ "token": "your-secret-token" }.
├── docs/ # integration docs
├── include/ # project headers
├── lib/ # private libraries
├── src/main.cpp # firmware entry point
├── test/ # unit tests
└── platformio.ini # PlatformIO config
- Traffic is plain HTTP — only use on trusted Wi-Fi networks.
- The auth token is hard-coded in firmware. Change it before deploying and do not commit production tokens.
- There is no rate limiting in firmware — the client should debounce lock/unlock actions.