change timing/power handling

This commit is contained in:
Joerg Lehmann 2020-01-09 17:12:04 +01:00
parent 630c432289
commit 730904e6ba
2 changed files with 10 additions and 12 deletions

View File

@ -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());
}
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
delay(400);
for (byte i = 0; i < times; i++) {
// 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) {

View File

@ -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;