hx711

package
v3.4.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package hx711 implements an interface to the 24-bits HX711 analog to digital converter.

Datasheet

http://www.aviaic.com/Download/hx711F_EN.pdf.pdf

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTimeout is returned from Read and ReadAveraged when the ADC took too
	// long to indicate data was available.
	ErrTimeout = errors.New("timed out waiting for HX711 to become ready")
)

Functions

This section is empty.

Types

type Dev

type Dev struct {
	// contains filtered or unexported fields
}

Dev is a handle to a hx711.

func New

func New(clk gpio.PinOut, data gpio.PinIn) (*Dev, error)

New creates a new HX711 device.

The data pin must support edge detection. If your pin doesn't natively support edge detection you can use PollEdge from gpioutil.

func (*Dev) Function

func (d *Dev) Function() string

Function implements analog.PinADC.

func (*Dev) Halt

func (d *Dev) Halt() error

Halt stops a continuous read that was started with ReadContinuous.

This will close the channel that was returned by ReadContinuous.

func (*Dev) IsReady

func (d *Dev) IsReady() bool

IsReady returns true if there is data ready to be read from the ADC.

func (*Dev) Name

func (d *Dev) Name() string

Name implements analog.PinADC.

func (*Dev) Number

func (d *Dev) Number() int

Number implements analog.PinADC.

func (*Dev) Range

func (d *Dev) Range() (analog.Sample, analog.Sample)

Range implements analog.PinADC.

func (*Dev) Read

func (d *Dev) Read() (analog.Sample, error)

Read implements analog.PinADC.

func (*Dev) ReadContinuous

func (d *Dev) ReadContinuous() <-chan analog.Sample

ReadContinuous starts reading values continuously from the ADC. It returns a channel that you can use to receive these values.

You must call Halt to stop reading.

Calling ReadContinuous again before Halt is an error, and nil will be returned.

func (*Dev) ReadTimeout

func (d *Dev) ReadTimeout(timeout time.Duration) (int32, error)

ReadTimeout reads a single value from the ADC.

It blocks until the ADC indicates there is data ready for retrieval. If the ADC doesn't pull its Data pin low to indicate there is data ready before the timeout is reached, ErrTimeout is returned.

func (*Dev) SetInputMode

func (d *Dev) SetInputMode(inputMode InputMode) error

SetInputMode changes the voltage gain and channel multiplexer mode.

func (*Dev) String

func (d *Dev) String() string

String implements analog.PinADC.

type InputMode

type InputMode int

InputMode controls the voltage gain and the channel multiplexer on the HX711. Channel A can be used with a gain of 128 or 64, and Channel B can be used with a gain of 32.

const (
	CHANNEL_A_GAIN_128 InputMode = 1
	CHANNEL_A_GAIN_64  InputMode = 3
	CHANNEL_B_GAIN_32  InputMode = 2
)

Jump to

Keyboard shortcuts

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