From 730904e6ba5ae244bdae59d629e857310681ac67 Mon Sep 17 00:00:00 2001 From: Joerg Lehmann Date: Thu, 9 Jan 2020 17:12:04 +0100 Subject: [PATCH] change timing/power handling --- mini-beieli-node.ino | 13 +++++++------ mini_beieli_node.h | 9 +++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/mini-beieli-node.ino b/mini-beieli-node.ino index aa5e7d2..b8d90f9 100644 --- a/mini-beieli-node.ino +++ b/mini-beieli-node.ino @@ -536,7 +536,6 @@ void DoDeepSleep(uint32_t sleep_time) } } -// highest and lowest value will be ignored long my_read_average(byte gain, byte times) { // highest and lowest value will be ignored long sum = 0; @@ -547,13 +546,14 @@ long my_read_average(byte gain, byte times) { if (config_data.debug_level > 0) { gCatena.SafePrintf("%010d - my_read_average, measurements: ", millis()); } + + LoadCell.set_gain(gain); + // we wait 400ms (settling time according HX711 datasheet @ 10 SPS + delay(400); + for (byte i = 0; i < times; i++) { - delay(WAITTIMELOADSAMPLES * 1000); - LoadCell.power_up(); - LoadCell.set_gain(gain); - delay(2); // wait for stabilizing + // we wait 400ms (settling time according HX711 datasheet @ 10 SPS) v = LoadCell.read(); - LoadCell.power_down(); if (L > v) L = v; // find lowest value if (H < v) H = v; // find highest value @@ -562,6 +562,7 @@ long my_read_average(byte gain, byte times) { gCatena.SafePrintf("%d ", v); } gCatena.poll(); + delay(WAITTIMELOADSAMPLES); } res = (sum - L - H) / (times - 2); if (config_data.debug_level > 0) { diff --git a/mini_beieli_node.h b/mini_beieli_node.h index 1b77f76..f12866a 100644 --- a/mini_beieli_node.h +++ b/mini_beieli_node.h @@ -55,13 +55,10 @@ enum { | \****************************************************************************/ -static const int32_t fwVersion = 20200107; +static const int32_t fwVersion = 20200109; -// wait between samples -// 3 sec is a good delay so that load cell did not warm up -// too much and external random influences like wind has time -// to go so that the next sample is more valid -const int WAITTIMELOADSAMPLES = 3; +// wait between samples in milliseconds +const int WAITTIMELOADSAMPLES = 100; static const byte INIT_PACKAGE_INTERVAL = 100; // send an init package every 100 packages; static const byte MAX_VALUES_TO_SEND = 8;