Skip to content

Instantly share code, notes, and snippets.

@markusressel
Last active March 12, 2024 05:05
Show Gist options
  • Save markusressel/e888544d4404fbed4c841ec83df638bb to your computer and use it in GitHub Desktop.
Save markusressel/e888544d4404fbed4c841ec83df638bb to your computer and use it in GitHub Desktop.
ESPHome sample configuration for an HX711 powered Smart Scale including Auto-Tare functionality.
Moved to https://github.com/markusressel/ESPHome-Smart-Scale
@markusressel
Copy link
Author

Please use the repository for questions and issues.
https://github.com/markusressel/ESPHome-Smart-Scale

@cayote64
Copy link

cayote64 commented Aug 23, 2023

I'm wondering if anyone can help.

I have used this with an ESP8266 board in an outside hedgehog box. It weighs the hogs as they are feeding. Everything works, however the zero reading drifts massively being outside. I have tried a previous auto tare which keeps the reading at 0g throughout the day, but the weight is quite a distance out once the temperatures drop on the night.

Can anyone include some code so that I can use a spare GPIO pin on the board so as the hog enters the box, the scales zero themselves before it reaches the main compartment ?

Current code is:

globals:

  • id: constant_weight
    type: float

`captive_portal:

sensor:

  • platform: hx711
    id: weight
    name: "HX711 Value2"
    dout_pin: GPIO14
    clk_pin: GPIO12
    gain: 128
    update_interval: 5s
    unit_of_measurement: g
    filters:
    calibrate_linear:
    - 68604 -> 0
    - 626959 -> 2030
    on_value:
    - if:
    condition:
    - lambda: |-
    static float last = 0.0;
    float diff = x - last;
    last = x;
    return x < 50.0 && diff < 1.0 && diff > - 1.0;
    then:
    - lambda: 'id(constant_weight) = x;'

  • platform: template
    name: Hog Weight2
    icon: mdi:scalee
    unit_of_measurement: g
    accuracy_decimals: 0
    lambda: 'return id(weight).state;'
    filters:
    - lambda: 'return x - id(constant_weight);'
    - lambda: 'return x >= 10.0 ? x : 0;'
    - delta: 0.5`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment