A Firmware-Project for Espressif microcontrollers (such as ESP32, ESP32S3, ESP32H2 ...) that reads Powermeter registers and publishes the data to MQTT, while also providing a Webserver interface for real-time-monitoring and logging.
It works with almost all Eastron SDM-Powermeter-Device (integrated) and it is configured for the Eastron SDM630. Only small adjustments needed, to work with a different type, or Modbus-Powermeters from other vendors.
This is purely based on ESP-IDF (Espressif IoT Development Framework), it is NOT an Arduino-Project.
- Continuously reads Powermeter's values via Modbus RTU.
- Distinguish between priority and normal values. Priority-values are read more often.
- Publishes read values to an MQTT broker for integration with IoT platforms.
- Only publishes values to MQTT if they have changed significantly (per-register threshold configurable).
- Embedded async Webserver (on ESP) for real-time monitoring.
- WebSerial interface to view live logs in the browser.
- LAN connection via either with Ethernet or WiFi.
- Synchronize local time using an NTP Server, allowing data to be timestamped.
- Supports Over-The-Air (OTA) updates, eliminating the need for USB access.
- Devices can be reached by Hostname or IP (can be fixed IP).
- HTML-Pages are stored in LittleFS (File-System) for easy updates and editing.
- Consists of 7 reusable components plus a main application.
- Almost all components include
menuconfigconfiguration options and are designed for reused in other projects.
-
Microcontroller Board with any chip of the ESP32-Family.
- Recommended:
Chips with JTAG integrated like ESP32S2, ESP32S3 or ESP32H2 for easy debugging via USB.
Search for 'JTAG' in technical datasheet of the chip, ESP32S3-Datasheet-Example.
- Recommended:
-
Powermeter with a Modbus-Interface.
-
UART(Serial)-to-MOBUS(RS485)-Adapter.
- Recommended:
With galvanic isolation of MCU from MODBUS.
- Recommended:
-
Optional: Ethernet-Shield (e.g. with W5500-Chip), for to LAN connection via Ethernet.
- For compile and flashing: ESP-IDF-Tools.
Recommended:
- ESP-IDF-Extension in Visual Studio Code as IDE, which includes all required tools and project configuration UI.
-
Clone this repository:
git clone https://github.com/twischi/Powermeter-values-to-MQTT-and-Websever.git cd Powermeter-values-to-MQTT-and-Websever -
Configure the project:
idf.py menuconfig
- Set Wi-Fi credentials, MQTT broker address, and power meter parameters.
-
Build and flash:
idf.py build idf.py -p <PORT> flash
-
Monitor output:
idf.py monitor
Located in the 'components/'directory and used by the main application:
See the list of components: COMPONENTS.md
| Script-Name | Script-Type | Purpose |
|---|---|---|
ota_update/install_py_requirements.sh |
Shell | Installs Python modules needed for ota_server-one-shot.py |
ota_server-one-shot.py |
Python | Serves the OTA file over local network using Zeroconf; shuts down after delivery. |
provide_ota_update.sh |
Shell | Just for convenience, to start ota_server-one-shot.py |
toggle_project_config.sh |
Shell | Enables/disables the Project Configuration Editor in VSCode ESP-IDF extension. |
clean_all.sh |
Shell | Cleans everything related with 'build' including skdconfig and depencency.lock leads to a 'virgin'-state. |
| File | Content |
|---|---|
version.txt |
Holds the firmware version, written to None-Volatile-Storage(NVS) during build. |
storage_at_runtime/prm_webserver.html |
Webpage to monitoring the Powermeter register-values. Updated at runtime after each read-cycle. |
storage_at_runtime/webserial.html |
Webpage to show log-messages during runtime (WebSerial) |
partitions.csv |
Partition layout definition needed for OTA and LittleFS. |
This project is licensed under the MIT License.