#include short ten_min = 0, value, i = 0, c = 0, high = -100, low = 100; short ten_avg[144]; //6 10 min increments in each hour * 24 hours needed int total = 0, count = 0; LM75A lm75a_sensor(false,false,false); //initializes A0, A1, A2 pins on chip, would be true without PCB int ten (int i, short ten_min, short ten_avg[], int count) //ten minute average computation function { if(count%600 == 0) //number of values measured in 10 minutes { ten_avg[i] = ten_min/600; //600 is number of measurements in 10 minutes i++; ten_min = 0; } return i; } void overall (int count, short ten_avg[], int total, short high, short low) //final report printing function { Serial.println("Averages Every 10 Minutes in Celcius: "); for(i = 0; i < count/600; i++) //makes only measured ten minute averages print { Serial.println(ten_avg[i]); } Serial.println(); Serial.print("High: "); Serial.print(high); Serial.println(" °C"); Serial.print("Low: "); Serial.print(low); Serial.println(" °C"); Serial.println(); Serial.print("Overall Average: "); Serial.print(total/count); Serial.println(" °C"); } void setup() { // put your setup code here, to run once: Serial.begin(115200); //baud rate delay(400); Serial.println("Starting Program (at any time press r to generate a report):"); } void loop() { // put your main code here, to run repeatedly: value = lm75a_sensor.getTemperatureInDegrees(); //measuring function if(value > high) { high = value; } if(value < low) { low = value; } Serial.print("Temperature: "); Serial.print(value); Serial.println(" °C"); ten_min += value; total += value; count++; //measures number of total measurements i = ten(i, ten_min, ten_avg, count); //will occur every ten minutes if(count%600 == 0) { ten_min = 0; } if(Serial.available() > 0) { if(Serial.read() == 'r') { overall(count, ten_avg, total, high, low); //end of program values } } delay(1); //ensures at least a millisecond has passed while(millis()%1000 != 0); //stops code so there is a measurement every second while(count == 86400) //holds code at exactly 24 hours of measurements (86400) { if(c == 0) { Serial.println(); Serial.println("24 hours is up! No more temperatures will be tracked."); Serial.println("Please press r to print the report"); c++; } if(Serial.available() > 0) { if(Serial.read() == 'r') { overall(count, ten_avg, total, high, low); //end of program values } } } }