diff --git a/README.md b/README.md index a7a72aa..faf8beb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Microprocessors and Peripherals semester assignment, 2019, AUTH > Temperature and distance sensing and data sending over the internet -insertCoolProjectNameHere is an *experimental* application developed as part of the course "Microprocessors and Peripherals" assignment, that took place in the Department of Electrical & Computer Engineering at Aristotle University of Thessaloniki in 2019. +Groot is an *experimental* application developed as part of the course "Microprocessors and Peripherals" assignment, that took place in the Department of Electrical & Computer Engineering at Aristotle University of Thessaloniki in 2019. --- @@ -22,13 +22,13 @@ All the libraries' latest versions (as of the completion of the project) can be ## Execution -To execute the code just open the `todoFindCoolNameForProject\todoFindCoolNameForProject.ino` file using the Arduino IDE and click the Verify and Upload buttons. All necessery peripherials need to be correctly connected to the Arduino board used, more information about the connections can be found inside the `todoFindCoolNameForProject.ino` file and the report. +To execute the code just open the `projectGroot\projectGroot.ino` file using the Arduino IDE and click the Verify and Upload buttons. All necessery peripherials need to be correctly connected to the Arduino board used, more information about the connections can be found inside the `projectGroot.ino` file and the report. --- ## Support -Reach out to me: +Reach out to us: - [apostolof's email](mailto:apotwohd@gmail.com "apotwohd@gmail.com") - [anapt's email](mailto:ana.pachni.tsitiridou@gmail.com "ana.pachni.tsitiridou@gmail.com") diff --git a/todoFindCoolNameForProject/todoFindCoolNameForProject.h b/projectGroot/projectGroot.h similarity index 81% rename from todoFindCoolNameForProject/todoFindCoolNameForProject.h rename to projectGroot/projectGroot.h index 2f98ebc..13e8635 100644 --- a/todoFindCoolNameForProject/todoFindCoolNameForProject.h +++ b/projectGroot/projectGroot.h @@ -1,5 +1,5 @@ -#ifndef TODO_FIND_COOL_NAME_FOR_PROJECT_H -#define TODO_FIND_COOL_NAME_FOR_PROJECT_H +#ifndef PROJECT_GROOT_H +#define PROJECT_GROOT_H /* ===== INCLUDES ===== */ #include @@ -11,9 +11,9 @@ // Number of readings to average #define BUFFER_SIZE 24 // Interval between readings in milliseconds -#define SLEEP_INTERVAL 1000 // ----> TODO 5000 +#define SLEEP_INTERVAL 5000 // Duration of average temperature display -#define TEMPERATURE_DISPLAY_DURATION 2000 // ----> TODO 10000 +#define TEMPERATURE_DISPLAY_DURATION 10000 // Number of digits on the display #define NUMBER_OF_DIGITS 4 // Pin layout @@ -36,11 +36,14 @@ #define SEGMENT_G_PIN 6 #define DECIMAL_POINT_PIN 13 // Temperature thresholds -#define LOW_TEMP 28 -#define HIGH_TEMP 28 -#define HIGH_TEMP_RELAY 32 +#define LOW_TEMP 20 +#define HIGH_TEMP 24 +#define HIGH_TEMP_RELAY 26 // Distance threshold #define DIST_THRESHOLD 10 +#define CASE_HIGH_TEMP 0 +#define CASE_LOW_TEMP 1 +#define CASE_AVERAGE_TEMP 2 /* ===== GLOBAL VARIABLES AND INITIALIZATIONS ===== */ @@ -59,4 +62,4 @@ float getNewTemp(); float calcAverageTempAndReset(); float getDistance(); -#endif //TODO_FIND_COOL_NAME_FOR_PROJECT_H +#endif //PROJECT_GROOT_H diff --git a/todoFindCoolNameForProject/todoFindCoolNameForProject.ino b/projectGroot/projectGroot.ino similarity index 85% rename from todoFindCoolNameForProject/todoFindCoolNameForProject.ino rename to projectGroot/projectGroot.ino index 4e82f2a..9cab21b 100644 --- a/todoFindCoolNameForProject/todoFindCoolNameForProject.ino +++ b/projectGroot/projectGroot.ino @@ -1,7 +1,7 @@ /* * TODO: write something here */ -#include "todoFindCoolNameForProject.h" +#include "projectGroot.h" /* ===== SETUP AND LOOP ===== */ void setup() { @@ -38,7 +38,6 @@ void loop() { // Gets new readings if (!lastReading || millis() - lastReading > SLEEP_INTERVAL) { getNewSamples(); - Serial.println(temperatureReadingsCounter); lastReading = millis(); } @@ -53,8 +52,6 @@ void loop() { sevseg.refreshDisplay(); } - // Waits a few seconds between measurements. - //delay(SLEEP_INTERVAL); } /* ===== FUNCTION IMPLEMENTATIONS ===== */ @@ -64,30 +61,28 @@ void getNewSamples() { if (lastTemperature >= HIGH_TEMP) { // Turns red led on digitalWrite(HIGH_TEMP_LED_PIN, HIGH); - Serial.print(F("Warning: temperature above ")); - Serial.print(HIGH_TEMP); - Serial.println(F("°C ")); + sendEmail(CASE_HIGH_TEMP, 0); //todo send email - } else if (lastTemperature < HIGH_TEMP) { + } else { // Turns red led off digitalWrite(HIGH_TEMP_LED_PIN, LOW); - } else if (lastTemperature < LOW_TEMP){ + } + 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 ")); + sendEmail(CASE_LOW_TEMP, 0); //todo send email - } else if (lastTemperature >= LOW_TEMP) { + } else { // Turns blue led off digitalWrite(LOW_TEMP_LED_PIN, LOW); - } else if (lastTemperature >= HIGH_TEMP_RELAY){ + } + 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){ + } else { // Turns relay off // this could cause the fan to stop working digitalWrite(RELAY_PIN, LOW); @@ -97,8 +92,7 @@ void getNewSamples() { // Two minutes have passed by. At this point the desired number of readings has been reached. // Calculates the new average temperature averageTemp = calcAverageTempAndReset(); - Serial.print("Average temperature: "); - Serial.println(averageTemp); + sendEmail(CASE_AVERAGE_TEMP, averageTemp); // Updates the starting time for the display displayTimeStart = millis(); @@ -124,10 +118,6 @@ float getNewTemp(){ // Updates the readings counter ++temperatureReadingsCounter; - Serial.print(F("Temperature: ")); - Serial.print(temperature); - Serial.println(F("°C ")); - return temperature; } @@ -153,7 +143,7 @@ float getDistance() { digitalWrite(DIST_TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(DIST_TRIG_PIN, LOW); - + // Reads the signal from the sensor: a HIGH pulse whose // duration is the time (in microseconds) from the sending // of the ping to the reception of its echo off of an object. @@ -164,3 +154,19 @@ float getDistance() { float distance = (duration/2) / 29.1; return distance; } + +void sendEmail(int _case, float averageTemp) { + if (_case == CASE_HIGH_TEMP){ + Serial.print("EMAIL : The temperature is above "); + Serial.print(HIGH_TEMP); + Serial.println("°C "); + } else if (_case == CASE_LOW_TEMP){ + Serial.print("EMAIL : The temperature is below "); + Serial.print(LOW_TEMP); + Serial.println("°C "); + } else if (_case == CASE_AVERAGE_TEMP){ + Serial.print("EMAIL : The average temperature is "); + Serial.print(averageTemp); + Serial.println("°C "); + } +} diff --git a/report/report.pdf b/report/report.pdf new file mode 100644 index 0000000..aad3ab2 Binary files /dev/null and b/report/report.pdf differ