olkal / HX711_ADC

Arduino library for the HX711 24-bit ADC for weight scales
MIT License
235 stars 124 forks source link

function for re-calibrating within a sketch #37

Closed olkal closed 4 years ago

olkal commented 4 years ago

Building a dual weight with individual HX711 sensors, but need a function for re-calibrating bouth sensors individually within a sketch. When using the Calibration Sketch, I can get the raw number using getData(), but are not able to retreive this inside a sketch. Then I only get the calibrated number.. Tried getTareOffset(), but it's not the same as what I get using getData() in the calibration sketch. How can I easily re-calibrate HX711 (not just setting a new setCalFactor()) using two individual sensors within the Read_2x_load_cell.ino sketch?

_Originally posted by @msevland in https://github.com/olkal/HX711_ADC/issues/33#issuecomment-612899943_

olkal commented 4 years ago

Hi, If you want to use the method described in the calibration.ino example, you will need to reset the calFactor first: LoadCell.setCalFactor(1.0);

However, you can also re-calibrate using the following method (code not tested, but I hopefully it works):

olkal commented 4 years ago

In latest release 1.2.0 there are a new function "getNewCalibration(float known_mass)" related to this issue. See updated example file "Calibration.ino" for how to use.