Giter Club home page Giter Club logo

gop1's Introduction

Go Report Card Documentation

Golang P1 protocol library

This is a golang library to read P1 data from a so called smart energy meter, used primarily in The Netherlands. P1 is the protocol Dutch power grid companies designed together and is described on netbeheernederland.nl. The smart meters which are being deployed in Belgium implement the same protocol, but some additional data types were defined by the power grid companies. These types are defined in the e-MUCS H specification.

To read P1 data, you'll need something like a P1-to-USB cable. The P1 port is essentially a serial port where data (a so called P1 telegram) is dumped every second.

Example usage:

package main

import (
	"fmt"

	"github.com/skoef/gop1"
)

func main() {
	// open a new reader to given USB serial device
	p1, err := gop1.New(gop1.P1Config{
		USBDevice: "/dev/ttyUSB0",
	})
	if err != nil {
		panic(err)
	}

	// start reading data
	// this will send new telegrams to the channel p1.Incoming
	p1.Start()

	for telegram := range p1.Incoming {
		// loop over the objects in the telegram to find types we're interested in
		for _, obj := range telegram.Objects {
			switch obj.Type {
			case gop1.OBISTypeInstantaneousPowerDeliveredL1:
				fmt.Printf("actual power usage: %s %s\n", obj.Values[0].Value, obj.Values[0].Unit)
			}
		}
	}
}

In the example/ folder is an example application that collects relevant metrics and offers them over a prometheus-compatible HTTP endpoint for scraping.

Acknowledgements

The smartmeter project from Marcel de Graaf inspired me to write something like this. I like his work, but was looking for a more pluggable library rather than an actual application. Also there is a whole lot python projects out there with P1 support that gave some insight.

gop1's People

Contributors

pmaene avatar skoef avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

cloudnatives

gop1's Issues

No issue, just thanks!

Jow man, good to see Dutch Go development! Will use this package to send data to pvoutput.org.
Any tips regarding which cable to use? For example, would this cable do this job you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.