From 3028836e2f488feefca929a3488e866d41553ae3 Mon Sep 17 00:00:00 2001 From: Joerg Lehmann Date: Mon, 29 Jun 2020 16:54:59 +0200 Subject: [PATCH] try to make measurements more stable... --- README.md | 4 ++-- mini-beieli-node.ino | 12 +++++++++--- mini_beieli_node.h | 2 +- mini_beieli_node_nau7802.h | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 33b1c75..2fcec8f 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,9 @@ Das sind die verwendeten Libraries [1]: | --- | ----- | ----------- | | https://github.com/mcci-catena/Adafruit_BME280_Library.git | 3dafbe1 | Wed, 13 Dec 2017 13:56:30 -0500 | | https://github.com/mcci-catena/Adafruit_Sensor.git | f2af6f4 | Tue, 1 Sep 2015 15:57:59 +0200 | -| https://github.com/mcci-catena/arduino-lmic.git | 6fe04ec | Tue, 12 May 2020 09:16:47 -0400 | +| https://github.com/mcci-catena/arduino-lmic.git | 1964dcf | Mon, 22 Jun 2020 10:54:56 -0400 | | https://github.com/mcci-catena/arduino-lorawan.git | 4bc0d48 | Sat, 9 May 2020 12:38:28 -0400 | -| https://github.com/mcci-catena/Catena-Arduino-Platform.git | cdbb111 | Thu, 11 Jun 2020 14:56:40 +0530 | +| https://github.com/mcci-catena/Catena-Arduino-Platform.git | 478ad23 | Fri, 26 Jun 2020 18:39:01 -0400 | | https://github.com/mcci-catena/Catena-mcciadk.git | a428006 | Sat, 21 Dec 2019 20:45:26 -0500 | | https://github.com/mcci-catena/MCCI_FRAM_I2C.git | f0a5ea5 | Sat, 21 Dec 2019 16:17:01 -0500 | | https://github.com/tatobari/Q2-HX711-Arduino-Library.git | ccda8d8 | Wed, 13 Mar 2019 12:41:44 -0300 | diff --git a/mini-beieli-node.ino b/mini-beieli-node.ino index a32bc6c..09e9bce 100644 --- a/mini-beieli-node.ino +++ b/mini-beieli-node.ino @@ -679,13 +679,14 @@ void StartNewIteration() { // we send data the first time the system is started, when the array is full // or when the weight has fallen more than threshold or the first measurement is // more than one hour old (which should not happen :-) ) - if ( (next_package_is_init_package) || (my_position >= MAX_VALUES_TO_SEND) || ((my_position > 1) && (abs(last_sensor_reading.weight - current_sensor_reading.weight) > SEND_DIFF_THRESHOLD_5GRAMS)) || ((millis() - timer_pos0) > 3600000)) { + bool big_difference = (abs(last_sensor_reading.weight - current_sensor_reading.weight) > SEND_DIFF_THRESHOLD_5GRAMS); + if ( (next_package_is_init_package) || (my_position >= MAX_VALUES_TO_SEND) || ((my_position > 1) && big_difference) || ((millis() - timer_pos0) > 3600000)) { lora_data.offset_last_reading = (uint8_t)((millis() - timer_pos0) / 1000 / 60); if (config_data.debug_level > 0) { gCatena.SafePrintf("startSendingUplink(), my_position: %d, iteration: %d, package_counter: %d\n", my_position, iteration, package_counter); } // the first packets are "Init-Packets" or each INIT_PACKAGE_INTERVAL ... - startSendingUplink(next_package_is_init_package); + startSendingUplink(next_package_is_init_package, big_difference); next_package_is_init_package = ((iteration < INIT_PACKETS) || ((package_counter % INIT_PACKAGE_INTERVAL) == 0)); if (config_data.debug_level > 1) { @@ -791,7 +792,7 @@ void StartNewIteration() { } } -void startSendingUplink(bool firstTime) +void startSendingUplink(bool firstTime, bool confirmed) { send_in_progress = true; @@ -815,6 +816,11 @@ void startSendingUplink(bool firstTime) fConfirmed = true; } + // we can overwrite fConfirmed + if (confirmed) { + fConfirmed = true; + } + if (firstTime) { if (config_data.debug_level > 0) { gCatena.SafePrintf("SendBuffer firstTime\n"); diff --git a/mini_beieli_node.h b/mini_beieli_node.h index 39739ac..e32c7d7 100644 --- a/mini_beieli_node.h +++ b/mini_beieli_node.h @@ -56,7 +56,7 @@ enum { | \****************************************************************************/ -static const int32_t fwVersion = 20200611; +static const int32_t fwVersion = 20200629; static const byte INIT_PACKAGE_INTERVAL = 100; // send an init package every 100 packages; static const byte MAX_VALUES_TO_SEND = 8; diff --git a/mini_beieli_node_nau7802.h b/mini_beieli_node_nau7802.h index 3e3ad03..88bacbb 100644 --- a/mini_beieli_node_nau7802.h +++ b/mini_beieli_node_nau7802.h @@ -102,12 +102,14 @@ long ReadScale(char channel) if ((millis() - mytimer) > 10000) { // Timeout reading scale... Wire.endTransmission(true); + delay(50); + InitializeScales(); if (debug_level > 0) { gCatena.SafePrintf("Timeout while reading scale...\n"); } break; } - delay(1); + delay(50); } long reading; if (myScale.available()) { @@ -117,7 +119,7 @@ long ReadScale(char channel) if (debug_level > 0) { gCatena.SafePrintf("Reading: %d\n", reading); } - delay(10); + delay(50); } long duration = millis() - startTime;