Web preview
Install Node.js, then run these commands from the project folder. Open the local address printed by the dev server.
npm install
npm run devA practical guide to the hardware, ESP32 program, connection details and a simple index.html client. Start with the placeholders, then follow the message contract.
| Item | Purpose | Example configuration |
|---|---|---|
| ESP32 DevKit (classic ESP32) | Local priority policy and networking | Arduino board: ESP32 Dev Module |
| PZEM-004T v3.0 | Aggregate AC electrical measurements | UART2 RX GPIO16, TX GPIO17 |
| Suitable two-channel relay interface | Demonstration switching | GPIO26 and GPIO27; active-low behavior must match the actual module |
| Two supervised demonstration loads | High/low priority examples | Estimated 100 W and 40 W; change to match your loads |
| Power, isolation and enclosure | Appropriate supply and separation | Verify signal levels and module requirements; no mains wiring through a breadboard |
| Wi-Fi + TLS MQTT broker | Device and app communication | Wi-Fi supported by your ESP32; secure WSS endpoint for app |
| Placeholder | Where to get it | Where it belongs |
|---|---|---|
WIFI_SSID / WIFI_PASSWORD | Your Wi-Fi network | ESP32 secrets.h only |
MQTT_HOST / MQTT_PORT | Broker provider’s TLS endpoint, without wss:// | ESP32 secrets.h; usually port 8883, verify with provider |
MQTT_USERNAME / MQTT_PASSWORD | A restricted device broker account | ESP32 secrets.h |
ROOT_CA | Broker provider’s current root CA PEM | ESP32 secrets.h; keep BEGIN/END CERTIFICATE lines |
BROKER_URL | Provider’s secure WebSocket URL | App Settings / minimal web example |
USERNAME / PASSWORD | A restricted app broker account | App Settings / minimal web example |
TOPIC_PREFIX | Your chosen device namespace | Both clients; default optimizer/ |
| Topic after prefix | Payload | Direction |
|---|---|---|
telemetry | JSON object below, every second; not retained | ESP32 to app |
status | online / offline; retained last-will status | ESP32 / broker to app |
control/budget | Integer string from 0 to 300 | App to ESP32; not retained |
control/load1 | 1 requests ON; 0 cancels the request | App to ESP32; not retained |
control/load2 | 1 requests ON; 0 cancels the request | App to ESP32; not retained |
{
"budget": 200, "w": 100.0,
"v": 230.0, "i": 0.435, "pf": 0.99,
"hz": 50.0, "kwh": 0.125, "va": 100.05,
"l1": true, "l2": false,
"r1": true, "r2": false,
"e1": 100.0, "e2": 40.0,
"status": "Live PZEM telemetry"
}Loading configuration template…Loading ESP32 code…Loading web example…Install Node.js, then run these commands from the project folder. Open the local address printed by the dev server.
npm install
npm run devThe Android project uses Capacitor 8. Install a compatible Android SDK and JDK 21. Sync the bundled pages before building.
npm run android:sync
npm run android:apkUse npm run android:open to open the native project in Android Studio. A release distributed publicly needs your own signing configuration.