diff --git a/README.md b/README.md new file mode 100644 index 0000000..4b6b9d5 --- /dev/null +++ b/README.md @@ -0,0 +1,187 @@ +# ESP32 Modbus RTU Power Meter + +## Overview + +This project implements a compact **ESP32 C3 Super Mini-based Modbus RTU power meter interface** designed for monitoring electrical measurements from Modbus-compatible energy meters. The system has been developed and tested using the **Chint DDSU666 Single-Phase Power Meter**, although it is intended to work with any Modbus RTU compliant power meter after appropriate configuration. + +The device continuously reads measurement values from the power meter via an RS485 interface and provides multiple methods for visualizing the data: + +- Local display using a 128 × 32 OLED screen +- Integrated Wi-Fi access point with a web interface + - Historical data visualization + - CSV export of recorded measurements + +The compact enclosure is designed to fit inside a **1TE DIN rail distribution box**, making it suitable for electrical installations where space is limited. + + + + + + +### Features + +- ESP32-C3 Super Mini based implementation +- Modbus RTU communication over RS485 +- Compatible with the Chint DDSU666 and other Modbus RTU power meters +- Local real-time display on a 128 × 32 OLED +- Integrated Wi-Fi Access Point +- Web interface for monitoring live measurements +- Historical data visualization +- CSV export functionality +- Compact DIN rail enclosure (1TE) + + +### Power Meter + +Developed and tested with: + +- Chint DDSU666 Single-Phase Power Meter + +The software should also operate with other Modbus RTU compatible power meters after adjusting the communication parameters and register definitions if necessary. + +#### Modbus RTU Configuration + +The following communication parameters must be configured on the power meter: + +| Parameter | Value | +| -------------- | -------------------------- | +| Baud Rate | 9600 (DDSU666: **BAUD-3**) | +| Data Format | 8N1 | +| Device Address | 008 | + +These settings can also be modified in the source code if different communication parameters are required. + +### User Interface + +#### OLED Display + +The OLED display continuously shows the measured electrical values and is sized to fit within the 1TE enclosure. + + + + +#### Web Interface + +The ESP32 operates as a Wi-Fi Access Point with the following default configuration: + +- **SSID:** `PWR_METER` +- **Password:** None (open network) +- **Web Interface:** `http://192.168.4.1` + +The web interface provides: + +- Real-time measurements +- Historical graphical visualization +- CSV export of measurement data + + + + +## Hardware + +### Schematic + +The complete wiring schematic is shown below. + + + +### Enclosure + +The original enclosure design is based on the following Thingiverse project: + +**D1 Mini DIN Rail Case 1TE, RS485** by Hoich - https://www.thingiverse.com/thing:3337686 +The original design is licensed under: **Creative Commons Attribution – NonCommercial – ShareAlike** + +The enclosure has been modified to accommodate the OLED display. Additionally, a second flat enclosure variant has been created for applications where the OLED display is not required. + +The modified enclosure is licensed under **CC BY-NC-SA 4.0**, while the original enclosure design remains subject to its original Creative Commons license. + + + + + +### Assembly + +The design does not require a dedicated printed circuit board (PCB). + +All components are interconnected using point-to-point wiring inside the 3D-printed enclosure according to the schematic shown above. + + + + + + +## Software + +### Software Architecture + +The software consists of two independent parts: + +1. **Firmware** + + - Executes on the ESP32 + - Reads Modbus RTU measurements + - Updates the OLED display + - Hosts the web server + +2. **Web Resources** + + - HTML + - CSS + - JavaScript + - -> These files are stored in the ESP32 LittleFS filesystem and served by the embedded web server. + +The external libraries used by the project are referenced directly in the source code. + +### Programming the ESP32 + +Both the firmware and the web resources must be uploaded. + +1. **Step 1 – Upload the LittleFS Filesystem** + + Install the LittleFS extension for Arduino IDE. + + - Download the `.vsix` extension from: https://github.com/earlephilhower/arduino-littlefs-upload/releases/ + - Copy the downloaded file into: + ``` + C:\Users\\.arduinoIDE\plugins + ``` + (Create the folder if it does not already exist.) + + Upload the filesystem: + + - Press **CTRL + SHIFT + P** + - Select: + + ``` + Upload LittleFS to Pico/ESP8266/ESP32 + ``` + +2. **Step 2 – Upload the Firmware** + + Upload the ESP32 firmware using the standard **Upload** button in the Arduino IDE. + + +### Software Configuration + +If required, the following parameters can be modified in the source code: + +- Modbus slave address +- Baud rate +- Serial communication settings +- Supported Modbus register mapping +- Wi-Fi configuration +- Display behavior + + +## Sources/Useful Links + +- ESP32-C3 Super Mini Pinout: https://sigmdel.ca/michel/ha/esp8266/super_mini_esp32c3_en.html +- Chint DDSU666 User Manual: https://chint.it/wp-content/uploads/product-docs/iStoragE/Manuali/iStoragE%20Meter%20DDSU666%20User%20Manual%20EN.pdf + +- LittleFS support: https://randomnerdtutorials.com/arduino-ide-2-install-esp32-littlefs/ +- The ESP32 firmware and web interface are based on examples from: + - https://randomnerdtutorials.com/esp32-websocket-server-sensor/ + - https://randomnerdtutorials.com/esp32-web-server-gauges/ + - https://github.com/ChartsCSS/charts.css + diff --git a/pictures/device_1.jpg b/pictures/device_1.jpg new file mode 100644 index 0000000..f50336b Binary files /dev/null and b/pictures/device_1.jpg differ diff --git a/pictures/device_2.jpg b/pictures/device_2.jpg new file mode 100644 index 0000000..1a3690d Binary files /dev/null and b/pictures/device_2.jpg differ diff --git a/pictures/display.jpg b/pictures/display.jpg new file mode 100644 index 0000000..57dd498 Binary files /dev/null and b/pictures/display.jpg differ diff --git a/pictures/webpage.png b/pictures/webpage.png new file mode 100644 index 0000000..3bbc908 Binary files /dev/null and b/pictures/webpage.png differ diff --git a/pictures/wiring_1.jpg b/pictures/wiring_1.jpg new file mode 100644 index 0000000..0e84931 Binary files /dev/null and b/pictures/wiring_1.jpg differ diff --git a/pictures/wiring_2.jpg b/pictures/wiring_2.jpg new file mode 100644 index 0000000..e4a7699 Binary files /dev/null and b/pictures/wiring_2.jpg differ