Skip to content

Ramsudarshanmaurya/Energy-Monitoring-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โšก Energy Monitoring System (EMS)

Typing SVG

ESP32 Arduino MQTT Node-RED WiFi Modbus License Status


A complete IoT-based real-time energy monitoring solution using ESP32, Modbus RTU, MQTT, and Node-RED Dashboard with local DWIN HMI Display.


GitHub LinkedIn Website


๐Ÿ“ธ Project Gallery

Hardware Setup DWIN Display Node-RED Dashboard
Hardware DWIN Dashboard
ESP32 + MAX485 + Energy Meter Live HMI Display Live Gauges
Block Diagram Circuit Diagram
Block Circuit
System Architecture Complete Wiring

๐Ÿ“‹ Table of Contents


โšก Overview

The Energy Monitoring System (EMS) is a complete Industrial IoT solution that monitors electrical parameters of loads in real-time. The system reads data from a Modbus RTU energy meter using an ESP32 microcontroller, transmits data wirelessly via WiFi + MQTT, and visualizes it on a Node-RED dashboard. A local DWIN HMI display shows live readings on-site.

๐Ÿ“Š 5 Parameters  |  ๐Ÿ”„ 10s Update Rate  |  ๐Ÿ“ก WiFi + MQTT  |  ๐Ÿ–ฅ๏ธ Local HMI  |  ๐Ÿšจ Smart Alerts

โœจ Features

๐Ÿ“ก Data Acquisition

  • โœ… Modbus RTU over RS485
  • โœ… 5 electrical parameters
  • โœ… 10-second update rate
  • โœ… IEEE 754 float conversion

๐Ÿ–ฅ๏ธ Local Display

  • โœ… DWIN HMI Touch Screen
  • โœ… Real-time value updates
  • โœ… UART @ 115200 baud
  • โœ… 5 VP address mapping

๐ŸŒ IoT Connectivity

  • โœ… WiFi 2.4GHz (STA mode)
  • โœ… MQTT publish/subscribe
  • โœ… Aedes local broker
  • โœ… Auto reconnect

๐Ÿ“Š Dashboard

  • โœ… Live circular gauges
  • โœ… Historical line charts
  • โœ… Numeric text display
  • โœ… 2-tab layout

๐Ÿšจ Alert System

  • โœ… Voltage range check
  • โœ… Current overload
  • โœ… Frequency instability
  • โœ… Low power factor

๐ŸŒ HTTP API

  • โœ… REST GET endpoint
  • โœ… JSON response
  • โœ… CORS enabled
  • โœ… Latest data access

๐Ÿ—๏ธ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    EMS SYSTEM ARCHITECTURE                              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    RS485     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    UART     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚ ENERGY METER โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚   MAX485     โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚ ESP32  โ”‚ โ”‚
โ”‚  โ”‚ Modbus Slave โ”‚   A+ / B-   โ”‚  RS485โ†”TTL   โ”‚  GPIO32,27  โ”‚DevKit  โ”‚ โ”‚
โ”‚  โ”‚  Slave ID:1  โ”‚              โ”‚  GPIO33(DE)  โ”‚             โ”‚        โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ”‚        โ”‚ โ”‚
โ”‚                                                             โ”‚        โ”‚ โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    UART1                                  โ”‚        โ”‚ โ”‚
โ”‚  โ”‚    DWIN      โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚        โ”‚ โ”‚
โ”‚  โ”‚   Display    โ”‚  GPIO16(RX) GPIO17(TX) @ 115200          โ”‚        โ”‚ โ”‚
โ”‚  โ”‚  HMI Touch   โ”‚                                          โ””โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                                              โ”‚      โ”‚
โ”‚                                                          WiFi  โ”‚      โ”‚
โ”‚                                                         2.4GHz โ”‚      โ”‚
โ”‚                                                                โ–ผ      โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  MQTT:1883  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   LAN  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚   NODE-RED   โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚ AEDES BROKER โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚  ROUTER  โ”‚  โ”‚
โ”‚  โ”‚  Dashboard   โ”‚  Topic:     โ”‚ 192.168.1.8  โ”‚        โ”‚192.168.  โ”‚  โ”‚
โ”‚  โ”‚  :1880/ui    โ”‚  EMS/UCT    โ”‚   Port:1883  โ”‚        โ”‚   1.1    โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚         โ”‚                                                             โ”‚
โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                 โ”‚
โ”‚    โ–ผ              โ–ผ                โ–ผ                                  โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                            โ”‚
โ”‚ โ”‚Gauge โ”‚    โ”‚  Charts  โ”‚    โ”‚  Alerts  โ”‚                            โ”‚
โ”‚ โ”‚  UI  โ”‚    โ”‚ Tab View โ”‚    โ”‚  Popup   โ”‚                            โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”ง Hardware Components

