Page 1 of 1

HX711 && getUnits() steady state reading

Posted: Sun Nov 25, 2018 4:28 pm
by Sunil
I am trying to use the library and sample code as described in
https://learn.sparkfun.com/tutorials/lo ... okup-guide
but one issue or enhancement that i would request is - either getUnits() or some new function return the 'final' weight added.

To give a short background, the project is to add or remove weight in increments (rather than just weighing it once for a object). And i would like to get the updated weight (not the current intermediate weight increments that i currently get) doing a getUnits() while trying different inputs of 5,10,20. A delay also is not helping.

It is of importance to me to have this working, so needless to say i am ready to arrange compensations.

For example, here is what my Serial output looks like when for each loop() i store the previous amount of weight change to the current one:
Checking at : 5 seconds, previous weight(gms): 0, current weight(gms): 239
Checking at : 8 seconds, previous weight(gms): 239, current weight(gms): 690
Checking at : 10 seconds, previous weight(gms): 690, current weight(gms): 689
Checking at : 13 seconds, previous weight(gms): 690, current weight(gms): 691

Thanks,
Sunil

Re: HX711 && getUnits() steady state reading

Posted: Mon Nov 26, 2018 8:42 am
by lyndon
I don't understand. Isn't the "current weight" exactly what you said you are looking for?

Re: HX711 && getUnits() steady state reading

Posted: Mon Nov 26, 2018 9:48 am
by DanV
I also don't understand.
What are you really asking for?

If you want and average of readings then get this library:
https://github.com/bogde/HX711

"5.The "get_value" and "get_units" functions can receive an extra parameter "times", and they will return the average of multiple readings instead of a single reading."

Re: HX711 && getUnits() steady state reading

Posted: Mon Nov 26, 2018 9:52 am
by Sunil
I am using the bogde library and the get_units(20) and the output you see is from that code. While the average helps, i want the function to return a value when the weight has stabilized.

Re: HX711 && getUnits() steady state reading

Posted: Mon Nov 26, 2018 10:05 am
by DanV
Code: Select all
Reading = get_units(10);
if ( abs(Reading - Prev_Reading) <= 1 ) then
   Reading_Stable = TRUE;
else
   Reading_Stable = FALSE;
   Prev_Reading = Reading;
end_if

Re: HX711 && getUnits() steady state reading

Posted: Mon Nov 26, 2018 11:03 am
by Sunil
Thanks. (in hindsight, i was over engineering it)