Posts: 3
Joined: Thu Feb 08, 2024 4:58 pm

HX711 continually drifting upwards - at a loss!

Thu Feb 08, 2024 5:26 pm

Hi there,

I'm working on a digitial scale for an addition to a hobby project that combines a Raspberry Pi 3B+ with a HX711 and 4 strain gauges from a kitchen scale in a wheatstone bridge configuration. Everything is connected and working but the output is continually counting up on average. I'm at a bit of a loss as to why this could be happening.

I'm using the python code library provided by Endail implementing the HX711 c library (
https://github.com/endail/hx711) in python https://github.com/endail/hx711-rpi-py. I have calibrated the code using the calibrate.py script with a known weight of 449g but I'm certain this also experiences this increase as the calibration output is never the same twice. I haven't changed any of this code and I can't find any information online as to other examples of this happening.

The drift is demonstrated here. The sudden spikes are when I have placed a known weight of 449g on the strain gauges. Otherwise there is no weight on the strain gauges.
driftInWeightSensor.png (31.83 KiB) Viewed 194 times

Equipment used:
  • Raspberry Pi 3B+
  • Sparkfun HX711
  • 4 strain gauges in a Wheatstone bridge configuration salvaged from a kitchen scale. All tested with a multimeter.
Code used:
  • Endail/HX711 run through the python variant HX711-rpi-py
Circuit configuration:
  • Wheatstone bridge connected to HX711
  • HX711 connected to Raspberry Pi with Data -> GPIO 20, CLK -> GPIO 16. VCC -> 5v, VDD -> 3.3v shared with a temp sensor 3.3v, GND -> GND
  • Wheatstone to HX711 with A -> E+, D -> E-, B -> A+, C -> A-

I can send a circuit diagram if requested but it is a bit difficult to see given all the wiring passing throught the breadboard. I also have a temperature sensor and a small OLED screen wired into the GPIO. The HX711 is sharing a 3.3v GPIO pin with the temperature sensor, I read online that this is ok.

What could cause this? I'm reasonably confident in the code as I've made no changes. I believe my wiring is correct as I purposely have routed it through a breadboard for visibility. Could my HX711 be busted? Or my strain gauges?
Any guidance is really appreciated!

User avatar
Posts: 7806
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near The National Museum of Computing

Re: HX711 continually drifting upwards - at a loss!

Thu Feb 08, 2024 11:27 pm

Can you post a circuit diagram (not a picture of the breadboard)?
How are you plotting that graph - might it be adding results erroneously? - his github script example seems to return a single value that is the median of 35 samples.

Posts: 3
Joined: Thu Feb 08, 2024 4:58 pm

Re: HX711 continually drifting upwards - at a loss!

Fri Feb 09, 2024 5:33 pm

Thank you for replying!

For the purposes of trying to find the root cause of the incremental drift, I am not using the median of 35 samples but rather outputing every sample.

The graph was created from a txt file that I have let the script output to for the purposes of this analysis, this was then read using pandas and displayed using matplotlib and seaborn - I'm confident the graphing isn't the issue, I'm not performing any data manipulation.

I'm using a Sparkfun HX711 that has both the VCC and VDD connections:
13879-04_HX711_Breaout_Board.jpg (228.33 KiB) Viewed 136 times

I have connected the strain gauges following this diagram here. Please ignore the GPIO side from the HX711 as I'm using the connections in the original post based on the Sparkfun documentation:
gauge connections.jpeg
gauge connections.jpeg (70.09 KiB) Viewed 136 times

I re-checked my outputs from the wheatstone bridge and swapped the E+ and E-, this is what it now looks like after running for a while to see if it would stabalize. The large spike around 1000mins is my test weight of 449g being added. What's throwing me is the odd random spikes, that seems like some form of disturbance beyond regular drift. No further along!

Weight vis across 1400mins looking for stabalization:
drift visualisation over 20 hours.png
drift visualisation over 20 hours.png (26.25 KiB) Viewed 136 times

Posts: 7201
Joined: Tue Jul 02, 2019 2:28 pm

Re: HX711 continually drifting upwards - at a loss!

Fri Feb 09, 2024 5:37 pm

Excessive drift when unloaded is usually a bad load cell or connection.

Posts: 3
Joined: Thu Feb 08, 2024 4:58 pm

Re: HX711 continually drifting upwards - at a loss!

Thu Feb 22, 2024 12:50 am

Hello folks.

Thank you for your replies and help. I bought a new scale that I tested, confirming all was working. I dismantled the scale and wired it up to the circuit to find...everything worked as expected!

I've also changed to using the HX711 library from gandalf15 https://github.com/gandalf15/HX711/tree/master directly instead of the endail library. I should have tried this with my original strain gauges to confirm they were an issue but I'm pleased it's working correctly now with the new gauges. At some point I will wire the original gauges and confirm if they are an issue or not.

Here is the scale with no weight added and with a 449g weight added. You can see the large spikes to 449 but also some aberrant spikes throughout - not really an issue for my purposes but still interesting interference.
drift_21022024.png (23.77 KiB) Viewed 58 times

Here you can see a closer version of the fluctuation in the scale where I have set the 449g spikes to be capped at 5g. This fluctation is inconsequential for my purposes and more inline with the tolerance of the gauges and HX711.
drift_with_cap_at_5_21022024.png (29.36 KiB) Viewed 58 times

Thanks everyone for your help and I'll leave this here for anyone in the future that is struggling!

Return to “Troubleshooting”