Smart energy meter for a hostel room or shop

Bills arrive once a month, so people cannot see which appliance wastes power. A meter that shows live watts and units used, and the cost in rupees at the local tariff, makes savings visible.

ESP32Mini or Major projectEEE, ECE, EIE
ESP320.17 A0.17 AOLEDONFeatured
Parts
₹2,875
Build
14 weeks
Board
ESP32
Objectives
6
Mains wiring can kill. Use the isolated PZEM module, an enclosed box, a fuse and an MCB, and have your guide check the wiring before switching on.

Block diagram

Inputs
  • 4.98V
    PZEM-004T moduleMeasures voltage, current, power and energy safely
Controller
  • ESP32
    ESP32Reads the meter and works out cost
Outputs
  • 23.4°COLED
    OLED displayShows watts, units and rupees
  • ON
    RelayCuts a load above a limit
  • CLOUD
    Cloud dashboardStores readings, plots trends and sends alerts+
  • DATA
    Data loggerStores timestamped readings for analysis+

Objectives

  1. To measure voltage, current, power, power factor and energy of a single-phase load.
  2. To show the cost in rupees using the local tariff slabs.
  3. To compare the readings with the electricity board meter over a week (error below 2%).
  4. To cut supply to a load above a set power (up to 2 kW with the 10 A relay).
  5. To publish readings over MQTT and show them on a live dashboard with threshold alerts.
  6. To log timestamped data and analyse it to support the conclusions with evidence.

Parts and specifications

Total about ₹2,875 at typical online prices. Tap a part for its pinout and datasheet notes.

Design calculations

Real power

P = V × I × PF. 230 V × 4.2 A × 0.9 = 869 W.

Energy and units

Energy (kWh) = P × hours / 1000. 869 W for 5 hours = 4.35 units.

Cost with slabs

Example tariff: ₹3 for the first 100 units, ₹4.50 for 101 to 200. 150 units cost 100 × 3 + 50 × 4.5 = ₹525, plus fixed charge.

Relay limit

The relay contacts are rated 10 A, so the cut-off must stay below 230 × 8 = 1840 W, about 80% of rating.

Pin map

SignalPin or connection
PZEM TX → ESP32 RX2GPIO 16
PZEM RX ← ESP32 TX2GPIO 17
PZEM VCC5 V (module TTL side is isolated)
OLED SDA / SCLGPIO 21 / 22
Relay INGPIO 26

Firmware outline

  1. Poll the PZEM over Modbus-RTU every 1 s: voltage, current, power, energy, frequency and PF.
  2. Keep today's and this month's units in flash, saved every 10 minutes.
  3. Work out the bill with the slab table stored in code.
  4. If power stays above the set limit for 5 s, open the relay and show why.
  5. Show live watts, units today and rupees on the OLED; serve a web page with the same.

Test plan

TestExpected result
100 W bulbAbout 100 W, PF near 1.0
CFL or phone chargerPF well below 1 (reactive and non-linear load)
One week against the board meterDifference below 2%
Load above the limitRelay opens within 5 s
Power cut and restartEnergy total kept

These rows start your results table when you plan the project.

Viva practice

Say your answer out loud first, then check. The first 2 answers are free; Maker opens all 6.

1. What is power factor?
2. Why use a current transformer?
3. What is the difference between W and VA?
4. How does the PZEM measure energy?
5. Why is mains isolation important here?
6. How would you make it a prepaid meter?

Make it yours

One or two upgrades for a mini project, two to four for a major one.

Build these first

Datasheets and sources to cite

  • Peacefair PZEM-004T v3 manual
  • IS 13779 (AC static watthour meters)
  • Your state electricity regulatory commission tariff order

About this project

How much does the smart energy meter for a hostel room or shop project cost?

About ₹2,265 for the parts in the base list: ESP32 DevKit V1, PZEM-004T v3 with CT coil, 0.96 inch OLED (SSD1306, I²C), 5 V relay module (1 channel), 5 A glass fuse with holder, Enclosed switchboard box, sockets and 6 A MCB, 5 V USB charger for the ESP32.

How long does it take?

About 10 weeks for the base project, built on an ESP32. Each upgrade adds time.

Which branches is it suitable for?

Electrical and Electronics, Electronics and Communication, Instrumentation, as a mini or major project.

Which pins and design calculations does it use?

PZEM TX → ESP32 RX2 on GPIO 16; PZEM RX ← ESP32 TX2 on GPIO 17; PZEM VCC on 5 V (module TTL side is isolated). Worked calculations on this page: real power, energy and units, cost with slabs, relay limit.

How do I test it?

100 W bulb: About 100 W, PF near 1.0. CFL or phone charger: PF well below 1 (reactive and non-linear load). One week against the board meter: Difference below 2%. Load above the limit: Relay opens within 5 s. Power cut and restart: Energy total kept.

What are the objectives?

To measure voltage, current, power, power factor and energy of a single-phase load. To show the cost in rupees using the local tariff slabs. To compare the readings with the electricity board meter over a week (error below 2%). To cut supply to a load above a set power (up to 2 kW with the 10 A relay).