Recording stable weight from hx711

I’m looking to get a sensor that displays the weight on a platfom only if it remains the same for a period of time. This is the current code that Igot from esphome smart scale:

- platform: template

    id: smart_scale_hx711_value

    name: "Smart Scale HX711 Value"

    internal: False

    filters:

      # apply auto_tare difference

      - lambda: 'return x + id(auto_tare_difference);'

      # apply rough calibration

      - calibrate_linear:

          # retrieve these values by evaluating the raw values with loads of known mass.

          # note that a bigger difference between measurements usually results in higher resolution,

          # so measure 0 Kg and the highest known mass you have (like f.ex. your own weight, measured by a normal scale with good accuracy)

          - 13120 -> 0

          - 31100 -> 8

      # map values below 0.1 to 0 (to decrease value changes due to random fluctuation)

      - lambda: |-

          if (x <= 0.1) {

            return 0.0;

          } else {

            return x;

          }

    unit_of_measurement: kg

    accuracy_decimals: 2

    # the sensor will automatically update through the 'sensor.template.publish' call

    update_interval: never

I would like to have a separate sensor that only displays the value of “Smart Scale HX711 Value” if it has a stable weight that remains unchanged for 3 seconds. I have tried quite a few different ways and haven’t had any success.

I used a delta filter for that, with sufficiently high value.

Does it fluctuate over long periods of time for you too? Mine sees a swing of over 300g even after temperature compensation thru third to seventh degree polynomial curves.

if I could ask what are you using for the temperature compensation?

Temperature probe with voltage divider. It tracks with my other temperature sensors.

1 Like

Thanks I’ve ended up using the delta and and debounce filter in a seperate sensor and it’s basically doing what I want. I haven’t been using it very long but with auto tare enabled in the esp smart scale code I am getting fairly accurate results at this stage. My use case maybe different to yours though as I want to weigh something that is stepping on and off my scale not constantly sitting on it.

Yah it’s different. I want to weigh a gas cylinder so I need it to be stable over long periods of time.