levelsensor

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 4 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,
	massOfMechanic, massLossPerLevelRise int16,
	limit uint8,
) *HX711

NewHX711 returns a level sensor based on reading of a load cell connected to the first channel of a HX711. Please read the documentation of the HX711 for offset and calibration factor of the configurable ADC. Please read the documentation of base level sensor for the other parameters.

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 (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 (0..255)

func (HX711) SetMassLossOnImmersion

func (ls HX711) SetMassLossOnImmersion(newMassLossPerLevelRise int16)

SetMassLossOnImmersion set a new value for the mass loss per immersion. 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 relates to the immersion.

func (HX711) SetMassOfMechanic

func (ls HX711) SetMassOfMechanic(newMass int16)

SetMassOfMechanic set a new value for the used mass (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) error

SetOffsetAndCalibrationFactor sets linear correction values, used for reading.

func (HX711) Value

func (ls HX711) Value() uint8

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

Jump to

Keyboard shortcuts

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