|
@ -62,22 +62,34 @@ void getNewSamples() { |
|
|
float lastTemperature = getNewTemp(); |
|
|
float lastTemperature = getNewTemp(); |
|
|
|
|
|
|
|
|
if (lastTemperature >= HIGH_TEMP) { |
|
|
if (lastTemperature >= HIGH_TEMP) { |
|
|
// Turns red led and relay on
|
|
|
// Turns red led on
|
|
|
digitalWrite(HIGH_TEMP_LED_PIN, HIGH); |
|
|
digitalWrite(HIGH_TEMP_LED_PIN, HIGH); |
|
|
digitalWrite(RELAY_PIN, HIGH); |
|
|
Serial.print(F("Warning: temperature above ")); |
|
|
// Turns blue led off
|
|
|
Serial.print(HIGH_TEMP); |
|
|
digitalWrite(LOW_TEMP_LED_PIN, LOW); |
|
|
Serial.println(F("°C ")); |
|
|
} else if (lastTemperature < LOW_TEMP) { |
|
|
//todo send email
|
|
|
// Turns blue led on
|
|
|
} else if (lastTemperature < HIGH_TEMP) { |
|
|
digitalWrite(LOW_TEMP_LED_PIN, HIGH); |
|
|
|
|
|
// Turns red led off
|
|
|
// Turns red led off
|
|
|
digitalWrite(HIGH_TEMP_LED_PIN, LOW); |
|
|
digitalWrite(HIGH_TEMP_LED_PIN, LOW); |
|
|
digitalWrite(RELAY_PIN, LOW); |
|
|
} else if (lastTemperature < LOW_TEMP){ |
|
|
} else { |
|
|
// Turns blue led on
|
|
|
// Turns red led off
|
|
|
digitalWrite(LOW_TEMP_LED_PIN, HIGH); |
|
|
digitalWrite(LOW_TEMP_LED_PIN, LOW); |
|
|
Serial.print(F("Warning: temperature below ")); |
|
|
|
|
|
Serial.print(LOW_TEMP); |
|
|
|
|
|
Serial.println(F("°C ")); |
|
|
|
|
|
//todo send email
|
|
|
|
|
|
} else if (lastTemperature >= LOW_TEMP) { |
|
|
// Turns blue led off
|
|
|
// Turns blue led off
|
|
|
digitalWrite(HIGH_TEMP_LED_PIN, LOW); |
|
|
digitalWrite(LOW_TEMP_LED_PIN, LOW); |
|
|
|
|
|
} else if (lastTemperature >= HIGH_TEMP_RELAY){ |
|
|
|
|
|
// Turns relay on
|
|
|
|
|
|
// this could start a fan
|
|
|
|
|
|
digitalWrite(RELAY_PIN, HIGH); |
|
|
|
|
|
Serial.print(F("Warning: extremely high temperature. ")); |
|
|
|
|
|
Serial.println(F("Fan activated.")); |
|
|
|
|
|
} else if (lastTemperature < HIGH_TEMP_RELAY){ |
|
|
|
|
|
// Turns relay off
|
|
|
|
|
|
// this could cause the fan to stop working
|
|
|
digitalWrite(RELAY_PIN, LOW); |
|
|
digitalWrite(RELAY_PIN, LOW); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -128,6 +140,8 @@ float calcAverageTempAndReset() { |
|
|
// Resets the readings counter
|
|
|
// Resets the readings counter
|
|
|
temperatureReadingsCounter = 0; |
|
|
temperatureReadingsCounter = 0; |
|
|
|
|
|
|
|
|
|
|
|
// TODO send email -> emailAverageTemp(averageTemp)
|
|
|
|
|
|
|
|
|
return sum/BUFFER_SIZE; |
|
|
return sum/BUFFER_SIZE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|