Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should function "scale.tare();" need a parameter? #244

Open
mianqi2016 opened this issue Sep 3, 2022 · 2 comments
Open

Should function "scale.tare();" need a parameter? #244

mianqi2016 opened this issue Sep 3, 2022 · 2 comments

Comments

@mianqi2016
Copy link

I tested the example "HX711_full_example", in line 49, it was:
scale.tare(); // reset the scale to 0
I found it was same in example on github, my question are:

  1. due to the function's prototype in header file, there should be a parameter in the calling, even it was "0", and not be null?
    `void HX711::tare(byte times) {
    double sum = read_average(times);
    set_offset(sum);
    }
  2. since the function's prototype has "set_offset(sum);" inside, so the comment should be "reset the offset to 0"?
@ThierryChatGarou
Copy link

For 1: A default arguments was defined as void tare(byte times = 10); in the header file. So even if you call scale.tare(); with no argument still valid.
For 2: I believe the current comment is correct. Calling Tare sets the scale to Zero, but doesn't mean the OFFSET is set to Zero.
The subtraction of the read value minus the OFFSET is what makes your get_value() or get_units() function give zero.

@banoz
Copy link

banoz commented May 14, 2023

Currently there's an issue with the tare method described here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants