Skip to content

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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PZEM-004T-V3.0 C# Library

// This library allows you to connect your computer to the PZEM-004T V3.0 digital meter module directly via a UART-to-USB converter (without a microcontroller).
// The baud rate is 9600, with 8 data bits, 1 stop bit, and no parity.
// The new PZEM-004T version (protocol changed) uses the Modbus-RTU protocol to communicate at the application layer.
// The original library is 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);
        }
    }
}