![image](https://private-user-images.githubusercontent.com/61102713/395097163-778c7cbd-cac6-4dd8-a6ea-f943715503e4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0ODIxMjEsIm5iZiI6MTczOTQ4MTgyMSwicGF0aCI6Ii82MTEwMjcxMy8zOTUwOTcxNjMtNzc4YzdjYmQtY2FjNi00ZGQ4LWE2ZWEtZjk0MzcxNTUwM2U0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDIxMjM0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI1MTc4MjVkZWYxZWUzMmVjNzVhZTU0M2I1MmI3NDM3MzU3MmEyZmQ4OGQwZTRmNzg0OGQ4YjRjZTg1ZTVlYjYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.LtoaJT1wS9oF-wquUtmgsVebZAXLpbAoSM4vVbrFjoQ)
This document guides you through quickly setting up and running a simple test and demo environment for Dignsys' PMS01 power monitoring board. Previously, manual installation and configuration of Arduino IDE, Node-RED, MQTT broker (Mosquitto), and InfluxDB were required. However, this updated guide allows you to conveniently configure all backend environments using Docker Compose. Additionally, the firmware uploaded to the PMS01 board is now built and uploaded using PlatformIO.
By following this guide, you can configure the PMS01 board to send power data to a local MQTT server and visualize real-time power measurements via the Node-RED dashboard.
![image](https://private-user-images.githubusercontent.com/61102713/395096518-fe8a859e-0f4b-4be7-9a66-9b16900112ff.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0ODIxMjEsIm5iZiI6MTczOTQ4MTgyMSwicGF0aCI6Ii82MTEwMjcxMy8zOTUwOTY1MTgtZmU4YTg1OWUtMGY0Yi00YmU3LTlhNjYtOWIxNjkwMDExMmZmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDIxMjM0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYwNGQ2NDIzNTRhMjE4ODlhNDRiNTMyZjNhYmI4YjM3MzYxZTkxMTUyNjhmOTk2MTVhMzFiYzY3YmVhZThkYTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.cBkZbnxnWSoODVsFS89lcrfqqWDkL2F5mPC2Jkm7wWs)
- PMS01 Board: Power measurement (voltage, current, power, energy, frequency, power factor) using the PZEM-004T module.
- MQTT Communication: Periodic data transmission to a local Mosquitto MQTT broker.
- Node-RED Dashboard: Visualization of real-time and historical data with InfluxDB as the backend.
- Docker Compose Environment: Convenient single-command deployment of Node-RED, InfluxDB, and Mosquitto services.
- Prepare the PMS01 Board and PZEM-004T Module.
- Install PlatformIO:
- Refer to the PlatformIO official site.
- Available as a VSCode extension or CLI tool.
- Install Docker & Docker Compose:
- Refer to the Docker official site.
- See Docker Compose Installation Guide.
- Ensure a Wi-Fi Network:
- The PMS01 board and the test PC (or laptop) must be connected to the same network (Wi-Fi).
- Supply 12V power to the PMS01 board and 220V power to the PZEM-004T module.
Caution: The PZEM-004T module requires 220V power supply to function properly, independent of the PMS01 board.
.
├── README.md # Project overview and usage guide
├── docker-compose.yml # Docker Compose file for Node-RED, InfluxDB, and Mosquitto services
├── include
│ └── README # Documentation for the include directory
├── init-influxdb
│ └── init-influxdb.sh # Initialization script for InfluxDB
├── lib
│ ├── PZEM004Tv30-pms # PZEM-004T v3.0 sensor library (for PMS01 board)
│ ├── README # Documentation for the lib directory
│ └── SC16IS752Serial # Library for serial communication extension
├── mosquitto
│ └── config # Mosquitto MQTT broker configuration files
├── platformio.ini # Configuration for building and uploading PMS01 firmware (PlatformIO)
├── src
│ ├── MQTTClient.cpp # MQTT client logic
│ ├── MQTTClient.h
│ ├── PowerMonitor.cpp # Power monitoring logic
│ ├── PowerMonitor.h
│ └── main.cpp # Main entry point for the PMS01 firmware
├── test
│ └── README # Documentation for testing
└── volumes
├── influxdb-data # InfluxDB data volume
├── mosquitto-data # Mosquitto data volume
├── mosquitto-log # Mosquitto log volume
└── nodered-data # Node-RED data volume
-
Modify the
platformio.ini
file to set the serial port, Wi-Fi, and MQTT settings for the PMS01 board.// Example settings in main.cpp const char* WIFI_SSID = "YOUR_WIFI_SSID"; const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD"; const char* MQTT_SERVER = "192.168.0.10"; // IP of the PC running Docker Compose const int MQTT_PORT = 1883;
Ensure the PMS01 board and PC are on the same network. Set the
MQTT_SERVER
to the IP address of the host (PC) running the Mosquitto container. -
Connect the PMS01 board to the PC via USB and use PlatformIO to build and upload the firmware.
pio run -t upload
After the upload is complete, the PMS01 board will connect to the Wi-Fi and begin sending data to the MQTT server.
The docker-compose.yml
file is located in the root directory of this project. Use the following commands to run backend services like Node-RED, InfluxDB, and Mosquitto.
-
Start Docker Compose:
docker-compose up -d
The following services will run as containers:
- Node-RED: http://localhost:1880
- InfluxDB: http://localhost:8086
- Mosquitto (MQTT Broker): mqtt://localhost:1883
- InfluxDB Admin UI: http://localhost:8083 (optional)
-
Check the infrastructure status:
docker ps
Use
docker logs <container_name>
to troubleshoot any issues.
- Access the Node-RED UI:
- Open your browser and go to http://localhost:1880.
- Import the provided Node-RED flow JSON:
- In the Node-RED editor, select Import from the top-right menu.
- Paste the JSON code and click Import.
- Deploy the flow:
- Click the Deploy button to activate the flow.
- View the dashboard:
- Open http://localhost:1880/ui in your browser to view the power monitoring dashboard.
-
PMS01 Board -> Mosquitto (MQTT Broker)
The PMS01 board connects to the configured Wi-Fi and sends power data to thepms01/power
topic. -
Mosquitto -> Node-RED
Node-RED subscribes to thepms01/power
topic and receives data in real-time. -
Node-RED -> InfluxDB
Data is parsed within Node-RED and stored in InfluxDB. -
Node-RED Dashboard
The dashboard retrieves data from InfluxDB for real-time and historical visualization.
-
MQTT Connection Issues:
- Check if the PMS01 board is connected to the same LAN as the host PC.
- Verify that the Mosquitto container is running using
docker logs mosquitto
. - Ensure firewall settings allow communication.
-
Missing Data:
- Add a debug node in Node-RED to verify data output from the MQTT-In node.
- Use PlatformIO Monitor to view logs from the PMS01 board.
-
InfluxDB Query Issues:
- Access the InfluxDB Admin UI at http://localhost:8083 to check the database and measurements.
- Verify the InfluxDB node configuration in Node-RED.
- Modify the PMS01 firmware using PlatformIO for updates.
- Back up and manage InfluxDB data.
- Extend Node-RED flows for additional features (e.g., alerts, email notifications).
- This project is licensed under the MIT License.
- Bug reports, feature suggestions, and Pull Requests are welcome.