Skip to content
forked from bogde/HX711

An Arduino library to interface the Avia Semiconductor HX711 24-Bit Analog-to-Digital Converter (ADC) for Weight Scales.

License

Notifications You must be signed in to change notification settings

ecomatesrick/HX711

 
 

Repository files navigation

Checkout README from original repor here: https://github.com/bogde/HX711

As the original implementation is blocking. This fork has been made to create an unblocking version of the lib.

long HX711::read() {

	// Wait for the chip to become ready.
	//wait_ready();
[...]

the blocking HX711:wait_ready()-method has been commented out of HX711:read().

The user has to check for readiness manually.

Before calling get_units(), tare(), read() or any other method that will end up calling read() call one of te two unblocking methods to check if chip is ready:

bool HX711::wait_ready_retry(int retries, unsigned long delay_ms) {
	// Wait for the chip to become ready by
	// retrying for a specified amount of attempts.
	// https://github.com/bogde/HX711/issues/76
	int count = 0;
	while (count < retries) {
		if (is_ready()) {
			return true;
		}
		delay(delay_ms);
		count++;
	}
	return false;
}
bool HX711::wait_ready_timeout(unsigned long timeout, unsigned long delay_ms) {
	// Wait for the chip to become ready until timeout.
	// https://github.com/bogde/HX711/pull/96
	unsigned long millisStarted = millis();
	while (millis() - millisStarted < timeout) {
		if (is_ready()) {
			return true;
		}
		delay(delay_ms);
	}
	return false;
}

WARNING!!! If the readiness is not checked manually in advance, completely wrong values are returned.

About

An Arduino library to interface the Avia Semiconductor HX711 24-Bit Analog-to-Digital Converter (ADC) for Weight Scales.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 86.6%
  • Makefile 12.3%
  • CMake 1.1%