Coder Social home page Coder Social logo

Comments (2)

banoz avatar banoz commented on July 19, 2024

Did you try to call scale.power_up() after scale.begin()?

from hx711.

fenixil avatar fenixil commented on July 19, 2024

@Xarbenence
I hit the same issue today, so let me explain what's likely causing yours.
First, here is the link to the datasheet - https://www.digikey.com/htmldatasheets/production/1836471/0/0/1/hx711.html
As you can see, module can provide 10 or 80 samples per second. It needs some time to provide the value after it's started, that's why your first loop always succeeds as you wait for 1 second between iterations.
Your second loop does not have any delays, so it will exit almost immediately. You must add a delay there too.

weight = scale.get_units(); 
// ^^^^ you read the data here, so is_ready() becomes false
...
while(i<9){
if(scale.is_ready()){ // this is_ready() always fails
  long reading = scale.read();
  Serial.print("HX711 reading: ");
  Serial.println(reading);
  break;
} else {
  delay(100);
  // ^^^^ here
}

As I can see from the sources, begin() does not perform communication with the module, so it's not something that helps you here, but rather the delay at the end of the script, or something else.

I had and identical issue cause by power_up and power_down - I called power_up and expected data was available immediately. That was obviously wrong, so after I added some delay (just hardcoded 500ms to comply with Output settling time, however there are better APIs of achieving that, have a look at wait_ready_timeout and wait_ready_retry) everything got back to normal.

PS. I'd greatly appreciate if you edit your post, use github's markdown to make it look like a code and clean it up from commented code.

from hx711.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.