fix bug with big difference
This commit is contained in:
parent
74bca8966b
commit
a6d5d045f1
|
|
@ -12,7 +12,7 @@ BME280 bme280;
|
|||
/******************************************************************************/
|
||||
/* Firmware Version */
|
||||
/******************************************************************************/
|
||||
static const int32_t fwVersion = 20210426;
|
||||
static const int32_t fwVersion = 20210427;
|
||||
|
||||
/******************************************************************************/
|
||||
/* LoraWAN Settings */
|
||||
|
|
@ -850,12 +850,14 @@ void AddSensorDataToLoraData()
|
|||
timer_pos0 = millis();
|
||||
}
|
||||
my_position++;
|
||||
|
||||
last_sensor_reading = sensor_data;
|
||||
}
|
||||
|
||||
bool TooBigWeightChange()
|
||||
{
|
||||
// on first position there cannot be a difference
|
||||
if (my_position == 1) {
|
||||
return false;
|
||||
}
|
||||
bool big_difference = (abs(last_sensor_reading.weight - sensor_data.weight) > SEND_DIFF_THRESHOLD_5GRAMS);
|
||||
if (big_difference) {
|
||||
lora_data.weight_last = sensor_data.weight;
|
||||
|
|
@ -907,7 +909,8 @@ bool ReadSensors(bool read_only)
|
|||
if (!read_only) {
|
||||
AddSensorDataToLoraData();
|
||||
send_data = (TooBigWeightChange()) || (my_position >= MAX_VALUES_TO_SEND) || (iteration <= INIT_PACKETS) || (iteration % INIT_PACKAGE_INTERVAL == 0);
|
||||
|
||||
last_sensor_reading = sensor_data;
|
||||
|
||||
if (config_data.debug_level > 0) {
|
||||
if (send_data) {
|
||||
Serial.printf("Iteration: %d, we send the data...\n", iteration);
|
||||
|
|
|
|||
|
|
@ -67,5 +67,5 @@ $ mkdir ~/arduino-builds-saved/20210423/
|
|||
$ cp /tmp/arduino-sketch-0870BAA82DFEB3C4E076C8FBBDEB25B4/CubeCell_Board_REGION_EU868_RGB_0.cyacd ~/arduino-builds-saved/20210423/
|
||||
|
||||
Upload:
|
||||
/home/joerg/Arduino/hardware/CubeCell/CubeCell/tools/CubeCellflash/CubeCellflash -serial /dev/ttyUSB0 /home/joerg/arduino-builds-saved/20210423/CubeCell_Board_REGION_EU868_RGB_0.cyacd
|
||||
/home/joerg/Arduino/hardware/CubeCell/CubeCell/tools/CubeCellflash/CubeCellflash -serial /dev/ttyUSB0 /home/joerg/arduino-builds-saved/latest/CubeCell_Board_REGION_EU868_RGB_0.cyacd
|
||||
`
|
||||
|
|
|
|||
Loading…
Reference in New Issue