bogde / HX711

An Arduino library to interface the Avia Semiconductor HX711 24-Bit Analog-to-Digital Converter (ADC) for Weight Scales.
MIT License
896 stars 538 forks source link

Library HX711 #10

Closed vejo17 closed 10 years ago

vejo17 commented 10 years ago

Hi Good night i have problem with the code that you use when i try to upload the code, the program send me this message sketch_sep07a:6: error: 'Hx711' does not name a type sketch_sep07a.ino: In function 'void setup()': sketch_sep07a:11: error: 'scale' was not declared in this scope sketch_sep07a.ino: In function 'void loop()': sketch_sep07a:16: error: 'scale' was not declared in this scope And i already uploaded the library that you put in web page

I hope can you help me with this issue.

Thanks. Regards

bogde commented 10 years ago

do you have:

include "HX711.h"

at the top of your sketch file?

are you using Hx711 scale(A1, A0); or HX711 scale(A1, A0); ?

use HX711 scale(A1, A0);

does the included example (HX711Serial) work?

vejo17 commented 10 years ago

Hi I use HX711 scale(A1, A0), but the program send me the next message:sketch_sep08b.ino: In function 'void loop()':sketch_sep08b:12: error: 'class HX711' has no member named 'getGram'.The example (HX711Serial) is working correctly. Im using this code:#include

include

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);HX711 scale(A1, A0);void setup() {lcd.begin(16, 2);}void loop() {lcd.setCursor(0, 0);lcd.print(scale.getGram(), 1);lcd.print(" g");lcd.print(" ");delay(200);} but in the blue line im having a mistake. Can you tell me how to resolve this issue ? Or if i have to use another function? And thanks for your answer Date: Sun, 7 Sep 2014 22:30:27 -0700 From: notifications@github.com To: HX711@noreply.github.com CC: lavadero_jorge@hotmail.com Subject: Re: [HX711] Library HX711 (#10)

do you have:

include "HX711.h"

at the top of your sketch file?

are you using

Hx711 scale(A1, A0);

or

HX711 scale(A1, A0);

?

use HX711 scale(A1, A0);

does the included example (HX711Serial) work?

— Reply to this email directly or view it on GitHub. =

bogde commented 10 years ago

there is no method getGram. see here for the methods you can call: https://github.com/bogde/HX711/blob/master/HX711.h

see the example for a proper usage.

r-a-i commented 5 years ago

I ran into this issue too.

The documentation on ./README.md says that in the non-blocking mode we should:

// 4. Acquire reading without blocking
if (scale.wait_ready_timeout(1000)) {...

Instead, it should say:

// 4. Acquire reading without blocking
if (loadcell.wait_ready_timeout(1000)) {...

for consistency with the definition at the start of the example HX711 loadcell;

amotl commented 5 years ago

Dear @r-a-i,

may I humbly ask for a pointer where you found this inconsistency? I just skimmed [1] and can't find any typo in there.

With kind regards, Andreas.

[1] https://github.com/bogde/HX711/tree/master/examples

amotl commented 5 years ago

may I humbly ask for a pointer

Reading things more concentrated always makes sense. Sorry again for overlooking your reference to README.md.

You are absolutely right. When fixing this, we might also think about making the example in README.md consistent with the example files referenced above, right?

Would you personally prefer scale oder loadcell as the name for a canonical variable name referencing the HX711 object? Technically, just calling it hx711 would also be fine but might confuse newcomers.

... just wanted to mention that I acknowledge we should bring more consistency into the code examples and that I am personally open for any better name if desired.

r-a-i commented 5 years ago

Dear @amotl, I just submitted a pull request for this change for your consideration.

Personally, I think the variable name "loadcell" is more generic as the "Hx711" is a loadcell amplifier. Some people may use loadcells to build "scales", but not always. In my case, I'm using a loadcell to measure a force directly and not weight.

Thank you for your consideration and all your contributions to this library.