emon

package module
v0.0.0-...-2effa10 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2016 License: MIT Imports: 2 Imported by: 1

README

emon-api-go

Go module to read emon-http-arduino

Example

package main

import (
	"fmt"
	"os"

	emon "github.com/exzz/emon-api-go"
)

func main() {

	// set up
	e, err := emon.NewClient(emon.Config{
		URL: "http://192.168.168.16:5555",
	})
	if err != nil {
		fmt.Printf("Unable to connect to Energymonitor: %s", err)
		os.Exit(1)
	}

	// read data
	err = e.Read()
	if err != nil {
		fmt.Printf("Cannot fetch EnergyMonitor data: %s", err)
		os.Exit(1)
	}

	fmt.Printf("%+v\n", e.Sensor)
}

Output should look like this :

{SiteName:Home ModuleName:mainPower Irms:1.15 Vrms:237.57 RealPower:197.28 ApparentPower:273.54 PowerFactor:0.72 ExecTime:1669656 Time:1479115468}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	URL    string
	Sensor PowerSensor
}

func NewClient

func NewClient(config Config) (*Client, error)

func (*Client) PowerSensor

func (c *Client) PowerSensor() PowerSensor

func (*Client) Read

func (c *Client) Read() error

type Config

type Config struct {
	URL string
}

type PowerSensor

type PowerSensor struct {
	SiteName      string
	ModuleName    string
	Irms          float32
	Vrms          float32
	RealPower     float32
	ApparentPower float32
	PowerFactor   float32
	ExecTime      int
	Time          int
}

Jump to

Keyboard shortcuts

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