From d8d002570de80a06ae60b1e4c2e2ca33cbe5b6f7 Mon Sep 17 00:00:00 2001 From: Fisch Date: Mon, 22 Feb 2021 20:39:44 +0100 Subject: [PATCH] calibrate with mate bottles --- src/main.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f8c4f0a..764392c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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.");