Autonomous IoT device based on ESP32-C3 that monitors power presence and sends Telegram notifications when power status changes.
Designed for monitoring electrical grid during rolling blackouts in Ukraine. The device runs on a Li-Ion battery (400-500mAh) and automatically notifies when power appears or disappears.
- 🔋 Autonomous operation
- 📱 Telegram notifications: instant messages about power status changes
- 📊 Battery monitoring: displays charge in % and volts
- 🌐 Web interface: configuration through browser
- 📺 OLED display: status display on button press
- ⚙️ Config mode: short press toggles screen for accessing settings
- ⏰ Configurable interval: from 1 to 30 minutes between checks
- 🔄 Factory Reset: reset to factory settings via button on boot
| Component | Description | Notes |
|---|---|---|
| ESP32-C3 SuperMini | Microcontroller | WiFi, deep sleep support |
| TP4056 | Li-ion charging module | Overcharge protection |
| MT3608 | Booster | Boost voltage to 5V |
| Battery | 400mAh - 500mAh Li-Ion | 18650 or pouch cell |
| OLED 128x32 SSD1306 | Display (I2C) | Blue or white |
| 10kΩ resistors | 4 pieces | For voltage divider |
| Diodes (SS34 recommended) | 2 pieces (optional) | Reverse current protection |
| Tactile button | NO (normally open) | For wake-up and config |
| USB charger 5V | For power and charging | 1-2A |
| Switch | For battery disconnect |
TP4056 ↔ Battery:
TP4056 BAT+ → Battery (+)
TP4056 BAT- → Battery (-)
TP4056 ↔ USB charger:
TP4056 IN+ → USB +5V
TP4056 IN- → USB GND
TP4056 ↔ ESP32-C3 (power):
TP4056 OUT+ → [SWITCH] → MT3608 IN+
MT3608 OUT+ → [DIODE] → ESP32 5V (optional protection, SS34 recommended)
TP4056 OUT- → MT3608 IN- → ESP32 GND
Note: Diode protects ESP32 from reverse current if multiple power
sources are connected. Schottky diode (SS34) recommended for lower
voltage drop, but any diode works.
Voltage Divider #1 (power detector):
TP4056 IN+ ──[10kΩ]──┬──[10kΩ]── TP4056 IN- (GND)
│
GPIO2
Voltage Divider #2 (battery monitor):
TP4056 BAT+ ──[10kΩ]──┬──[10kΩ]── TP4056 BAT- (GND)
│
GPIO3
Button:
GPIO4 ──[BUTTON]── GND
(uses internal pull-up)
OLED display:
OLED VCC → ESP32 3.3V
OLED GND → ESP32 GND
OLED SDA → ESP32 GPIO8
OLED SCL → ESP32 GPIO9
Component Quality:
- Only a small percentage of ESP32-C3 boards work reliably
- Test WiFi functionality before final assembly
- Use quality resistors (1% tolerance recommended)
Power Protection:
- Diode prevents reverse current damage (Schottky recommended)
- Essential if using multiple power sources
- Install between MT3608 OUT+ and ESP32 5V
- Any diode works, but Schottky has lower voltage drop
Battery Notes:
- Lookup table calibration provides ±3-5% accuracy
- Works with any Li-Ion chemistry (18650, pouch cell, etc.)
- Capacity doesn't affect percentage calculation
- Only voltage curve matters
- Message @BotFather in Telegram
- Send
/newbot - Choose name and username
- Save Bot Token (format:
123456:ABC-DEF1234ghIkl...)
Option 1 (simple):
- Send
/startto your bot - Open in browser:
https://api.telegram.org/bot<TOKEN>/getUpdates - Find
"chat":{"id":123456789}- this is your Chat ID
Option 2 (via bot):
- Message @userinfobot
- It will show your Chat ID
- Upload firmware to ESP32-C3
- Device will create WiFi network:
PowerMon(password shown on OLED display) - Connect to this network from your phone
- Web form will open automatically or go to
192.168.4.1 - Enter data:
- WiFi SSID and password
- Telegram Bot Token and Chat ID
- Device name (e.g., "Lviv")
- Check interval (recommended 5 minutes)
- Press SAVE
- Device will reboot and connect to WiFi
- On successful setup you'll receive a Telegram message
Hold button while powering on the device - instructions will appear on screen.
After Factory Reset device will create WiFi network PowerMon (password shown on display) for new configuration.
On device startup:
🔄 Device started!
📡 IP: 192.168.1.100
⏰ UP: 15 secs
⚡ Power: ON
On power status change:
⚡ POWER: ON (5.00V)
🔋 BTR: 87% (3.85V)
⏰ UP: 2 h 15 min(s) 30 secs
📡 IP: 192.168.1.100
If voltage or percentage shows incorrectly:
- Measure real battery voltage with multimeter (e.g., 3.99V)
- Check ADC raw in Serial Monitor (e.g., 2760)
- Calculate coefficient:
3.99 / 2760 = 0.001446 - Update constant
BATTERY_CALIBRATIONin code
- WITHOUT charger measure IN+/IN- → check ADC raw (e.g., 2287)
- WITH charger measure IN+/IN- → check ADC raw (e.g., 3976)
- Threshold should be in middle:
(2287 + 3976) / 2 ≈ 3100 - Update constant
POWER_THRESHOLDin code
- Connect USB charger (5V)
- Check Serial Monitor:
Power ADC raw: 3976 -> 9.94V ← INCORRECT!
- Measure REAL voltage with multimeter on TP4056 IN+ (should be ≈5V)
- Calculate calibration:
POWER_CALIBRATION = real_voltage / rawValue
Example: 5.0V / 3976 = 0.001258
Device won't connect to WiFi:
- Check SSID and password in settings
- Make sure WiFi is 2.4GHz (ESP32 doesn't support 5GHz)
- MT3608 boost converter creates electromagnetic interference. Try moving MT3608 or ESP32 further away
Telegram messages not arriving:
- Check Bot Token and Chat ID
- Use TEST TELEGRAM button in web interface
- Make sure device is connected to internet
Incorrect voltage or percentage:
- Perform calibration (see section above)
Install via Arduino IDE Library Manager:
- Adafruit SSD1306 - for OLED display
- Adafruit GFX Library - graphics library
- UniversalTelegramBot by Brian Lough - for Telegram
- ArduinoJson (v6) - for JSON processing
- ESP32 board support - from Espressif
MIT License - free to use, modify and distribute.