HX711 && getUnits() steady state reading

For the discussion of Arduino related topics.

Moderator: phalanx

Post Reply
Sunil
Posts: 3
Joined: Wed Nov 07, 2018 5:23 pm

HX711 && getUnits() steady state reading

Post by Sunil » Sun Nov 25, 2018 4:28 pm

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

lyndon
Support Volunteer
Posts: 1629
Joined: Thu Jul 17, 2008 6:37 pm
Location: Minnesota, USA

Re: HX711 && getUnits() steady state reading

Post by lyndon » Mon Nov 26, 2018 8:42 am

I don't understand. Isn't the "current weight" exactly what you said you are looking for?

User avatar
DanV
Posts: 390
Joined: Sat Apr 25, 2015 9:29 am

Re: HX711 && getUnits() steady state reading

Post by DanV » Mon Nov 26, 2018 9:48 am

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."

Sunil
Posts: 3
Joined: Wed Nov 07, 2018 5:23 pm

Re: HX711 && getUnits() steady state reading

Post by Sunil » Mon Nov 26, 2018 9:52 am

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.

User avatar
DanV
Posts: 390
Joined: Sat Apr 25, 2015 9:29 am

Re: HX711 && getUnits() steady state reading

Post by DanV » Mon Nov 26, 2018 10:05 am

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

Sunil
Posts: 3
Joined: Wed Nov 07, 2018 5:23 pm

Re: HX711 && getUnits() steady state reading

Post by Sunil » Mon Nov 26, 2018 11:03 am

Thanks. (in hindsight, i was over engineering it)

Post Reply