Skip to content

Commit ae43557

Browse files
committed
increase sensor sample count to improve data accuracy and enhance warning messages for sample failures
1 parent 929d016 commit ae43557

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/sensors_task.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::{
2121
const USB_CHARGING_VOLTAGE: u16 = 4200;
2222
const DHT11_WARMUP_DELAY_MILLISECONDS: u64 = 2000;
2323
const SENSOR_WARMUP_DELAY_MILLISECONDS: u64 = 50;
24-
const SENSOR_SAMPLE_COUNT: usize = 5;
24+
const SENSOR_SAMPLE_COUNT: usize = 6;
2525

2626
pub struct SensorPeripherals {
2727
pub dht11_digital_pin: GpioPin<1>,
@@ -140,7 +140,10 @@ pub async fn sensor_task(
140140
.push(Sensor::AirHumidity(avg_air_humidity))
141141
.expect("Too many samples");
142142
} else {
143-
warn!("Unable to generate average value of air humidity");
143+
warn!(
144+
"Unable to generate average value of air humidity - we had {} samples",
145+
air_humidity_samples.len()
146+
);
144147
}
145148

146149
if let Some(avg_air_temperature) = calculate_average(&mut air_temperature_samples) {
@@ -150,7 +153,10 @@ pub async fn sensor_task(
150153
.push(Sensor::AirTemperature(avg_air_temperature))
151154
.expect("Too many samples");
152155
} else {
153-
warn!("Unable to generate average value of air temperature");
156+
warn!(
157+
"Unable to generate average value of air temperature, we had {} samples",
158+
air_temperature_samples.len()
159+
);
154160
}
155161

156162
if let Some(avg_water_level) = calculate_average(&mut water_level_samples) {

0 commit comments

Comments
 (0)