bogde / HX711

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

HX711 not thread safe? #257

Open andreash-esp opened 7 months ago

andreash-esp commented 7 months ago

Hi,

while diagnosing some rare fluations during initialisation I noticed these happen because i set up the scale in my setup() funktion and then spawn a task on core 0 to continously read the weight.

The issue can easily be triggered by reading scale.get_units from the main thread (running on core 1) and a second thread doing the same on core 0. This results in fluctuations and very slow reads from the HX711.

A valid answer might be "don't do that then", but does this observation make sense from the code point of view?

Kind Regards Andreas