# Component Model Qty Purpose
1 ๐Ÿง  ESP32 DevKit ESP32-WROOM-32 1 Main IoT Controller
2 โšก Energy Meter Modbus RTU Type 1 Measure Electrical Parameters
3 ๐Ÿ”Œ MAX485 Module RS485 to TTL 1 RS485 Interface
4 ๐Ÿ–ฅ๏ธ DWIN Display HMI Touch Screen 1 Local Real-time Display
5 ๐Ÿ“ถ WiFi Router 2.4GHz Router 1 Wireless Network
6 โš™๏ธ Power Supply 5V DC Adapter 1 Power for ESP32
7 ๐Ÿ’ป PC / Laptop Linux/Windows 1 Node-RED Host
8 ๐Ÿ”— Jumper Wires M-F Set Set Connections

๐Ÿ“Œ Pin Connections

๐Ÿ–ฅ๏ธ DWIN Display โ†” ESP32

DWIN Pin ESP32 Pin GPIO Signal
TX RX1 (U1RXD) GPIO 16 DWIN โ†’ ESP32
RX TX1 (U1TXD) GPIO 17 ESP32 โ†’ DWIN
VCC 5V 5V Power
GND GND GND Ground

๐Ÿ”Œ MAX485 Module โ†” ESP32

MAX485 Pin ESP32 Pin GPIO Signal
RO (Receive Out) Custom RX GPIO 32 RS485 โ†’ ESP32
DI (Data Input) Custom TX GPIO 27 ESP32 โ†’ RS485
DE (Driver Enable) Control GPIO 33 TX Enable
RE (Receiver Enable) Control GPIO 33 RX Enable (tied to DE)
VCC 5V 5V Power
GND GND GND Ground

โšก MAX485 โ†” Energy Meter

MAX485 Energy Meter Description
A+ A+ RS485 Positive Line
B- B- RS485 Negative Line

๐Ÿ”Œ Complete Wiring

ESP32 DevKit
โ”œโ”€โ”€ GPIO 16 (RX1) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’ DWIN Display TX
โ”œโ”€โ”€ GPIO 17 (TX1) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’ DWIN Display RX
โ”œโ”€โ”€ GPIO 32       โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’ MAX485 RO
โ”œโ”€โ”€ GPIO 27       โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’ MAX485 DI
โ”œโ”€โ”€ GPIO 33       โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’ MAX485 DE + RE (tied)
โ”œโ”€โ”€ 5V            โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’ DWIN VCC + MAX485 VCC
โ””โ”€โ”€ GND           โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’ DWIN GND + MAX485 GND

MAX485
โ”œโ”€โ”€ A+  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’ Energy Meter A+
โ””โ”€โ”€ B-  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’ Energy Meter B-

๐Ÿ’ป Software Stack

Layer Technology Version Purpose
Firmware Arduino IDE (C++) 2.x ESP32 Programming
IoT Protocol MQTT (PubSubClient) 2.8+ Data Publishing
Serial Protocol Modbus RTU (ModbusMaster) 2.0.1 Meter Reading
Data Format ArduinoJson 6.x JSON Serialization
Dashboard Node-RED 3.x Visualization
MQTT Broker Aedes (Node-RED) Latest Local Broker
UI Framework node-red-dashboard 3.x Gauges & Charts

๐Ÿ“ฆ Arduino Libraries

#include <WiFi.h>           // WiFi connection
#include <PubSubClient.h>   // MQTT client
#include <ModbusMaster.h>   // Modbus RTU master
#include <ArduinoJson.h>    // JSON v6+
#include <SoftwareSerial.h> // Modbus UART
#include <HardwareSerial.h> // DWIN UART

๐Ÿ“ก Communication Protocols

1๏ธโƒฃ Modbus RTU (RS485)

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         MODBUS RTU CONFIG           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Baud Rate       โ”‚ 9600 bps          โ”‚
โ”‚ Data Bits       โ”‚ 8                 โ”‚
โ”‚ Parity          โ”‚ None              โ”‚
โ”‚ Stop Bits       โ”‚ 1 (8N1)           โ”‚
โ”‚ Slave ID        โ”‚ 1                 โ”‚
โ”‚ Function Code   โ”‚ 0x04 (Read Input) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

