Unstable measurements (HX711 and STM32)

Hello Forum

According to Sparkfun it should be no problem to run the HX711 with 3.3V supply (see [1]).

Nevertheless I am getting quite unstable values when reading weights (I do it every 5 minutes).

On https://beelogger.de/?page_id=3633 one of their suggestions is to replace the 20k resistor with a 12k one (arrticle is in German, sorry):

===

Modifikation HX711-Board

Modifikation zum Betrieb des HX711-Boards mit 3,3V.

Laut Datenblatt kann der HX711-Chip problemlos mit 3,3V oder 5V

betrieben werden. In der Regel ist daher diese Angabe auch bei fertigen

Boards mit diesem Chip zu finden. Wenn man sich nun intensiv mit dem

Datenblatt dieses Chips sowie den Schaltplänen dieser Boards

beschäftigt, wird man feststellen, dass diese zumeist für 5Volt-Betrieb

dimensioniert sind. Für ein optimal funktionierendes Wägesystem mit 3,3V

sind daher Anpassungen notwendig.

===

I wonder what I can do to make the readings more stable.

The load cell I use:

https://www.galoce.com/Uploads/Download … GPB100.pdf

The CPU:

STM32L082

(https://store.mcci.com/products/mcci-ca … technology)

Used Library:

https://github.com/bogde/HX711

Graph of weight readings (yesterday, constant weight so should be constant):

see attachement, I make 25 readings per measurement and calculate the median.

Best regards

Joerg Lehmann

[1]:

NOV 11, 2019 | 09:35AM MST

Chris F replied:

Hi Joerg.

Either a split supply or both on 3.3 volts will work with this sensor. If you have 5 volts available, go ahead and connect that to VCC, otherwise, connect both VCC and VDD to 3.3V.

Order Support

SparkFun Electronics, Inc.

6333 Dry Creek Parkway

Niwot, CO 80503

NOV 08, 2019 | 01:21AM MST

SparkFun replied:

Hello Chris

Thanks for your answer. I was just unsure, as there is the following

note in your documentation:

PRO TIP: In many cases, you can just short VCC and VDD together. If

your microcontroller uses 3.3V logic however, you’ll want to connect

VCC to 5V and VDD to 3.3V.

Source:

https://learn.sparkfun.com/tutorials/lo … okup-guide

Also, I have read in different places that VCC should be 5V.

Kind regards–Joerg

NOV 07, 2019 | 02:53PM MST

Chris F replied:

Hello Joerg.

The HX711 can run on any voltage between 2.7 and 5.5 volts and will work fine at 3.3 volts with no reduction in performance. You will want to connect VCC and VCC both to your 3.3 volt supply.

Hope this helps!

Order Support

SparkFun Electronics, Inc.

6333 Dry Creek Parkway

Niwot, CO 80503

So are you using both 3.3V and 5V as indicated by the discussion with Chris F on November 11? If you’re just using 3.3V, are you seeing the same margins of error as 5V?

I don’t know what HX711 board you’re using, but if you have the update rate on your HX711 set for 80SPS, try setting it for 10SPS. The extra time the HX711 spends sampling the load cells will translate into smoother readings.

You could also try taking more readings and averaging them out. That way high and low readings will even out.

Last thing you could try is to use shorter and/or shielded wire between the HX711 and load cells. EMI could be getting into the wiring causing skewed results.

Finally, make sure there isn’t noise on your power supply lines. You might even try popping a 100uF cap across VCC and GND right at the HX711’s power inputs.

If none of those work, unfortunately I don’t know what else to tell you to try.

TS-Brandon:
So are you using both 3.3V and 5V as indicated by the discussion with Chris F on November 11? If you’re just using 3.3V, are you seeing the same margins of error as 5V?

No, I am just using 3.3V (I do not have 5V available).

TS-Chris:
I don’t know what HX711 board you’re using, but if you have the update rate on your HX711 set for 80SPS, try setting it for 10SPS. The extra time the HX711 spends sampling the load cells will translate into smoother readings.

You could also try taking more readings and averaging them out. That way high and low readings will even out.

Last thing you could try is to use shorter and/or shielded wire between the HX711 and load cells. EMI could be getting into the wiring causing skewed results.

Finally, make sure there isn’t noise on your power supply lines. You might even try popping a 100uF cap across VCC and GND right at the HX711’s power inputs.

If none of those work, unfortunately I don’t know what else to tell you to try.

I am using the one from Sparkfun: https://www.sparkfun.com/products/13879

I am using it with the default sample rate of 10 SPS. I do not take the average but the median, see see https://community.particle.io/t/boron-g … o/46647/13

I cannot make the cable from the load cell to the HX711 shorter. What I could try is to use a capacitor (first time I hear such a recommendation, but it is worthwhile to try…).

I found a discussion about this topic here:

https://community.hiveeyes.org/t/stromv … 711/893/16

The outcome is (at least what they recommend) to do the following:

  • replace the 8.2k resistor with a 20k one (use the one that is already present)

  • instead of the former 20k resistor, use a 22k one

What do you think?

I don’t know if that would work, but if you’d like to try, go ahead. It might be a lot easier to solve this issue in software though. If you’re not expecting the values to change much between measurements, averaging your readings would probably work. You could even reject any readings that are significantly different from what you expect before averaging to get better results.

I am not sure this can be solved in software. I already calculate the median (the median, not the average) of 25 readings. The problem is also: it is a a beehive scale, so it can be normal that there is a big change (when the bees swarm out).

Can we get a little more resolution on the image? I can’t quite read the values on the graph axes.

Please find attached the values as CSV .

hx711-readings-9feb2020.csv (4.68 KB)

Are those the raw A/D values based on the 24 bit output?

Some amount of noise is always going to be present.

Which capacity GPB100 load cell is being used?

When loaded with a known mass/force, what are the typical A/D values?

The GPB100 is the 100kg model.

It is a bit more complicated, though: I am using two of those GPB100, one is connected to channel A, the other to channel B. The values are not raw values, but values in gram.

I agree that there is always some noise, but I would never expext that much (maximum is almost 2.5% more than minimum, and this is after the “median-filter”).

If it’s grams, then I agree there’s a larger problem.

Do you have a meter capable of measuring the millivolt response from the cells?

It would be useful to make sure that instrumentation not in fact measuring correctly and the load cell outputs are swinging.

Similarly, you can build a simple load cell simulator and see whether the calibrated values stabilize.

For a quick test, you don’t even need the potentiometer shown in a lot of the example schematics, just a few resistors to feed the signal inputs with a couple millivolts.

I just ordered an oscilloscope to be able see what’s going on… Should get it in the coming days. I now also have resistors (22k and 20k) and capacitors (100uF) ready, of course I would prefer not to have to change the resistors on the sparkfun breakout board.

I got my oscilloscope today and first thing I did is take a measurement of VDD/VCC versus GND (see hx711_vdd_gnd.png). I am a bit surprised about the noise I see (there seem to be short peaks every 40 milliseconds). VDD is switched on by software on the MCCI 4610 (VOUT1). The picture shows one such cycle (turn on - measure - turn off).

This is what I did on the HX711 and it looks like it helps:

  • Remove Resistor R5 (10k) - this one only to save power, I do not use 80SPS

  • Replace Resistor R1 (20k) with 22k

  • Replace Resistor R2 (8.2k) with 20k

This is thanks to https://community.hiveeyes.org/t/stromv … 711/893/17

Perhaps a moving average could help you for the smoothing. The picture below is your data with an 8-value window average.

rolling avg - smoothing.png

@languer: thanks for your advise. But the measurements are much better since I made the hardware change mentioned above (replace R1 and R2). Also, I already read 25 values and calculate the median. Also, as it is a beehive scale, I send out alerts when the weight loss is too high (>750 grams). This does not work in a timely manner if I use a moving average.

@Sparkfun: when you create a new revision of https://www.sparkfun.com/products/13879 , can you consider to look again at the values of R1/R2 and also in a better way to get rid of the power consumption of R5 (when not using 80SPS)?