Documentation ¶
Index ¶
- Constants
- Variables
- func CalculatePowerFactor(c *Config, phase Phase, watts float64, voltAmps float64, ...) float64
- func DeviceFetchInt(d *i2c.Device, l int, cmd []byte) int64
- func InitADE7878(c *Config) (*i2c.Device, error)
- func ReadActiveEnergy(d *i2c.Device, c *Config, phase Phase) (energy float64)
- func ReadActiveWatts(d *i2c.Device, c *Config, phase Phase) (watts float64)
- func ReadAngle(d *i2c.Device, c *Config, phase Phase) (angle float64)
- func ReadApparentPower(d *i2c.Device, c *Config, phase Phase) float64
- func ReadCurrent(d *i2c.Device, c *Config, phase Phase) (current float64)
- func ReadFrequency(d *i2c.Device, c *Config, phase Phase) (frequency float64)
- func ReadPhase(d *i2c.Device, c *Config, p Phase, v *ADE7878Readout)
- func ReadReactivePower(d *i2c.Device, c *Config, phase Phase) (rewatts float64)
- func ReadVoltage(d *i2c.Device, c *Config, phase Phase) (voltage float64, measureVoltage bool)
- func WriteRegister(d *i2c.Device, register string, data ...byte) (err error)
- type ADE7878Readout
- type CTFactors
- type Config
- type Phase
- type Readings
Constants ¶
View Source
const ( ADE7878_ADDR int = 0x38 SAMPLES int = 100 )
View Source
const ( PhaseA PhaseB PhaseC PhaseN )
Variables ¶
View Source
var ADE7878REG = map[string][]byte{}/* 136 elements not displayed */
View Source
var ( CTTypes = map[string]CTFactors{ "YHDC_SCT013": CTFactors{ CurrentResistor: 7.07107, CurrentClampFactor: 0.05, OffsetCurrent: 1.049084906, OffsetVoltage: 1.0, PowerCorrectionFactor: 0.019413, }, "X/1A": CTFactors{ CurrentResistor: 0.33, CurrentClampFactor: 1.0, OffsetCurrent: 1.010725941, OffsetVoltage: 1.0, PowerCorrectionFactor: 0.043861, }, } )
View Source
var MainPhases = []Phase{PhaseA, PhaseB, PhaseC}
Functions ¶
func CalculatePowerFactor ¶
func DeviceFetchInt ¶
Fetch a number of bytes from the device and convert it to an int.
func ReadActiveEnergy ¶
func ReadReactivePower ¶
func ReadVoltage ¶
Types ¶
type ADE7878Readout ¶
type CTFactors ¶
type CTFactors struct {
CurrentResistor, CurrentClampFactor, OffsetCurrent, OffsetVoltage, PowerCorrectionFactor float64
}
type Config ¶
type Config struct { // [base] Serial string Name string LogLevel log.Level MetricsListenAddress string // [location] Lat float64 Lng float64 // [device] I2CDevice string PowerFrequency float64 Samplerate int Integrator bool CTType map[Phase]string CTTypePrimaryCurrent map[Phase]int CurrentDirection map[Phase]bool MeasureCurrent map[Phase]bool MeasureVoltage map[Phase]bool Voltage map[Phase]float64 // [calibration] CalibrationfactorI map[Phase]float64 CalibrationfactorU map[Phase]float64 }
func (*Config) ReadParameterFromFile ¶
func (p *Config) ReadParameterFromFile()
Click to show internal directories.
Click to hide internal directories.