Hello friends, I hope you all are doing great. Today, I am going to share the new PZEM-004T Energy Meter Library for Proteus Simulation. The PZEM-004T is a complete AC energy meter on a small board: it measures the mains voltage, the current, the active power, the energy, the frequency and the power factor by itself, and hands them to your Arduino over a serial line in the Modbus-RTU protocol. With this library you can run a full Proteus simulation of it - the meter measures what your simulated circuit really does, and answers the very same Modbus frames as the real one.

Figure: The PZEM-004T simulation running: the heaters switch, the readings over Modbus, the alarm.
Updates

PZEM-004T Energy Meter Library for Proteus

Latest version: V1.0 (November 2026, this tutorial)

Other measurement modules: Current Sensor WCS1600 · HX711 Load Cell · ADS1115 ADC · INA219 · ACS712 · ZMPT101B

Helping Tools

The module is drawn compact and comes alive at run time: its PWR LED lights with the mains, RX blinks with each request, TX with each reply, and its shunt glows with the current. The demo is a 230 V energy monitor: an Arduino switches two heater elements, reads the meter every second and shows the readings on an OLED, with an alarm LED driven by the meter's own over-power alarm.

NOTICE: Our team has put a lot of effort into these small parts: the bodies, the animation and the pop-ups are all our own design, and you get them free. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below or in the SCR and TRIAC board of our forum. And if our free libraries help you, you can buy us a coffee. So, let's get started with the PZEM-004T Energy Meter Library for Proteus Simulation:

Figure: The PZEM-004T Energy Meter Library for Proteus Simulation.

What is the PZEM-004T?

The PZEM-004T V3.0 is a single-phase energy meter module. A metering chip samples the voltage and the current thousands of times a second and works out the RMS values, the real power - the average of voltage times current - the energy, the frequency and the power factor. The 10 A version measures the current through a built-in shunt; the 100 A version uses a clip-on current transformer instead. The measuring side is powered by the mains it measures, and an optocoupler isolates the TTL serial port for your Arduino.

The PZEM-004T at a glance
PZEM-004T V3.0 (10 A)
Voltage80 - 260 V AC, 0.1 V
Current0 - 10 A (built-in shunt), 0.001 A
Power, energy0.1 W; 1 Wh up to 9999.99 kWh
Frequency, power factor45 - 65 Hz (0.1 Hz); 0.00 - 1.00
Alarman over-power threshold in W
InterfaceTTL UART 9600 8N1, Modbus-RTU, optocoupler-isolated: 5V, RX, TX, GND
Boardabout 73 x 30 mm: a 4-way screw terminal, a power transformer, the metering chip, two optocouplers

Power Factor in One Paragraph

Multiply the RMS voltage by the RMS current and you get the apparent power in VA. The active power in W is what actually heats, turns or lights - the average of the instantaneous voltage times the instantaneous current. For a heater or a lamp they are the same and the power factor is 1.00. For a motor, or for a load that only conducts for part of each cycle, the current is shifted or distorted and the active power is smaller: the power factor drops. The PZEM-004T measures both, so it shows you the difference.

Modbus-RTU: How the Arduino Talks to It

The PZEM-004T is a Modbus slave. The Arduino sends a short frame - an address, a function code, a register and a count, and a CRC - and the meter answers about 30 ms later. One request reads everything:

Reading all ten registers
BytesMeaning
01 04 00 00 00 0A 70 0Daddress 1, function 0x04 (read input registers), from 0x0000, 10 registers, CRC
01 04 14 ... (20 bytes) ... CRCthe reply: 0x14 = 20 data bytes, two per register, high byte first
The input registers of the PZEM-004T
RegisterMeaningUnit
0x0000Voltage0.1 V
0x0001 - 0x0002Current (low word, high word)0.001 A
0x0003 - 0x0004Active power (low word, high word)0.1 W
0x0005 - 0x0006Energy (low word, high word)1 Wh
0x0007Frequency0.1 Hz
0x0008Power factor0.01
0x0009Alarm0xFFFF on, 0x0000 off

Two more functions do the rest: 0x06 writes a holding register - 0x0001 is the over-power alarm in W, 0x0002 the meter's Modbus address - and 0x42 resets the energy counter. Address 0xF8 is a general address that any single meter answers. A wrong request gets a Modbus exception reply, and a frame with a bad CRC is simply ignored.

