Hi. I am measuring the weight of a small item using a 3kg load cell, a HT711 ADC and a XAIO ESP32-C3. I am using the ESPHome “HX711 Load Cell Amplifier” component to drive the HT711 and get the data into HA.
Without any change to the weight on the scales, it randomly produces an incorrect weight value, eg 95grams instead of 38grams. It does this a few times per hour. I am sampling the signal every 0.2 seconds.
Any thoughts on what’s causing this and how to fix this?
Here’s the ESPHome config:
sensor:
- platform: hx711
name: "Scales"
dout_pin: 10
clk_pin: 9
gain: 128
unit_of_measurement: g
icon: "mdi:scale"
device_class: "weight"
state_class: "measurement"
accuracy_decimals: 0
update_interval: 0.2s #ADC sampling interval
filters:
- calibrate_linear:
- -66000 -> 0
- +84000 -> 217
- or:
- delta: 10 # Send value to HA only if value changes more than 10 grams
- heartbeat: 10s # Send update every 10 seconds even if weight hasn't changed
Thanks Karosm. I was hoping to solve the underlying issue in the hardware ie stop the spikes from occurring. If that fails I’ll try filtering them out as you suggested.
Of course. Software solution is usually “the second option”.
But your wiring is quite far from ideal.
I see you have the only hx711 board that actually works with 3.3V Esp board. Did you take advantage of that separate 3.3/5V voltage supply?
What wiring changes would you recommend?
FYI I connected the incoming 5v to the HX711 VCC and the XAIO 3.3v output to the HX711 VDD.
I might add some capacitors to the incoming 5v, in case there’s noise coming from the power supply.
I’ve gotten similar weird spikes like that as well. My particular project was located outside, so I was less inclined to dig too deep into potential hardware issues and just did a filter.
I’ll also toss out the question of what your end goal of the project is. You’ll definitely tend to get some drift over time.
It’s a reminder to give my dog her daily tablet. There’s a LED on the board which illuminates at a set time every day. When you lift the tablets off the scales, Home Assistant turns off the LED. So anyone in the house can give the tablet without asking if it’s been done already.
The rule right now is to turn off the LED when the weight changes by more than 10grams in either direction.
That median filter worked, thanks. I used the default filter length of 5 and haven’t had any breakthrough spurious readings come through in 12 hours.
Thanks for your help!