NullScale

class NullScale[source]

Bases: object

__init__()

Methods

__init__()

calibrate(weight)

Calibrates the scale using a known weight.

get_weight()

Gets the current weight.

real_weight_inference()

Determines if a sequence of weight measurements represents a stable weight.

tare()

Tares the scale.

Attributes

error: str = 'Error connecting to the scale '
tare() None[source]

Tares the scale.

calibrate(weight: float) None[source]

Calibrates the scale using a known weight.

Parameters:

weight (float) – The known weight.

get_weight() float[source]

Gets the current weight.

Returns:

The weight reading (default 0.0).

Return type:

float

real_weight_inference() tuple[bool, float][source]

Determines if a sequence of weight measurements represents a stable weight.

Conditions to call it a real weight: - standard deviation of the last 5 measurements is

smaller than 10% of the threshold

Returns:

(True, median_weight) if stable, else (False, 0.0).

Return type:

tuple[bool, float]