The Trap: No AC, No Reply

The metering chip is powered by the mains on its L and N terminals, not by the 5 V on the header. Wire up only the TTL side on your desk and the meter stays completely silent - the number one question about this module. Our model behaves the same way: without AC on L and N it does not answer, and the pop-up says why.

Features of the PZEM-004T Energy Meter Library for Proteus Simulation

  • A real-looking module: the green board with its 4-way screw terminal, the shunt, the yellow power transformer, the metering chip, the two optocouplers, the varistor and the white 4-pin header - drawn compact, and with our small TEP mark.
  • Animated: PWR, RX and TX LEDs (our addition) that work at run time, and a shunt that glows with the current.
  • A real meter in your circuit: the current flows from IN to OUT through a 1 mOhm shunt and L / N take the voltage, so it measures what your simulation really does - RMS values, active power, power factor, frequency, energy.
  • The real Modbus-RTU: functions 0x03, 0x04, 0x06, 0x41 and 0x42, the exception replies, the general and broadcast addresses and the CRC, at 9600 baud.
  • The real traps: no reply without AC on L / N, the two-register values low word first, the over-power alarm.
  • A pop-up: the voltage and current waveforms, the Modbus traffic in hex, eight live tiles with their registers, an energy-reset and alarm chips, graphs, an event log and a check page.
  • A complete package: about 2.8 MB with the library, our OLED, SCR and TRIAC, power resistor, 5 mm LED and resistor libraries, our Arduino UNO V4.0 and the demo, without the source code of the model.

The PZEM-004T in Proteus

The device is PZEM004TTEP in TEPPZEM004T.LIB, under Sensors > Energy, with the prefix U and the model TEPPZEM004T.DLL. Search PZEM or energy in Pick Devices. On the left, at the screw terminal: IN and OUT (the current through the shunt - put them in the live wire to your load) and L and N (the voltage). On the right, the header: 5V, RX, TX and GND. Its properties: ADDRESS (1), ALARM_W (2300 W) and ENERGY (the Wh already counted).

Figure: The PZEM-004T module.

Download PZEM-004T Energy Meter Library for Proteus Simulation

Click the button below to download PZEM-004T-Energy-Meter-Library-for-Proteus-v1.0.zip (about 2.8 MB, without the source code of the models):

PZEM-004T Energy Meter Library for Proteus V1.0
  • README.txt: installation, the demo, the wiring, the safety notes, troubleshooting and the limits of the simulation.
  • Proteus Library Files: TEPPZEM004T.LIB, TEPOLED12864.LIB, TEPTHYR.LIB, TEPPOWERRES.LIB, TEPLED5MM.LIB, TEPRESISTOR.LIB and ArduinoV4TEP.LIB.
  • Proteus Model Files: TEPPZEM004T.DLL, TEPOLED.DLL, TEPTHYR.DLL, TEPPOWERRES.DLL, TEPLED5MM.DLL, TEPRESISTOR.DLL and TEPARDUINO.DLL.
  • Arduino Code: the demo sketch (it needs the AltSoftSerial library from the Library Manager).
  • Proteus Simulation: the demo project, its HEX file and copies of the DLLs.

No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.

How to Install PZEM-004T Energy Meter Library for Proteus Simulation

  1. Close Proteus and extract the whole zip file, for example to your Desktop.
  2. Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
  3. Copy the files from Proteus Model Files into the MODELS folder.
  4. Delete TEPPZEM004T.IDX from the LIBRARY folder if it is there.
  5. Start Proteus, press P and search for PZEM-004T.

Proteus Simulation of a Heater Energy Monitor

Our demo watches two small heater elements on the mains. V1 is Proteus's own ALTERNATOR, 325 V peak - 230 V RMS - at 50 Hz, its negative side grounded like an earthed neutral. The live goes into the meter's IN and out of OUT to the heaters - two 5 W power resistors from our Power Resistor Library for Proteus, 12 kOhm (4.4 W at 230 V) and 15 kOhm (3.5 W) - each switched by a BT136 triac from our SCR and TRIAC Library for Proteus on D5 and D6. The meter's TX and RX go to D8 and D9 of our Arduino UNO Library for Proteus V4.0. Our OLED SSD1306 Library for Proteus shows the readings, and a red ALARM LED from our 5mm LED Library for Proteus sits on D7. The Arduino's built-in monitor is the same window as our TEP Serial Monitor Advance for Proteus. Open PZEM004T-Energy-ArduinoUnoV4.pdsprj.

