hx711

package
v3.3.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package hx711 implements an interface to the 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 (
	// TimeoutError is returned from Read and ReadAveraged when the ADC took too
	// long to indicate data was available.
	TimeoutError = 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
}

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 periph.io/x/periph/experimental/conn/gpio/gpioutil

func (*Dev) Halt

func (d *Dev) Halt()

Halt stops a continuous read that was started with StartContinuousRead. This will close the channel that was returned by StartContinuousRead.

func (*Dev) IsReady

func (d *Dev) IsReady() bool

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

func (*Dev) Read

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

Read 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, TimeoutError is returned.

func (*Dev) SetInputMode

func (d *Dev) SetInputMode(inputMode InputMode)

SetInputMode changes the voltage gain and channel multiplexer mode.

func (*Dev) StartContinuousRead

func (d *Dev) StartContinuousRead() <-chan int32

StartContinuousRead 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 StartContinuousRead again before Halt is an error, and nil will be returned.

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