pzem

package
v0.0.0-...-88a6c0b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//MODBUS_RTU_ADDRESS the range is 0x0001-0x00F7
	MODBUS_RTU_ADDRESS Register = 0x0002
	////AlarmThreshold  1LSB correspond to 1W
	//AlarmThreshold Register = 0x0001
	//
	////ReadHoldingRegister command
	//ReadHoldingRegister Command = 0x03
	//READ_INPUT_REGISTER command
	READ_INPUT_REGISTER Command = 0x04
	//WRITE_SINGLE_REGISTER command
	WRITE_SINGLE_REGISTER Command = 0x06
	////Calibration command
	//Calibration Command = 0x41
	//RESET_ENERGY command
	RESET_ENERGY Command = 0x42

	DEVICE_UPDATE_TIME             = 1000
	DEVICE_DEFAULT_BAUD_RATE       = 9600
	DEVICE_DEFAULT_ADDRESS   uint8 = 0xF8
)

Variables

This section is empty.

Functions

func CheckCRC

func CheckCRC(buf []uint8) bool

func IsError

func IsError(buf []uint8) error

func SetCRC

func SetCRC(buf []uint8)

Types

type Command

type Command uint8

type Config

type Config struct {
	Port         string
	Speed        int
	SlaveAddress uint8
}

Config PZEM initialization

type Probe

type Probe interface {
	Voltage() (float64, error)
	Power() (float64, error)
	Energy() (float64, error)
	Frequency() (float64, error)
	Intensity() (float64, error)
	PowerFactor() (float64, error)
	ResetEnergy() error
}

Probe is PZEM interface

func Setup

func Setup(config Config) (Probe, error)

Setup initialize new PZEM device

type Register

type Register uint16

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL