I think it's working!
I could try round the float...
This commit is contained in:
101
main/main.c
101
main/main.c
@@ -78,106 +78,8 @@ void read_from_dht22() {
|
|||||||
latest_datapoint.temp = dht22_temperature();
|
latest_datapoint.temp = dht22_temperature();
|
||||||
latest_datapoint.rh = dht22_relative_humidity();
|
latest_datapoint.rh = dht22_relative_humidity();
|
||||||
|
|
||||||
|
// No point collecting rolling average if we don't know what the time is
|
||||||
if (has_ntp_time_obtained_once()) {
|
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)
|
|
||||||
/*
|
|
||||||
There is a bug _somewhere_
|
|
||||||
|
|
||||||
First 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:
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
Another log where it corrected itself (decided to print the decitemp
|
|
||||||
rather than float):
|
|
||||||
|
|
||||||
I (22231) YASPAM: latest_datapoint.temp: 188
|
|
||||||
I (22231) YASPAM: ten_minute_average.temp: 188, num_samples: 1
|
|
||||||
I (27241) YASPAM: latest_datapoint.temp: 188
|
|
||||||
I (27241) YASPAM: ten_minute_average.temp: 188, num_samples: 2
|
|
||||||
I (32251) YASPAM: latest_datapoint.temp: 188
|
|
||||||
I (32251) YASPAM: ten_minute_average.temp: 188, num_samples: 3
|
|
||||||
I (37261) YASPAM: latest_datapoint.temp: 187
|
|
||||||
I (37261) YASPAM: ten_minute_average.temp: 22033, num_samples: 4
|
|
||||||
I (42271) YASPAM: latest_datapoint.temp: 187
|
|
||||||
I (42271) YASPAM: ten_minute_average.temp: 16571, num_samples: 5
|
|
||||||
I (47281) YASPAM: latest_datapoint.temp: 187
|
|
||||||
I (47281) YASPAM: ten_minute_average.temp: 26401, num_samples: 6
|
|
||||||
I (52291) YASPAM: latest_datapoint.temp: 187
|
|
||||||
I (52291) YASPAM: ten_minute_average.temp: 186, num_samples: 7
|
|
||||||
I (57301) YASPAM: latest_datapoint.temp: 187
|
|
||||||
I (57301) YASPAM: ten_minute_average.temp: 186, num_samples: 8
|
|
||||||
I (62311) YASPAM: latest_datapoint.temp: 188
|
|
||||||
I (62311) YASPAM: ten_minute_average.temp: 186, num_samples: 9
|
|
||||||
|
|
||||||
I think someone might be stomping on my bits perhaps?
|
|
||||||
|
|
||||||
There's potentially a bug with the average temp calculation (or storing)
|
|
||||||
I (152421) YASPAM: latest_datapoint.temp: 187
|
|
||||||
I (152421) YASPAM: ten_minute_average.temp: 187, num_samples: 27
|
|
||||||
I (157431) YASPAM: latest_datapoint.temp: 188
|
|
||||||
I (157431) YASPAM: ten_minute_average.temp: 187, num_samples: 28
|
|
||||||
I (162441) YASPAM: latest_datapoint.temp: 188
|
|
||||||
I (162441) YASPAM: ten_minute_average.temp: 187, num_samples: 29
|
|
||||||
... increase temperature for a while
|
|
||||||
I (558231) YASPAM: latest_datapoint.temp: 246
|
|
||||||
I (558231) YASPAM: ten_minute_average.temp: 187, num_samples: 108
|
|
||||||
I (563241) YASPAM: latest_datapoint.temp: 245
|
|
||||||
I (563241) YASPAM: ten_minute_average.temp: 187, num_samples: 109
|
|
||||||
I (568241) YASPAM: latest_datapoint.temp: 244
|
|
||||||
I (568241) YASPAM: ten_minute_average.temp: 187, num_samples: 110
|
|
||||||
... no change in average
|
|
||||||
I (618321) YASPAM: latest_datapoint.temp: 234
|
|
||||||
I (618321) YASPAM: ten_minute_average.temp: 187, num_samples: 120
|
|
||||||
W (618331) YASPAM: 10 minutes of samples collected. Average temp: 187
|
|
||||||
I (623331) YASPAM: latest_datapoint.temp: 233
|
|
||||||
I (623331) YASPAM: ten_minute_average.temp: 233, num_samples: 1
|
|
||||||
I (628331) YASPAM: latest_datapoint.temp: 231
|
|
||||||
I (628331) YASPAM: ten_minute_average.temp: 231, num_samples: 2
|
|
||||||
I (633341) YASPAM: latest_datapoint.temp: 231
|
|
||||||
I (633341) YASPAM: ten_minute_average.temp: 231, num_samples: 3
|
|
||||||
I (638341) YASPAM: latest_datapoint.temp: 229
|
|
||||||
I (638341) YASPAM: ten_minute_average.temp: 22075, num_samples: 4
|
|
||||||
I (643351) YASPAM: latest_datapoint.temp: 228
|
|
||||||
I (643351) YASPAM: ten_minute_average.temp: 16613, num_samples: 5
|
|
||||||
|
|
||||||
^ Did capture 10 mins of samples though! And appears to reset correctly.
|
|
||||||
|
|
||||||
I think the problem is with the integer math truncating any changes properly...
|
|
||||||
Or something weird like that - I forgot how careful to be around dividing with integers
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (num_samples_last_ten_mins == 0) {
|
if (num_samples_last_ten_mins == 0) {
|
||||||
relative_humidity_tmp = latest_datapoint.rh;
|
relative_humidity_tmp = latest_datapoint.rh;
|
||||||
temperature_tmp = latest_datapoint.temp;
|
temperature_tmp = latest_datapoint.temp;
|
||||||
@@ -217,6 +119,7 @@ Or something weird like that - I forgot how careful to be around dividing with i
|
|||||||
// TODO check this conversion just works
|
// TODO check this conversion just works
|
||||||
ten_minute_average.temp = temperature_tmp;
|
ten_minute_average.temp = temperature_tmp;
|
||||||
ten_minute_average.rh = relative_humidity_tmp;
|
ten_minute_average.rh = relative_humidity_tmp;
|
||||||
|
ESP_LOGW(TAG, "ten_min_avg.temp %" PRIi16 ", .rh %" PRIu16, ten_minute_average.temp, ten_minute_average.rh);
|
||||||
|
|
||||||
// TODO: Write the data out somewhere - into RAM maybe
|
// TODO: Write the data out somewhere - into RAM maybe
|
||||||
// TODO: maybe push the data somewhere - or put a flag up that data
|
// TODO: maybe push the data somewhere - or put a flag up that data
|
||||||
|
|||||||
Reference in New Issue
Block a user