Closed AndhikaWB closed 2 years ago
Yes, read_raw()
is going to be the values you get without the calibrated multiple. I separated it out in the example code to show the difference, but maybe I can make it more clear in the future. I also named them raw
and weight
to make the difference clear.
In my use case, I made a script that prompts the user for input like your example and then compares the measurement to that value, queries again, etc. You really want multiple known weights and multiple queries so that your multiple is more accurate. I use a set of weights ranging from 1 gram to 100 grams.
If I have some extra time, I'll incorporate this into the codebase as an example calibration script.
I think i'll add 2 functions get_raw()
and get_weight()
which would just access the most recent measurements. The way it is now, read_raw()
will always pull a new sample, but maybe you don't want to read a new sample, you just want the latest measurement values. read_weight()
already does this if you pass in use_prev_read=True
, so I could just separate that functionality into a get
to clarify everything.
Edit: or maybe just add a use_prev_read
to the read_raw()
function? Whaddya think?
Update: I have a new script in a dev branch for this calibration process, will merge after testing. I also added an input to the read_raw
function for use_prev_read
as mentioned above.
Also adding the get
functions to double up on that functionality. This will be published as part of the next build.
You're right, I can just take the last measurement value without pulling a new sample again. Never thought of that before. The comment on use_prev_read
could be emphasized more on 'without' keyword instead of 'new' (since I don't recognize how useful it is before), but the new comment on get_raw()
and get_weight()
makes it clear enough.
Also the new branch looks fine (just by looking, I haven't tested it yet). I think I like to use get_raw()
and get_weight()
more since it doesn't require extra parameters, but use_prev_read
should stay as it may break other people's code if removed.
Thank you, I will close this.
I tested my code and made a few improvements. I also rolled that entire script into my HX711 class so that you can call hx711.run_calibration()
instead of needing to copy and write your own version of my example. The calibration example is still there and uses the run_calibration function. See ReadMe for some clarification on how that all works.
I also added the get_raw() and get_weight() functions.
The latest rev 1.2.0 includes all of this and a few other fixes.
By looking at the library source code, there's a comment like this on
set_weight_multiples()
section:How do I get this scale value? Should I use
read_raw()
,read_weight()
, or something else?On Gandalf15's original library I can achieve it using something like this:
So what's the equivalent of
get_data_mean()
in this library? (I assumeset_weight_multiples()
andset_scale_ratio()
behave similarly)I'm sorry I had to ask this, I don't have the load cell yet but I'm planning to use your library.
EDIT: My bad, I didn't check the other issue. I assume the answer is
read_raw()
?