levelsensor

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HX711

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

func NewHX711

func NewHX711(
	sckPin outputPinner,
	dataPin inputPinner,
	offset int32,
	calibrationFactor float32,
	limitCm uint8,
) *HX711

NewHX711 returns a level sensor based on reading of a load cell connected to the first channel of a HX711.

func (HX711) Calibrate

func (ls HX711) Calibrate(zero bool) error

Calibrate calibrates to the mass of mechanic, if value is false, otherwise measures the offset.

func (HX711) ConfigStatus

func (ls HX711) ConfigStatus() byte

func (HX711) Configure

func (ls HX711) Configure() error

func (HX711) IsCritical

func (ls HX711) IsCritical() (bool, error)

func (HX711) Limit

func (ls HX711) Limit() uint8

Limit returns the limit for the level in cm (0..255).

func (HX711) OffsetAndCalibrationFactor

func (ls HX711) OffsetAndCalibrationFactor() (int32, float32)

OffsetAndCalibrationFactor returns linear correction values, used for reading.

func (HX711) SetLimit

func (ls HX711) SetLimit(newLimit uint8)

SetLimit sets a new limit in cm (0..255)

func (HX711) SetMassLossOnImmersion

func (ls HX711) SetMassLossOnImmersion(newMassLossGramPerCm float32)

SetMassLossOnImmersion set a new value for the mass loss in gram per immersion in cm. This value is for calculation of the level and has no influence on the calibration. The mass loss can be calculated by the density of the used fluid (e.g. 1g/cm³ for water) multiplied by the volume of the solid which equals 1 cm immersion.

func (HX711) SetMassOfMechanic

func (ls HX711) SetMassOfMechanic(newMassGram float32)

SetMassOfMechanic set a new value for the used mass in gram (value without immersion). After change of this value a call of the calibration function is maybe useful.

func (HX711) SetOffsetAndCalibrationFactor

func (ls HX711) SetOffsetAndCalibrationFactor(offset int32, calibrationFactor float32)

SetOffsetAndCalibrationFactor sets linear correction values, used for reading.

func (HX711) Value

func (ls HX711) Value() uint8

Value returns the level in cm (0..255) of the last read.

Jump to

Keyboard shortcuts

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