Smart Battery Monitor (ESP8266) with OLED, REST API & Blynk IoT
ESP8266 Blynk IoT OLED (SSD1306) DS3231 RTC EEPROM REST API
A menu-driven smart battery monitoring system built on ESP8266, featuring a 0.96" OLED, DS3231 RTC with NTP sync, and persistent settings in AT24C32 EEPROM. It measures voltage, current, power, and state of charge (SOC) using sensors like INA219, WCS1600, and ADS1115, exposes a RESTful API for custom integrations, and connects to the Blynk IoT platform (mobile + web dashboards) for remote monitoring and control.
View Source on GitHub
Table of Contents
Required Components
- ESP8266 (NodeMCU)
- INA219 – voltage & current sensor
- ADS1115 (ADS1X15) – external ADC
- WCS1600 – current sensor – Watch how it works
- DS3231 RTC + AT24C32 EEPROM
- 0.96″ OLED (SSD1306, I²C)
- Push buttons for navigation
- 1X 470uf capacitor
- Screw Terminals
- Jumper wires, breadboard/PCB, power module
Circuit & Wiring



- I²C: SDA/SCL → OLED, DS3231, ADS1115
- INA219 & WCS1600 routed to ADC inputs (as per your design)
- Buttons to digital GPIOs (e.g., D5/D6/D7) for Up/Down/Select/Back
- Stable power supply and proper grounding recommended
View the wiring PDF below or download it in the Downloadables section.
Copper Clad PCB Circuit


Installation & Libraries
- Clone the repo: git clone https://github.com/akshit-singhh/Smart-Battery-Monitor-ESP8266-V1.0
- Open BatteryMonitor.ino in Arduino IDE.
- Select board: NodeMCU 1.0 (ESP-12E Module).
- Install the following libraries (Library/Boards Manager):
- ESP8266 Core for Arduino (Boards Manager)
- ArduinoJson (BenoƮt Blanchon)
- RTClib (Adafruit)
- Adafruit INA219
- Adafruit SSD1306 (auto-installs Adafruit GFX)
- Adafruit ADS1X15 (ADS1115/ADS1015)
- QRCode (e.g., ricmoo/QRCode)
Built-ins used: Wire (I²C), ESP/ESP8266WiFi/ESP8266WebServer/ESP8266HTTPClient, stdio, Arduino core.
Menu-Based OLED Interface
The on-device UI is a full, navigable menu with timeouts and status screens:
- Live Data: Voltage, Current, Power, SOC, WiFi RSSI, IP, Uptime
- Configuration: Battery Settings (capacity, thresholds, type), Screen Timeout, Reset SOC
- Calibration: Current & Voltage calibration, auto-zero/manual offsets, Save/Load to EEPROM
- Statistics: Cycle count, Total Energy (Wh), Runtime history
- System Info: Firmware version, Sensor status, Memory, Uptime
- GitHub: QR code linking to the repository
- AP Mode: Start/Stop AP, AP details + QR to setup page




REST API Endpoints
You can verify and interact with these API endpoints directly from your web browser or using tools like Postman. Below are some examples based on the local IP http://192.168.1.99
. Note: The IP address of your device may vary depending on your network configuration. Please check your device’s current IP address before testing the endpoints.
- Using a web browser: Simply enter the endpoint URL in the browser’s address bar (works best with GET requests). For example, open http://192.168.1.99/live_data to see the real-time JSON data.
- Using Postman:
- Open Postman and create a new request.
- Set the request method (GET, POST, etc.) based on the API endpoint.
- Enter the full URL (e.g.,
http://192.168.1.99/settings
). - If needed, add headers or body data (e.g., for POST requests).
- Click Send to view the response.
Endpoint | Description |
---|---|
/live_data |
Real-time JSON: voltage, current, power, SOC, WiFi mode, RSSI, IP Example: http://192.168.1.99/live_data |
/serial_log |
Rolling log buffer with uptime + RTC timestamps Example: http://192.168.1.99/serial_log |
/settings (GET) |
Read calibration + SOC Example: http://192.168.1.99/settings |
/settings (POST) |
Update and persist settings (EEPROM) Use Postman or similar tool to send POST request with JSON body. |
/wifi_config |
Provision WiFi via JSON or HTML Example: http://192.168.1.99/wifi_config |
/sta_ip |
Return STA IP or NOT_CONNECTED |
/reboot |
Reboot device |
Sample Response: /live_data
{
"voltage": 12.34,
"current": 1.23,
"soc": 87.5,
"power": 15.18,
"status": "Charging|Discharging|Idle",
"rssi": -60,
"mode": "AP|STA|AP_STA|NONE",
"ip": "192.168.4.1"
}
Blynk IoT Integration
- Mobile + Web dashboards with live telemetry and controls.
- Template + Datastreams mapping to device variables (SOC, V, A, W, alarms).
- Automations/Notifications for thresholds (e.g., low SOC, overcurrent).

Blynk Datastream Configuration
In the Blynk Web Dashboard or Mobile App, set up the following Datastreams to match your firmware variables. These use virtual pins V0
through V9
.
# | Label | Virtual Pin | Type | Units | Min | Max | Format |
---|---|---|---|---|---|---|---|
1 | Voltage | V0 | Double | V | 0 | 20 | #.## |
2 | Current | V1 | Double | A | -100 | 20 | #.## |
3 | Power | V2 | Double | - | -100 | 600 | #.## |
4 | State of Charge | V3 | Double | % | 0 | 100 | #.## |
5 | Battery Status | V4 | String | - | - | - | - |
6 | Energy In | V5 | Double | Wh | 0 | 1000 | #.## |
7 | Energy Out | V6 | Double | Wh | 0 | 1000 | #.## |
8 | Uptime | V7 | String | - | - | - | - |
9 | Backup Time | V8 | String | - | - | - | - |
10 | Charging Time | V9 | String | - | - | - | - |
Note: Ensure each datastream is correctly mapped to its corresponding virtual pin in the Blynk Template. These pins should be updated in your firmware using Blynk.virtualWrite(Vx, value)
.
Important: Before deploying the Blynk dashboard, double-check that your Blynk.virtualWrite(Vx, value)
calls in the firmware match the configured datastreams above. Also verify all sensor connections and GPIO mappings (e.g., for current sensors, buttons, and I²C devices) in your wiring and code. Incorrect pin assignments or loose connections may result in invalid or missing telemetry.