2๏ธโƒฃ MQTT Protocol

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚           MQTT CONFIG               โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Broker          โ”‚ Aedes (Local)     โ”‚
โ”‚ Host            โ”‚ 192.168.1.8       โ”‚
โ”‚ Port            โ”‚ 1883              โ”‚
โ”‚ Topic           โ”‚ EMS/UCT           โ”‚
โ”‚ QoS             โ”‚ 0                 โ”‚
โ”‚ Publish Rate    โ”‚ Every 10 seconds  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

3๏ธโƒฃ MQTT JSON Payload

{
  "Voltage"     : 230.5,
  "Current"     : 1.25,
  "Frequency"   : 49.98,
  "PowerFactor" : 0.95,
  "Energy"      : 0.52
}

๐Ÿ—บ๏ธ Modbus Register Map

Parameter Register (Hex) Register (Dec) Data Type Unit
โšก Voltage 0x15 21 32-bit IEEE Float V
๐Ÿ”Œ Current 0x17 23 32-bit IEEE Float A
ใ€ฐ๏ธ Frequency 0x1B 27 32-bit IEEE Float Hz
๐Ÿ“ Power Factor 0x19 25 32-bit IEEE Float PF
๐Ÿ”‹ Active Energy 0x0E 14 32-bit Float (Swapped) kWh

๐Ÿ–ฅ๏ธ DWIN VP Address Map

Parameter VP Address Unit
Voltage 0x64 V
Frequency 0x65 Hz
Energy 0x66 kWh
Current 0x67 A
Power Factor 0x68 PF

๐Ÿ“Š Dashboard

Tab 1 โ€” โšก Live Dashboard

Gauge Min Max Yellow Red Unit
Voltage 0 300 200 260 V
Current 0 100 50 80 A
Frequency 45 55 49 51 Hz
Power Factor 0 1 0.7 0.9 PF
Active Power 0 50 20 40 kW

Tab 2 โ€” ๐Ÿ“ˆ Historical Charts

Chart Y-Min Y-Max Color Points
Voltage (V) 200 260 #00d4ff ๐Ÿ”ต 60
Current (A) 0 50 #ff6b35 ๐ŸŸ  60
Frequency (Hz) 49 51 #a8ff3e ๐ŸŸข 60
Power Factor 0 1 #ff3ecc ๐ŸŸฃ 60
Active Power (kW) 0 50 #ffd700 ๐ŸŸก 60

๐ŸŒ Access Dashboard

Dashboard URL : http://127.0.0.1:1880/ui
HTTP API      : http://192.168.1.8:1880/api/ems
Node-RED      : http://127.0.0.1:1880

โš ๏ธ Alert System

Parameter Condition Alert Message
โšก Voltage < 200V or > 260V Voltage OUT OF RANGE: xxV
๐Ÿ”Œ Current > 80A Current HIGH: xxA
ใ€ฐ๏ธ Frequency < 49.5Hz or > 50.5Hz Frequency UNSTABLE: xxHz
๐Ÿ“ Power Factor < 0.8 Low Power Factor: x.xx

๐Ÿ”” Alerts appear as popup notifications on the dashboard in real-time!


๐ŸŒ Network Configuration

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              NETWORK TOPOLOGY               โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Device       โ”‚ IP Address   โ”‚ Port          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ WiFi Router  โ”‚ 192.168.1.1  โ”‚ โ€”             โ”‚
โ”‚ PC (WiFi)    โ”‚ 192.168.1.8  โ”‚ 1883, 1880    โ”‚
โ”‚ ESP32        โ”‚ 192.168.1.x  โ”‚ โ€”  (DHCP)     โ”‚
โ”‚ MQTT Broker  โ”‚ 192.168.1.8  โ”‚ 1883          โ”‚
โ”‚ Node-RED     โ”‚ 127.0.0.1    โ”‚ 1880          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โš ๏ธ Important: ESP32 supports 2.4GHz WiFi only โ€” 5GHz will NOT work!


๐Ÿš€ Getting Started

Prerequisites

# Arduino IDE Libraries (Install via Library Manager)
โœ… PubSubClient       by Nick O'Leary
โœ… ModbusMaster       by Doc Walker
โœ… ArduinoJson        v6+ by Benoit Blanchon

# Node-RED Packages
โœ… node-red-dashboard
โœ… node-red-contrib-aedes

Step 1 โ€” ESP32 Setup

// Update WiFi credentials in code
const char* ssid     = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
const char* mqtt_server = "YOUR_PC_IP";  // e.g. 192.168.1.8
# Upload via Arduino IDE
Board   : ESP32 Dev Module
Port    : COMx (Windows) or /dev/ttyUSB0 (Linux)
Upload Speed : 115200

