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

Sketch lockup when using constructor with the parameters and HX711 not connected #76

Open
Petorrr opened this issue Jul 28, 2017 · 3 comments

Comments

@Petorrr
Copy link

Petorrr commented Jul 28, 2017

When using the constructor to initialize the class with parameter passing, the system locks up when my sensor board is not connected. I found out that this is caused by the 'read' function that is called through the set_gain/begin calls. The while loop in that function stays there forever, thus hanging the system since the system is not yet through it's setup.

Just a proposed improvement, that will make the read more robust against 'hanging' in a loop;

byte retry = 0;

// wait for the chip to become ready
while (!is_ready() && retry < 20)
{
	delay (10);
	retry++;
	// Will do nothing on Arduino but prevent resets of ESP8266 (Watchdog Issue)
	yield();
}
if (retry >= 20)
  return (0);
@lewsut
Copy link

lewsut commented Dec 22, 2018

This absolutely solves the stuck in the while loop I was having when the scales were disconnected or failed.

@amotl
Copy link
Contributor

amotl commented Feb 19, 2019

Dear Peter,

while working on #125 in the aftermath of #123, we just added your wait-for-readyness-with-retry implementation to our spring-cleaning branch by 87727e0.

The corresponding HX711_retry_example.ino uses the new wait_ready_retry() function originally coming from your suggestion.

With kind regards,
Andreas.

@gjt211
Copy link

gjt211 commented Mar 15, 2020

I think I am having the same problem using the most recent version of code. If I power up the board without the HX711 connected it locks up.

scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);

I can't work out how to fix this issue, it would be good if the scale.begin could timeout and return a success or fail.

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

4 participants