calibrate with mate bottles

This commit is contained in:
interfisch 2021-02-22 20:39:44 +01:00
parent f78193556d
commit d8d002570d
1 changed files with 4 additions and 3 deletions

View File

@ -11,7 +11,8 @@
#include "HX711.h"
#define SCALE_CALIBRATION 23805 //calibrated with 2.25kg weight. devide adc reading by calibration weight (in kg) to get this value (or other way around)
//#define SCALE_CALIBRATION 23805 //calibrated with 2.25kg weight. devide adc reading by calibration weight (in kg) to get this value (or other way around)
#define SCALE_CALIBRATION 23960 //8 club mate 0.5L bottles weight 7.097kg. scale returns units=340090 with 16 bottles -> 340090/(2*7.097kg) = 23960
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = D2;
@ -295,9 +296,9 @@ bool cmdHandler(const HomieRange& range, const String& value) {
}else if (value=="calibrate") { //get raw value. use "reset" first. then adc to get value for calibration to enter in SCALE_CALIBRATION
if (scale.wait_ready_timeout(1000)) { //for non blocking mode
float _units=scale.get_units(10);
long _units=scale.get_units(10); //if set_scale was called with no parameter before, get_units has not decimals
char charBuf[13];
dtostrf(_units,6, 6, charBuf);
dtostrf(_units,2, 1, charBuf);
scaleNode.setProperty("cmd").send(charBuf);
} else {
Serial.println("HX711 not found.");