Component: Energy Monitor (PZEM-004T) (Electrical)
Author | Matrix Ltd. |
Version | 1.0 |
Category | Electrical |
Contents
Energy Monitor (PZEM-004T) component
The PZEM-004T module is used for measuring AC voltage, current, active power, frequency, power factor & overcurrent. Resetable active energ and the overpower level can be set and monitored.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_Energy_Monitor_PZEM-004T.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_Energy_Monitor_PZEM-004T.fcfx
Detailed description
No detailed description exists yet for this component
Examples
Notes: if there is a communication issue after initialisation, then just 9's will be returned!
The TX of the PZEM-004T energy monitor goes to RX of the Arduino Uno
The RX of the PZEM-004T energy monitor goes to TX of the Arduino Uno The PZEM-004T must be disconnected from the RX of the Uno prior to programming. After reconnecting press the Reset button on the Uno
WARNING: MAINS CAN KILL. ONLY TRY THIS IF ARE EXPERIENCED WITH MAINS ELECTRICITY. WIRE AT YOUR OWN RISK!
This example program uses a PZEM-004T energy monitor to monitor mains voltage, current, frequency, power factor, energy, and over-threshold power alarm. The alarm threshold is set within properties. Initialiasion returns 0 if PZEM-004T is detected or 255 if it is not. Values are sent to the ESP32 TTGO display which uses a ST7789v1 GLCD.
This example uses the Arduino Uno and outputs UART via the Timer UART component on pin D2 at a baud rate of 19200.
All the functions are the same as above but no display is used.
D3 and D4 have pullups so no external resistors are required.
Each switch is pulled to GND to trigger.
Macro reference
Initialise
![]() |
Initialise |
Starts up the UART to allow communications. Also, checks if PZEM-004T is detected. Returns 0 if detected or 255 if not detected. | |
![]() |
Return |
ReadAlarmStatus
![]() |
ReadAlarmStatus |
65535 = Overpower alarm triggered. 0 = Overpower alarm not triggered. | |
![]() |
Return |
ReadCurrent
![]() |
ReadCurrent |
Read what the current draw is. Resolution: 0.001A Measurement accuracy: 0.5% | |
![]() |
Return |
ReadEnergy
![]() |
ReadEnergy |
Read active energy value. Resolution: 1Wh Measurement accuracy: 0.5% | |
![]() |
Return |
ReadFrequency
![]() |
ReadFrequency |
Reads the frequency of the mains | |
![]() |
Return |
ReadPower
![]() |
ReadPower |
Read active power. Starting measure power: 0.4W Resolution: 0.1W | |
![]() |
Return |
ReadPowerAlarmThreshold
![]() |
ReadPowerAlarmThreshold |
Reads the power alarm threshold in watts | |
![]() |
Return |
ReadPowerFactor
![]() |
ReadPowerFactor |
Read power factor Resolution: 0.01 Measurement accuracy: 1% | |
![]() |
Return |
ReadVoltage
![]() |
ReadVoltage |
Read voltage. Measuring range:80~260V Resolution: 0.1V Measurement accuracy: 0.5% | |
![]() |
Return |
ResetEnergy
![]() |
ResetEnergy |
Reset the energy value | |
![]() |
Return |
SetPowerThresholdLevel
![]() |
SetPowerThresholdLevel |
Sets the power alarm threshold in watts | |
![]() |
PowerThresholdValue |
Reg addreess high of alarm threshold | |
![]() |
Return |