Step 2 โ€” Node-RED Setup

# Install Node-RED (if not installed)
npm install -g node-red

# Start Node-RED
node-red

# Open browser
http://127.0.0.1:1880

Step 3 โ€” Import Flow

โ˜ฐ Menu โ†’ Import โ†’ Select file โ†’ Node Red JSON file/nodered_aedes_flow.json โ†’ Import โ†’ Deploy

Step 4 โ€” View Dashboard

๐ŸŒ Open browser: http://127.0.0.1:1880/ui

Step 5 โ€” Verify Serial Monitor

โœ… WiFi Connected!
โœ… IP Address: 192.168.1.x
โœ… MQTT Connected!
โœ… Active Power (kW): xx.xx
โœ… Publish message: {"Voltage":230.5,...}

๐Ÿ“ Project Structure

๐Ÿ“ฆ Energy Monitoring System/
โ”œโ”€โ”€ ๐Ÿ“‚ Code/
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ EMS_Final_Code.ino          # ESP32 Arduino Firmware
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ Document/
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ EMS_Documentation.docx      # Full Technical Documentation
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ EMS_Full_Documentation.docx # English Detailed Doc
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ image/
โ”‚   โ”œโ”€โ”€ ๐Ÿ–ผ๏ธ EMS_Block_Diagram.png       # System Block Diagram
โ”‚   โ”œโ”€โ”€ ๐Ÿ–ผ๏ธ EMS_Circuit_Diagram.jpg     # Circuit Wiring Diagram
โ”‚   โ”œโ”€โ”€ ๐Ÿ–ผ๏ธ image1.jpg                  # Node-RED Dashboard
โ”‚   โ”œโ”€โ”€ ๐Ÿ–ผ๏ธ image2.jpg                  # Live Gauges
โ”‚   โ”œโ”€โ”€ ๐Ÿ–ผ๏ธ image3.jpg                  # DWIN Display
โ”‚   โ”œโ”€โ”€ ๐Ÿ–ผ๏ธ image4.jpg                  # Hardware Setup
โ”‚   โ””โ”€โ”€ ๐Ÿ–ผ๏ธ image5.jpg                  # Energy Meter
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ Node Red JSON file/
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ nodered_aedes_flow.json     # Node-RED Flow Export
โ”‚
โ””โ”€โ”€ ๐Ÿ“„ README.md                       # This File โ† You are here!

๐Ÿ”ฎ Future Enhancements

  • ๐Ÿ’พ Database Integration โ€” InfluxDB / MySQL for historical storage
  • ๐Ÿ“ง Email/SMS Alerts โ€” Critical event notifications
  • ๐Ÿ“ฑ Mobile App โ€” React Native / Flutter
  • ๐Ÿ’ฐ Billing Calculator โ€” Monthly electricity bill from kWh
  • ๐Ÿ“Š Grafana Dashboard โ€” Professional time-series visualization
  • โ˜๏ธ Cloud Integration โ€” AWS IoT / Azure IoT Hub
  • ๐Ÿ”ง OTA Updates โ€” Over-the-air ESP32 firmware updates
  • ๐Ÿ“ˆ Multi-Meter Support โ€” Monitor multiple energy meters

๐Ÿ› Troubleshooting

Problem Cause Solution
WiFi not connecting Wrong SSID or 5GHz router Use 2.4GHz, check credentials
MQTT failed (rc=-2) Wrong broker IP Check mqtt_server IP
Modbus no data Wrong A+/B- wiring Swap RS485 wires
DWIN blank Wrong GPIO or baud Check GPIO 16/17, 115200
Dashboard empty MQTT disconnected Redeploy Node-RED flow

๐Ÿ‘จโ€๐Ÿ’ป Author

Ramsudarshan Maurya

Embedded Systems & IoT Engineer

B.Tech ECE โ€” AKTU Lucknow (2025) | CGPA: 7.4 UniConverge Technologies, Noida (Intern)

GitHub LinkedIn Portfolio Email

Skills: C C++ ESP32 STM32 FreeRTOS MQTT BLE Modbus IoT

๐Ÿ† RoboRace 1st Prize ย |ย  ๐Ÿ“„ Published Researcher ย |ย  ๐ŸŸข Open to Work


๐Ÿ“„ License

MIT License โ€” Free to use, modify, and distribute with attribution.
Copyright (c) 2025 Ramsudarshan Maurya

โญ If this project helped you, please give it a star!

Visitor Count

Made with โค๏ธ by Ramsudarshan Maurya

ESP32 + Modbus RTU + MQTT + Node-RED = Complete EMS Solution โšก

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages