How to use the HX711 24 bit ADC for weight scales?

Max. 150kg     d = 100g

For this, it would probably suffice to multiply a reading in kilograms by 10, hence preserving 1 decimal, as the accuracy is just 100 gram or 0.1 kg anyway.

But multiplying by 10 would allow an unsigned 16 bits integer to hold a maximum of 6553.5 kg, which is way above the scale’s maximum. So, if the float reading is in kilograms, one could still preserve 2 decimals (multiply by 100, just like in the code above), yielding a maximum of 655.35 kg which is still way above the scale’s maximum. A single 8 bits byte, with a maximum of 255, would be too small to hold the maximum of 149.9 kg with one decimal though.

To detect negative weight values (probably indicating a calibration error), it’s even better to send a 16 bits signed integer (int16_t), which supports -32768 up to 32767, hence a maximum of 327.67 kg with two decimals. Like noted earlier, that needs sign extension when decoding negative values in a payload function.

1 Like