Introduction
Design a smart energy meter that measures voltage, current, power, and energy with real-time cloud dashboard. This comprehensive guide covers everything from design through implementation, testing, and deployment.
Design a smart energy meter that measures voltage, current, power, and energy with real-time cloud dashboard.
Design a smart energy meter that measures voltage, current, power, and energy with real-time cloud dashboard. This comprehensive guide covers everything from design through implementation, testing, and deployment.
AC power measurement requires RMS (Root Mean Square) calculations. The Arduino samples the AC waveform at high speed (2000+ samples/cycle), calculates VRMS and IRMS using the Emonlib library, then computes real power (W), apparent power (VA), reactive power (VAR), and power factor (PF = W/VA). True RMS measurement accounts for non-sinusoidal loads like computers and motors.
10 components required for this project.
| # | Component | Purpose | Qty |
|---|---|---|---|
| 1 | Arduino Uno R3 | Main microcontroller | x1 |
| 2 | ACS712 Current Sensor (30A) | Non-invasive AC current measurement | x1 |
| 3 | ZMPT101B Voltage Sensor Module | AC mains voltage measurement | x1 |
| 4 | ESP8266 NodeMCU | WiFi data transmission to cloud | x1 |
| 5 | OLED 1.3" Display (I2C) | Real-time local readout | x1 |
| 6 | DS3231 RTC Module | Timestamping energy readings | x1 |
| 7 | SD Card Module | Local data logging | x1 |
| 8 | 10A 250V Calibrated Shunt | Precision current reference | x1 |
| 9 | 5V 2A Power Supply | System power | x1 |
| 10 | ABS Project Enclosure | Weatherproof housing | x1 |
Follow these 10 steps carefully.
AC power measurement requires RMS (Root Mean Square) calculations. The Arduino samples the AC waveform at high speed (2000+ samples/cycle), calculates VRMS and IRMS using the Emonlib library, then computes real power (W), apparent power (VA), reactive power (VAR), and power factor (PF = W/VA). True RMS measurement accounts for non-sinusoidal loads like computers and motors.
Connect the ZMPT101B across the mains supply (through a properly fused test lead). Adjust the onboard potentiometer until the output sine wave is within the 0–3.3V range of the Arduino ADC. Measure actual mains voltage with a certified multimeter. In code, apply a voltage calibration factor: VCAL = Actual_Volts / Raw_Volts_Calculated. Typical VCAL for 230V systems is around 234.26.
Connect the ACS712 in series with a known resistive load (e.g., 100W incandescent bulb). The ACS712-30A outputs 66mV/A centered at VCC/2 (2.5V). Measure actual current with a clamp meter. Apply ICAL = Actual_Amps / Calculated_Amps. Zero the sensor by averaging 1000 samples with no load — this compensates for DC offset.
Integrate real power over time to calculate energy in kWh: Energy_kWh += (RealPower_W × sample_interval_ms) / (3,600,000). Store cumulative kWh in EEPROM with wear-leveling (rotate across 16 addresses). Read EEPROM on startup to restore total energy after power loss — just like a real utility meter.
Log timestamp, voltage, current, power, power factor, and cumulative kWh to a CSV file every minute. Create daily files (YYYYMMDD.csv) to limit file size. Use the SD library with the SPI interface. This creates a permanent local record for billing verification and consumption trend analysis over months.
Create a ThingSpeak channel with 6 fields: Voltage, Current, Real Power, Apparent Power, Power Factor, Cumulative kWh. Program ESP8266 to receive data from Arduino via SoftwareSerial and POST to ThingSpeak every 60 seconds using the REST API. Add MATLAB visualizations on ThingSpeak to calculate daily/monthly energy cost at your tariff rate.
Program the OLED to cycle through 3 screens every 5 seconds: Screen 1: Voltage (V) and Current (A), Screen 2: Real Power (W) and Power Factor, Screen 3: Today's kWh and Total kWh. Include a button to manually cycle screens. Display a warning icon when PF < 0.8 (indicating poor power quality from inductive loads).
Implement a tariff structure: enter your electricity rate per kWh in the code. Calculate daily cost, monthly estimate, and display projected monthly bill. Add slab-based tariff support (e.g., 0–100 units at ₹3.50, 101–200 at ₹5.00) matching your local utility company's billing structure for accurate cost estimation.
Set a maximum current threshold (e.g., 20A). When exceeded, immediately publish a MQTT alert and trigger a buzzer. Log the overcurrent event with timestamp to SD card. Optionally integrate a relay to automatically disconnect the load when dangerous current levels are sustained for more than 5 seconds — providing automatic circuit protection.
Connect a known load (2000W water heater = 8.7A at 230V). Compare meter readings with a reference clamp meter (expect ±1% accuracy). Test power factor measurement with a fan motor (expected PF: 0.6–0.8). Test with LED lights (PF: 0.5–0.9 depending on driver quality). Verify cumulative kWh by running a 1000W load for exactly 1 hour.
Core code for energy_meter.ino:
#include <EmonLib.h> #include <Wire.h> #include <Adafruit_SSD1306.h> #include <SD.h> #include <RTClib.h> EnergyMonitor emon1; Adafruit_SSD1306 display(128, 64, &Wire, -1); RTC_DS3231 rtc; #define V_CAL 234.26 #define I_CAL 29.5 #define P_CAL 1.7 float cumulative_kwh = 0; unsigned long lastCalc = 0; void setup() { Serial.begin(115200); emon1.voltage(A0, V_CAL, 1.7); emon1.current(A1, I_CAL); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); rtc.begin(); SD.begin(10); EEPROM.get(0, cumulative_kwh); } void loop() { emon1.calcVI(20, 2000); float V = emon1.Vrms; float I = emon1.Irms; float P = emon1.realPower; float S = emon1.apparentPower; float PF = emon1.powerFactor; unsigned long now = millis(); float dt_h = (now - lastCalc) / 3600000.0; cumulative_kwh += (P * dt_h) / 1000.0; lastCalc = now; EEPROM.put(0, cumulative_kwh); display.clearDisplay(); display.setTextSize(1); display.setCursor(0, 0); display.printf("V:%.1fV I:%.2fA\\n", V, I); display.printf("P:%.1fW PF:%.2f\\n", P, PF); display.printf("kWh: %.3f\\n", cumulative_kwh); display.display(); Serial.printf("%.1f,%.3f,%.1f,%.1f,%.2f,%.4f\\n", V, I, P, S, PF, cumulative_kwh); delay(1000); }
Test Digital Energy Meter with IoT by verifying each subsystem individually before full integration.
Verify power voltages, check ground connections, use serial monitor for debug.
An interactive simulator will be available here — simulate circuits and run code in-browser without hardware.