am2301

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AM2301

type AM2301 interface {
	Check() (State, error)
}

AM2301 minimal interface

type Impl

type Impl struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Impl standard implementation of a Monitor

func New

func New(pin gpio.Pin) *Impl

New new am2301

func (*Impl) Check

func (am *Impl) Check() (State, error)

Check start a monitor with the given handler hook

func (*Impl) Read

func (am *Impl) Read() ([5]byte, error)

Read read a 5-byte sequence from the pin

func (*Impl) Request

func (am *Impl) Request() error

Request send the signal to request a new measurement

type State

type State struct {
	RH   float64
	Temp float64
}

State state of an AM2301 sensor

func Parse

func Parse(vals [5]byte) (State, error)

Parse parse a State from a 5-byte input stream

func (State) Valid

func (s State) Valid() bool

Valid check that values are within the specifed range

Jump to

Keyboard shortcuts

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