A smart meter reader for the ESP32 that collects meter data and provides a web interface for configuration and monitoring. The device reads SML (Smart Meter Language) data and can push readings to a remote API.
This project implements a firmware for the ESP32-C3 Super Mini microcontroller that:
- Reads Smart Meter Data: Captures SML-formatted meter readings via serial connection
- Web Interface: Provides a responsive HTML-based dashboard for real-time monitoring
- WiFi Configuration: Easy WiFi setup through a captive portal (Access Point mode)
- Push API: Automatically uploads meter readings to a remote API endpoint
- System Monitoring: Includes watchdog timer, heartbeat monitoring, and system health checks
- Board: ESP32-C3 Super Mini (or compatible ESP32-C3 board)
- Smart Meter: Smart meter with SML protocol
- Optical Reader: Optical reading head to interface with the smart meter
- Power Supply: 5V USB or battery
This project is built with:
- Visual Studio Code - Code editor
- PlatformIO - Embedded systems build system and IDE
- Arduino Framework - Hardware abstraction layer
-
Install VS Code and PlatformIO:
- Download Visual Studio Code
- Install the PlatformIO extension from the marketplace
-
Clone/Open this repository in VS Code
-
Connect your ESP32-C3:
- Plug the board into your computer via USB-C
-
Build and Upload:
# Build the firmware platformio run # Upload to device platformio run --target upload
- Power on the device - it will start in Access Point mode if not configured
- Connect to WiFi: Look for SSID
ESP32-SmartMeter - Open Web Interface: Navigate to
http://192.168.10.1in your browser - Enter WiFi Credentials:
- Select your WiFi network from the list
- Enter your WiFi password
- Click "Save"
- Device Connects: The ESP32 will connect to your network
Once connected, you can access the interface at the device's local IP address.
To enable automatic data uploads:
- Access Settings Page: Connect to the web interface and go to Settings
- API Configuration:
- Host: Enter the server host (e.g.,
http://api.example.com) - Smartmeter Endpoint: Enter the endpoint for uploading smart-meter data (e.g.
/upload/smartmeter.php - System Endpoint: Enter the endpoint for uploading system data (e.g.
/upload/system.php
- Host: Enter the server host (e.g.,
- Save Settings: Click "Save" to apply
- Data Upload: The device will now automatically push meter readings at configured intervals
The device sends JSON-formatted meter data to the specified endpoint.
The web interface provides:
- Overview Tab: Real-time meter readings and system status (
/overview) - Settings Tab: WiFi, API, and system configuration (
/settings) - Status Indicators: Connection status, uptime, and signal strength
To reset all stored settings, press and hold the BOOT button for at least 3 seconds. The ESP32 will automatically reboot and return to Access Point mode for reconfiguration.
The project uses the following libraries:
| Library | Version | Purpose |
|---|---|---|
| WiFiManager | 2.0.17+ | WiFi configuration and captive portal |
| SML Parser | 0.29+ | Smart Meter Language protocol parsing |
| ArduinoJson | 7.4.3+ | JSON serialization/deserialization |
- ESP32 Arduino Framework - Core Arduino functionality for ESP32
- PlatformIO - Build system and dependency management
- Watchdog Timer: Automatic recovery from hangs (5-second timeout)
- Heartbeat LED: Visual feedback (pin 6)
- Reset Button: Long press for factory reset (pin BOOT)
- System Health: Continuous monitoring of uptime and resource usage
- Data Collection: Configurable meter reading intervals (default 1 minute)
The HTML interface files (overview.html, settings.html) were created with the assistance of GitHub Copilot. While they have been tested and verified to work correctly, they are generated code and should be reviewed for your specific security and styling requirements if necessary.
src/
├── main.cpp # Main firmware entry point
├── datacollector.cpp # Meter data collection and storage
├── smlreader.cpp # SML protocol parsing
├── iec62056.cpp # Unused (IEC62056 protocol for older meters)
├── networking.cpp # WiFi connectivity and NTP updates
├── reset.cpp # Factory reset handling
├── system.cpp # System health and uptime tracking
├── components/ # Core system components
│ ├── watchdog.cpp # Watchdog timer
│ ├── heartbeat.cpp # Status LED heartbeat
│ ├── timer.cpp # General timers
│ └── datetime.cpp # Unused (simple DateTime implementation)
├── config/ # Configuration management
│ ├── config_network.cpp # Network settings
│ ├── config_pushapi.cpp # Push API configuration
│ └── config_system.cpp # System settings
└── web/ # Web interface
├── httpserver.cpp # Web server
├── httpclient.cpp # API client
└── server/html/ # HTML interface files
This project is licensed under the MIT License. See the LICENSE file for details.
For issues, questions, or contributions, please open an issue on the repository.