Building avaerages; Configreader database user and pw

This commit is contained in:
2017-09-07 15:09:45 +00:00
parent c2b7c1eed7
commit f4d1f248f7
8 changed files with 118 additions and 0 deletions

View File

@@ -88,6 +88,37 @@ int main(void) {
}
}
//build averages from all indoor/all outdoor sensors
float avtemp_in = 0.0, avhum_in = 0.0;
float avtemp_out = 0.0, avhum_out = 0.0;
int inCount = 0, outCount = 0;
for (j = 0; j < nodecount; j++) {
if (nodedata[j].isoutside == 0) {
//This node is a indoor node
avtemp_in += nodedate[j].temperature;
avhum_in += nodedata[j].humidity;
inCount++;
} else {
//This node is a outdoor node
avtemp_out += nodedate[j].temperature;
avhum_out += nodedata[j].humidity;
outCount++;
}
}
//Do the math
float avgInsideTemperature = avtemp_in / inCount;
float avgInsideHumidity = avhum_in / inCount;
float avgOutsideTemperature = avtemp_in / outCount;
float avgOutsideHumidity = avhum_in / outCount;
//Insert the results into the database
insertDataAverages(avgInsideTemperature, avgInsideHumidity, absoluteHumidityFloat(avgInsideTemperature, avgInsideHumidity));
insertDataAverages(avgOutsideTemperature, avgOutsideHumidity, absoluteHumidityFloat(avgOutsideTemperature, avgOutsideHumidity));
//free
//freeNodeLinkedList(nodes.next);
cfgdestroy();