Figure: The whole simulation on an A4 sheet.

One detail of the triacs: their T1 is on the ground - the same ground as the earthed neutral and the Arduino - and a HIGH pin drives about 18 mA into the gate through the 220 ohm resistor, enough to trigger the BT136 in both half-cycles. That is fine in a simulation; a real build drives the triac through an optotriac such as the MOC3021, which also isolates the Arduino from the mains.

The Sketch

The sketch talks to the meter through AltSoftSerial - D8 receives, D9 sends - and writes the Modbus frames itself. Every frame ends with the Modbus CRC:

uint16_t crc16(const byte* d, byte n) {                     // Modbus CRC: polynomial 0xA001, start 0xFFFF

At start it resets the energy and sets the over-power alarm to 6 W with function 0x06, register 0x0001:

  byte thr[8] = {ADDR, 0x06, 0x00, 0x01, 0x00, 6};          // the over-power alarm at 6 W

Every second it reads the ten input registers in one go - six bytes and the CRC out, 25 bytes back:

  byte req[8] = {ADDR, 0x04, 0x00, 0x00, 0x00, 0x0A}, r[25];

It checks the reply's length and CRC, then takes the values out. The current, power and energy are two registers each, and the low word comes first:

  amps = (reg(1) | (uint32_t)reg(2) << 16) / 1000.0;        // two registers, the LOW word first

The alarm register drives the ALARM LED, and the heaters change every four seconds - none, heater 1, heater 2, both. The OLED shows the power in its yellow band and the voltage, current, power factor with the frequency, energy and the load below.

PZEM-004T Simulation Results

Open the project and press Run. The demo runs 18 simulated seconds and took 316 seconds on our PC with the pop-up open and the pictures being taken. Click the module for its pop-up. Every number below comes from one simulation run, the demo exactly as it ships.

Start-up and No Load

At start the sketch waits for the meter's first readings and sends two frames: 01 42 (reset the energy) and 01 06 00 01 00 06 (the alarm at 6 W). Both come back echoed - the meter's way of saying done - and the monitor prints "Energy reset" and "Alarm threshold: 6 W". From then on the pop-up's traffic pane shows a request every second - 01 04 00 00 00 0A 70 0D - and the meter's 25-byte reply 30 ms later. With no load the meter reads 229.4 - 230.6 V, 0.000 A, 0.0 W, PF 0.00 and 50.0 Hz.

Heater 1, Heater 2

At about 5.4 seconds the sketch switches heater 1 on - the 12 kOhm element. The meter reads 0.0191 A, 4.38 W and a power factor of 1.000, as a heater should: the monitor says 0.019 A, 4.4 W, PF 1.00. The first reading after the switch still shows the old values - the meter refreshes its registers every half second from whole cycles, so a reading can lag the load by up to a second. At about 9.4 seconds heater 2 takes over - 15 kOhm: 0.0153 A and 3.52 W, PF 1.000.

Figure: One heater: the waveforms and the Modbus traffic.

Both Heaters: the Alarm

At about 13.4 seconds both heaters are on: 0.0343 A and 7.88 W, over the 6 W threshold. The meter sets its alarm register to 0xFFFF, the sketch turns the red ALARM LED on, the OLED says ALARM OVER 6 W and the pop-up's banner turns amber. Notice the energy line too: the meter counts in whole watt-hours, and the whole run uses only 0.018 Wh, so its register stays at 0 Wh while the sketch's own count, added up from the power readings, reaches 0.0176 Wh. With a kettle instead of two small heaters the register would count up every few seconds.

Figure: The OLED: both heaters, the alarm.
Figure: The simulation in the workspace.
Figure: Both heaters: the power alarm.

The Graphs, the Event Log and the Check Page

The Graphs page plots the voltage, the current, the active power and the energy. The Event log keeps the power-up, the Modbus requests that change something - the energy reset, the alarm threshold - and the alarm. The Check page sums up the run: 229.1 V at 49.99 Hz on L / N, 7.9 W at the most, 0.018 Wh counted (the register 0 Wh), 5.00 V on the header, and 19 requests with 19 replies, no exceptions and no CRC errors. (The last reading caught the heaters switching off in the middle of a window: 0.5 W with a power factor of 0.25 for that one reading.)

Figure: The Graphs page.
Figure: The Event log.
Figure: The Check page.

The monitor shows the sketch's side: the energy reset, the alarm threshold, and a line of readings every second.

Figure: The monitor.

Energy Meter Module or Your Own Sensors?

You can build the same measurement yourself: a ZMPT101B for the voltage - our ZMPT101B AC Voltage Sensor Library for Proteus - and an ACS712 for the current - our ACS712 Current Sensor Library for Proteus - sampled together by the Arduino, with the RMS, the power and the power factor worked out in your sketch. That teaches you how it works and lets you see the waveforms. The PZEM-004T does it all on its own chip, calibrated, and just hands you the results: less code, more accuracy, and the energy counter keeps counting even while your Arduino is busy.

Try It Yourself

  • Disconnect V1: the meter stops answering, and the sketch prints "No reply from the meter".
  • Click Alarm at 100 W in the pop-up: the alarm clears, since both heaters together draw less.
  • Change the request's address to 0xF8, the general address: the single meter still answers.
  • Send a request with a wrong CRC and watch the pop-up count it and the meter stay silent.
  • Drive one triac with a positive gate current instead (MT1 to ground): the meter shows the half-wave current with a power factor well under 1.

Ideas to Extend the Demo

  • Log the energy of a fridge or a pump through the day and work out its cost.
  • Switch off a load when the alarm comes on - an electronic overload relay.
  • Read several meters on one serial line, each at its own address.

Your Own Sketches

The demo sketch is in the zip file, and you can change it in the Arduino IDE. New to Arduino? Start with our Arduino Tutorial for Beginners. Export the compiled binary, and set the UNO's PROGRAM property to the new file. Our guide on How to get the HEX file from Arduino shows you where the file ends up.

Things to Know Before Using a Real PZEM-004T

  • Mains can kill: the screw terminal and the shunt carry the full mains voltage and the load current - build it in a closed box, never touch the board while it is plugged in, and get help if you are not trained for mains work.
  • No reply? The meter needs AC on L / N; check also TX / RX crossed and 5V on the header.
  • 10 A or 100 A: the 10 A version carries the current through its shunt; for more, use the 100 A version with its current transformer (the same registers).
  • Serial ports: SoftwareSerial or a hardware UART on a real board; this demo uses AltSoftSerial because it also works in Proteus.
  • Several meters: give each its own address with function 0x06 before putting them on one line.

Troubleshooting

  • No reply at all: no AC on L / N, TX / RX not crossed, or no 5V on the header.
  • CRC errors: the baud rate is not 9600, or two meters answer at once.
  • The current reads 0 with the load on: the load's current does not go through IN / OUT.
  • Huge current or power numbers: the two-register values are low word first.
  • The part is not simulated: TEPPZEM004T.DLL is missing from MODELS and from the project folder.

Limitations of the Simulation

  • The measurements, the registers and their formats, the Modbus functions, the exceptions, the addresses and the CRC follow the maker's manual; the module is our own drawing of a PZEM-004T board, drawn compact.
  • Our own choices: the 1 mOhm shunt and the 100 kOhm voltage input, the meter alive above 70 V RMS, the readings refreshed every 0.5 s from whole cycles, the reply 30 ms after the request, 0.2 % of noise and the 2300 W alarm from the factory.
  • Not modelled: the 100 A version's current transformer, the meter's own accuracy curve, the calibration function's effect and the alarm's hysteresis.
  • Arduino is a name of Arduino; this library is not made or endorsed by Arduino, Labcenter or the maker of the PZEM-004T.
  • Tested in Proteus 8.5 in November 2026 (the demo as shipped). Proteus 7 is not supported.

So, that was all about the PZEM-004T Energy Meter Library for Proteus Simulation. I hope it helps you build your energy monitor, your overload alarm or your smart plug safely on the screen before the real board touches the mains - and shows that an energy meter is a simple thing at heart: the voltage, the current, their product averaged over each cycle, and a few Modbus registers to read it all. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!