#include //this is the library that consists of data types #include //this is the library that consists for I2C COmmunication which will send information with SDA_PIN and SCL_PIN #include //this is the library that I'll be using for my project which is the main LM75 Temp Sensor const int summaryInterval = 600000; // Interval for printing summary (10 minutes = 600,000 milliseconds) unsigned long previousSummaryTime = 0; unsigned long totalTime = 0; float totalTemperature = 0; float highestTemperature = -273.15; // Initialize with absolute zero, just to make sure give a good interval because the -273.15 represents the lowest value that represents absolute zero in temperature wise float lowestTemperature = 1000; // Initialize with high value, interval maths plus I'm also just interested in making it this extremely low so anything lower isn't possible for calculations later int measurementCount = 0; //declare array of data to store temps in 10 min intervals [144] float tenMinTemps[144]; int tenMinIndex = 0; int SDA_PIN = 21; int SCL_PIN = 22; TempI2C_LM75 thermo = TempI2C_LM75(0x48, TempI2C_LM75::nine_bits); void setup() { // put your setup code here, to run once: Serial.begin(115200); //serial communication at baud rate of 115200 pinMode(SDA_PIN, INPUT); //both are inputs because of the library's settings so configured into input pinMode(SCL_PIN, INPUT); //configured to input } void loop() { // put your main code here, to run repeatedly: float temperature = thermo.getTemp(); // Declare and assign the temperature value and reads temp sensor from LM75 Serial.print("Cycle "); Serial.print(measurementCount); Serial.print(", "); Serial.println(temperature); unsigned long currentMillis = millis(); // Read temperature from the sensor // Update the highest and lowest temperature values yup updateTemperatureRange(temperature); // Update total temperature and measurement count totalTemperature += temperature; measurementCount++; // Number of seconds elapsed since start of program // Print summary if the summary interval has passed if (currentMillis - previousSummaryTime >= summaryInterval) { tenMinTemps[tenMinIndex] = totalTemperature / measurementCount; printSummary(); previousSummaryTime = currentMillis; tenMinIndex++; } if(tenMinIndex >= 144){ //Maybe put this in its own funciton for cleanliness // Print all of the data (for loop) in format below // Serial.print("Cycle "); // Serial.print(/*incrementing variable*/); // Serial.print(", "); // Serial.println(/*temperature*/); } delay(1000); } void updateTemperatureRange(float temperature) { if (temperature > highestTemperature) { highestTemperature = temperature; } if (temperature < lowestTemperature) { lowestTemperature = temperature; } } void printSummary() { float averageTemperature = totalTemperature / measurementCount; // Print 10-minute averages, highest temperature, lowest temperature, and overall average Serial.print("10-Minute Averages:\n"); Serial.print("==================\n"); Serial.println(); // Print the averages for every 10 minutes for (int i = 0; i < measurementCount; i++) { // // im gonna use this to verify if the index represents a 10-minute interval if ((i + 1) % 10 == 0) { Serial.print("Average "); // // Print the average temperature at the current 10-minute interval Serial.print((i + 1) / 10); Serial.print("0 minutes: "); Serial.print(tenMinTemps[1]); //// Print the temperature at index 1 Serial.println(" °C"); } } // format of printing the data for Highest, Lowest and average temp and then making it into Celcius unit format Serial.println(); Serial.print("Highest Temperature: "); Serial.print(highestTemperature); Serial.println(" °C"); Serial.print("Lowest Temperature: "); Serial.print(lowestTemperature); Serial.println(" °C"); Serial.print("Overall Average: "); Serial.print(averageTemperature); Serial.println(" °C"); Serial.println(); }