From 7ddb8c480f62f9d65737632e72a934459be9a0ef Mon Sep 17 00:00:00 2001 From: Anastasia Pachni Tsitiridou Date: Mon, 17 Jun 2019 18:46:44 +0000 Subject: [PATCH] Update todoFindCoolNameForProject/todoFindCoolNameForProject.ino --- .../todoFindCoolNameForProject.ino | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/todoFindCoolNameForProject/todoFindCoolNameForProject.ino b/todoFindCoolNameForProject/todoFindCoolNameForProject.ino index c19024d..4e82f2a 100644 --- a/todoFindCoolNameForProject/todoFindCoolNameForProject.ino +++ b/todoFindCoolNameForProject/todoFindCoolNameForProject.ino @@ -62,22 +62,34 @@ void getNewSamples() { float lastTemperature = getNewTemp(); if (lastTemperature >= HIGH_TEMP) { - // Turns red led and relay on + // Turns red led on digitalWrite(HIGH_TEMP_LED_PIN, HIGH); - digitalWrite(RELAY_PIN, HIGH); - // Turns blue led off - digitalWrite(LOW_TEMP_LED_PIN, LOW); - } else if (lastTemperature < LOW_TEMP) { - // Turns blue led on - digitalWrite(LOW_TEMP_LED_PIN, HIGH); + Serial.print(F("Warning: temperature above ")); + Serial.print(HIGH_TEMP); + Serial.println(F("°C ")); + //todo send email + } else if (lastTemperature < HIGH_TEMP) { // Turns red led off digitalWrite(HIGH_TEMP_LED_PIN, LOW); - digitalWrite(RELAY_PIN, LOW); - } else { - // Turns red led off - digitalWrite(LOW_TEMP_LED_PIN, LOW); + } else if (lastTemperature < LOW_TEMP){ + // Turns blue led on + digitalWrite(LOW_TEMP_LED_PIN, HIGH); + 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 - 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); } @@ -128,6 +140,8 @@ float calcAverageTempAndReset() { // Resets the readings counter temperatureReadingsCounter = 0; + // TODO send email -> emailAverageTemp(averageTemp) + return sum/BUFFER_SIZE; }