HT7111 ADC spurious values

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

I would suggest take it off the breadboard. They tend to cause interference.

This is a prototype board, not a breadboard. I might check all the solder joints.

I expect that your 0.2s interval has room for filtering.

filters:
  - median:
      window_size: 5

But you have to check if those outliers are just single spikes or repetitive and adjust filtering according to that.

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 didn’t read your comment about soldered wiring, sorry for that.

Sounds good.

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.

Ah, well then a software filter might be trickier if you’re specifically looking for momentary changes. :confused:

In the plus side, drift shouldn’t really be an issue.

I think I could probably write a lambda to discard a single sample that was an outlier, but I’d prefer to fix the hardware as a first resort.

That’s what median filter does. If you set window of 5 readings and get 38,38,38,95,38 it outputs 38.

Ah, didn’t know that, thanks. Sounds perfect.
I tried adding some capacitors to the 5V line. Didn’t help. Now resorting to the software filter.

You need to adjust the window size according to duration of those spikes. Your graph doesn’t show if it’s single reading or 100.

Understood. I think its only one sample, but I need to download some ESPHome logs to confirm.

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!

Nice. So it was just single spike every ~10000 readings, I think software solution is acceptable here.

1 Like