olkal/HX711_ADC

Issue with tare timeout in startMultiple()

alejo9719 opened this issue · 1 comments

Hi,

I've found an issue in the startMultiple() function(s) of your library. At the beginning of the function (lines 86 and 135), the timeout for the tare completion is initialized as:

static unsigned long timeout = millis() + tareTimeOut;

This makes the timeout variable to be set the first time the startMultiple() function is executed. So, it assumes the tare completion has to occur tareTimeOut milliseconds after that first execution. Nevertheless, since the function executes some conversions (update()) continuously during the stabilization time, before the tare is triggered (doTare is set), it is possible (and frequent) that the timeout has already completed even before triggering the tare. This causes the tareTimeoutFlag to be set in situations it shouldn't.

To solve the issue, I think moving the timeout initialization line (as is, keeping the "static") just before doTare = 1 (lines 106 and 157) should suffice.

P.S. I'm too lazy right now to make a pull request.

olkal commented

Thanks! The proposed fix has been implemented in release 1.2.1.