[SOLVED] How to implement a zeroing button for a HX711 scale?

Hello,
I would like to build a scale with an ESP32, 4 load cells and a HX711 load cell amp.

I do not have the parts yet (Aliexpress has 8 days shipping time) but I would like to write the YAML in advance based on the ESPHome docs…

But I would like to have a button in HA that set the scale to 0 (like the TARA button on commercial scales).

My code for the HX711 currently looks like this:

sensor:
  - platform: hx711
    id: hx711_raw
    name: "Waage Rohwert"
    dout_pin: 29
    clk_pin: 28
    gain: 128
    update_interval: 5s
switch:
  - platform: copy
    source_id: hx711_raw
    name: "Waage kalibriert"
    unit_of_measurement: "kg"
    device_class: weight
    filters:
      - calibrate_linear:
        values:
          10 -> 0
          150 -> 1

I think you’d have to make a global, say, current_zero, which you set from the raw value when pressing the TARE button. Then take the weight from a template sensor which computes the weight - current_zero

I haven’t used it, but you may be able to get some ideas from:

I’m not answering the question but answering a question you didn’t ask. So ignore as you see fit…

I had high hopes for a scale I could use to keep track of my propane cylinders current volume (translated from weight) but after a couple of years of trying I gave up on them entirely. The issue was that the load cells/circuit was way too temperature dependent. the weight would vary several pounds (out of 37 total pounds for a full tank) over the course of the day as the temp went up and down. It was way worse in the winter as well.

I never tested them in a temperature controlled environment so I can’t say how stable they will be. But I charted the weight vs ambient temperature on two different scales and it was pretty much a 100% correlation. Unfortunately I wasn’t smart enough to get a reasonable temperature compensation equation worked out. Mostly because of the differences between variations of weight over 10F to 40F in winter and 60F to 90F in summer. It wasn’t linear.

all that to say beware if you are using them outside.

Thank you, I’ll try to just implement this YAML when I get the parts…