Skip to content

cchian/PZEM-004T-V3.0-CS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PZEM-004T-V3.0 C# Library

This library allow you to connect your computer to PZEM-004T V3.0 digital meter Module directly via UARTtoUSB Converter (without microcontroller)
Baud rate is 9600,8 data bits, 1 stop bit, no parity

New PZEM-004T version (protocol changed) The application layer use the Modbus-RTU protocol to comunicate.
the original library from: https://github.com/mandulaj/PZEM-004T-v30 ( C/C++ library for Arduino)

example:

using System;
using System.Windows.Forms;
using System.IO.Ports;
using Pzem;
namespace Pzem004t {
    public partial class Demo : Form {
        public Demo() {
            InitializeComponent();
            new PZEM004TV30(new SerialPort("COM6")).OnUpdate += Pz_OnUpdate;
        }
        
        //Defualt update interval is 200ms (change it by .setInterval(int ms))
        private void Pz_OnUpdate(object sender, PzemEvent e) {
            Console.WriteLine("Voltage:" + e.Values.Voltage+"V");
            Console.WriteLine("Current:" + e.Values.Current+"A");
            Console.WriteLine("Active Power:" + e.Values.Power+"W");
            Console.WriteLine("Active Energy:" + e.Values.Energy+"Wh");
            Console.WriteLine("Frequency:" + e.Values.Frequency+"Hz");
            Console.WriteLine("Power Factor:" + e.Values.PF);
        }
    }
}