The function hx711_read_average from the HX711 driver computes the average by dividing the accumulate value data by the average times, which is of type size_t (unsigned). For positive values the average value is as expected but for negative values the dividend is considered unsigned and the readings loop to large values (850604851). Simply casting times as unsigned fixes the issue. Currently building for ESP32-C3.
Which SDK are you using?
esp-idf
Which version of SDK are you using?
master (fca4578cf5aca8a9d0947343a570f563d26afe3c)
Which build target have you used?
[ ] esp32
[ ] esp32s2
[ ] esp32s3
[ ] esp32c2
[ ] esp8266
[X] other
Component causing the issue
hx711
Anything in the logs that might be useful for us?
No response
Additional information or context
No response
Confirmation
[X] This report is not a question nor a request for drivers.
The issue
The function
hx711_read_average
from the HX711 driver computes the average by dividing the accumulate valuedata
by the averagetimes
, which is of typesize_t
(unsigned). For positive values the average value is as expected but for negative values the dividend is considered unsigned and the readings loop to large values (850604851). Simply castingtimes
as unsigned fixes the issue. Currently building for ESP32-C3.Which SDK are you using?
esp-idf
Which version of SDK are you using?
master (fca4578cf5aca8a9d0947343a570f563d26afe3c)
Which build target have you used?
Component causing the issue
hx711
Anything in the logs that might be useful for us?
No response
Additional information or context
No response
Confirmation