I think this could be because I'm printing a u16 when it should be i16

This commit is contained in:
2023-10-31 21:46:36 +00:00
parent 7b29ea24db
commit 0bbae8a254

View File

@@ -75,14 +75,48 @@ void read_from_dht22() {
} else {
latest_datapoint.temp = dht22_temperature();
latest_datapoint.rh = dht22_relative_humidity();
ESP_LOGW(TAG, "temperature: %f & relative humidity: %f",
latest_datapoint.temp / 10.0, latest_datapoint.rh / 10.0 );
if (has_ntp_time_obtained_once()) {
// I _think_ I only want to be doing that rolling average and saving
// if/when we've got an actual time to do that with. I think that'd
// avoid some weird bugs (e.g. time changing from 1970 -> current time within
// a 10 min period or just saving data saying it's from the 70s)
/*
* Appears to be a bug when hitting num samples = 64
* Here's a log:
W (327852) YASPAM: temperature: 19.500000 & relative humidity: 64.000000
W (327852) YASPAM: ten_minute_average.temp: 195, num_samples: 62
W (332862) YASPAM: temperature: 19.400000 & relative humidity: 64.100000
W (332862) YASPAM: ten_minute_average.temp: 2309, num_samples: 63
W (337872) YASPAM: temperature: 19.500000 & relative humidity: 64.300000
W (337872) YASPAM: ten_minute_average.temp: 18919, num_samples: 64
W (342882) YASPAM: temperature: 19.400000 & relative humidity: 64.200000
W (342882) YASPAM: ten_minute_average.temp: 18626, num_samples: 65
W (347892) YASPAM: temperature: 19.500000 & relative humidity: 64.400000
W (347892) YASPAM: ten_minute_average.temp: 34474, num_samples: 66
W (352902) YASPAM: temperature: 19.300000 & relative humidity: 64.300000
W (352912) YASPAM: ten_minute_average.temp: 34947, num_samples: 67
W (357912) YASPAM: temperature: 19.300000 & relative humidity: 64.500000
W (357912) YASPAM: ten_minute_average.temp: 35406, num_samples: 68
W (362922) YASPAM: temperature: 19.400000 & relative humidity: 64.600000
W (362922) YASPAM: ten_minute_average.temp: 35851, num_samples: 69
Another log - suggesting it's not to do with 64:
I (387992) YASPAM: ten_minute_average.temp: 187, num_samples: 74
W (392992) YASPAM: temperature: 18.700000 & relative humidity: 69.900000
I (393002) YASPAM: ten_minute_average.temp: 187, num_samples: 75
W (398002) YASPAM: temperature: 18.600000 & relative humidity: 69.900000
I (398012) YASPAM: ten_minute_average.temp: 53489, num_samples: 76
W (403012) YASPAM: temperature: 18.800000 & relative humidity: 69.900000
I (403022) YASPAM: ten_minute_average.temp: 53649, num_samples: 77
W (408022) YASPAM: temperature: 18.700000 & relative humidity: 69.800000
I (408032) YASPAM: ten_minute_average.temp: 53805, num_samples: 78
W (413032) YASPAM: temperature: 18.800000 & relative humidity: 69.600000
Something overrunning and stomping on my bits?
*/
if (num_samples_last_ten_mins == 0) {
ten_minute_rolling_average.rh = latest_datapoint.rh;
@@ -96,7 +130,8 @@ void read_from_dht22() {
num_samples_last_ten_mins;
}
num_samples_last_ten_mins += 1;
ESP_LOGD(TAG, "ten_minute_average.temp: %"PRIu16", num_samples: %"PRIu32, ten_minute_rolling_average.temp, num_samples_last_ten_mins);
ESP_LOGI(TAG, "latest_datapoint.temp: %"PRIi16, latest_datapoint.temp);
ESP_LOGI(TAG, "ten_minute_average.temp: %"PRIi16", num_samples: %"PRIu32, ten_minute_rolling_average.temp, num_samples_last_ten_mins);
// This should be: if (10 minutes of sample taken)
// TODO: check max samples / second that can fit in 10 minutes