Browse Source

Finalization

master
Apostolos Fanakis 6 years ago
parent
commit
2554079091
  1. 6
      README.md
  2. 19
      projectGroot/projectGroot.h
  3. 50
      projectGroot/projectGroot.ino
  4. BIN
      report/report.pdf

6
README.md

@ -1,7 +1,7 @@
# Microprocessors and Peripherals semester assignment, 2019, AUTH # Microprocessors and Peripherals semester assignment, 2019, AUTH
> Temperature and distance sensing and data sending over the internet > 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 ## 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 ## Support
Reach out to me: Reach out to us:
- [apostolof's email](mailto:apotwohd@gmail.com "apotwohd@gmail.com") - [apostolof's email](mailto:apotwohd@gmail.com "apotwohd@gmail.com")
- [anapt's email](mailto:ana.pachni.tsitiridou@gmail.com "ana.pachni.tsitiridou@gmail.com") - [anapt's email](mailto:ana.pachni.tsitiridou@gmail.com "ana.pachni.tsitiridou@gmail.com")

19
todoFindCoolNameForProject/todoFindCoolNameForProject.h → projectGroot/projectGroot.h

@ -1,5 +1,5 @@
#ifndef TODO_FIND_COOL_NAME_FOR_PROJECT_H #ifndef PROJECT_GROOT_H
#define TODO_FIND_COOL_NAME_FOR_PROJECT_H #define PROJECT_GROOT_H
/* ===== INCLUDES ===== */ /* ===== INCLUDES ===== */
#include <SevSeg.h> #include <SevSeg.h>
@ -11,9 +11,9 @@
// Number of readings to average // Number of readings to average
#define BUFFER_SIZE 24 #define BUFFER_SIZE 24
// Interval between readings in milliseconds // Interval between readings in milliseconds
#define SLEEP_INTERVAL 1000 // ----> TODO 5000 #define SLEEP_INTERVAL 5000
// Duration of average temperature display // Duration of average temperature display
#define TEMPERATURE_DISPLAY_DURATION 2000 // ----> TODO 10000 #define TEMPERATURE_DISPLAY_DURATION 10000
// Number of digits on the display // Number of digits on the display
#define NUMBER_OF_DIGITS 4 #define NUMBER_OF_DIGITS 4
// Pin layout // Pin layout
@ -36,11 +36,14 @@
#define SEGMENT_G_PIN 6 #define SEGMENT_G_PIN 6
#define DECIMAL_POINT_PIN 13 #define DECIMAL_POINT_PIN 13
// Temperature thresholds // Temperature thresholds
#define LOW_TEMP 28 #define LOW_TEMP 20
#define HIGH_TEMP 28 #define HIGH_TEMP 24
#define HIGH_TEMP_RELAY 32 #define HIGH_TEMP_RELAY 26
// Distance threshold // Distance threshold
#define DIST_THRESHOLD 10 #define DIST_THRESHOLD 10
#define CASE_HIGH_TEMP 0
#define CASE_LOW_TEMP 1
#define CASE_AVERAGE_TEMP 2
/* ===== GLOBAL VARIABLES AND INITIALIZATIONS ===== */ /* ===== GLOBAL VARIABLES AND INITIALIZATIONS ===== */
@ -59,4 +62,4 @@ float getNewTemp();
float calcAverageTempAndReset(); float calcAverageTempAndReset();
float getDistance(); float getDistance();
#endif //TODO_FIND_COOL_NAME_FOR_PROJECT_H #endif //PROJECT_GROOT_H

50
todoFindCoolNameForProject/todoFindCoolNameForProject.ino → projectGroot/projectGroot.ino

@ -1,7 +1,7 @@
/* /*
* TODO: write something here * TODO: write something here
*/ */
#include "todoFindCoolNameForProject.h" #include "projectGroot.h"
/* ===== SETUP AND LOOP ===== */ /* ===== SETUP AND LOOP ===== */
void setup() { void setup() {
@ -38,7 +38,6 @@ void loop() {
// Gets new readings // Gets new readings
if (!lastReading || millis() - lastReading > SLEEP_INTERVAL) { if (!lastReading || millis() - lastReading > SLEEP_INTERVAL) {
getNewSamples(); getNewSamples();
Serial.println(temperatureReadingsCounter);
lastReading = millis(); lastReading = millis();
} }
@ -53,8 +52,6 @@ void loop() {
sevseg.refreshDisplay(); sevseg.refreshDisplay();
} }
// Waits a few seconds between measurements.
//delay(SLEEP_INTERVAL);
} }
/* ===== FUNCTION IMPLEMENTATIONS ===== */ /* ===== FUNCTION IMPLEMENTATIONS ===== */
@ -64,30 +61,28 @@ void getNewSamples() {
if (lastTemperature >= HIGH_TEMP) { if (lastTemperature >= HIGH_TEMP) {
// Turns red led on // Turns red led on
digitalWrite(HIGH_TEMP_LED_PIN, HIGH); digitalWrite(HIGH_TEMP_LED_PIN, HIGH);
Serial.print(F("Warning: temperature above ")); sendEmail(CASE_HIGH_TEMP, 0);
Serial.print(HIGH_TEMP);
Serial.println(F("°C "));
//todo send email //todo send email
} else if (lastTemperature < HIGH_TEMP) { } else {
// Turns red led off // Turns red led off
digitalWrite(HIGH_TEMP_LED_PIN, LOW); digitalWrite(HIGH_TEMP_LED_PIN, LOW);
} else if (lastTemperature < LOW_TEMP){ }
if (lastTemperature < LOW_TEMP){
// Turns blue led on // Turns blue led on
digitalWrite(LOW_TEMP_LED_PIN, HIGH); digitalWrite(LOW_TEMP_LED_PIN, HIGH);
Serial.print(F("Warning: temperature below ")); sendEmail(CASE_LOW_TEMP, 0);
Serial.print(LOW_TEMP);
Serial.println(F("°C "));
//todo send email //todo send email
} else if (lastTemperature >= LOW_TEMP) { } else {
// Turns blue led off // Turns blue led off
digitalWrite(LOW_TEMP_LED_PIN, LOW); digitalWrite(LOW_TEMP_LED_PIN, LOW);
} else if (lastTemperature >= HIGH_TEMP_RELAY){ }
if (lastTemperature > HIGH_TEMP_RELAY){
// Turns relay on // Turns relay on
// this could start a fan // this could start a fan
digitalWrite(RELAY_PIN, HIGH); digitalWrite(RELAY_PIN, HIGH);
Serial.print(F("Warning: extremely high temperature. ")); Serial.print(F("Warning: extremely high temperature. "));
Serial.println(F("Fan activated.")); Serial.println(F("Fan activated."));
} else if (lastTemperature < HIGH_TEMP_RELAY){ } else {
// Turns relay off // Turns relay off
// this could cause the fan to stop working // this could cause the fan to stop working
digitalWrite(RELAY_PIN, LOW); 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. // Two minutes have passed by. At this point the desired number of readings has been reached.
// Calculates the new average temperature // Calculates the new average temperature
averageTemp = calcAverageTempAndReset(); averageTemp = calcAverageTempAndReset();
Serial.print("Average temperature: "); sendEmail(CASE_AVERAGE_TEMP, averageTemp);
Serial.println(averageTemp);
// Updates the starting time for the display // Updates the starting time for the display
displayTimeStart = millis(); displayTimeStart = millis();
@ -124,10 +118,6 @@ float getNewTemp(){
// Updates the readings counter // Updates the readings counter
++temperatureReadingsCounter; ++temperatureReadingsCounter;
Serial.print(F("Temperature: "));
Serial.print(temperature);
Serial.println(F("°C "));
return temperature; return temperature;
} }
@ -153,7 +143,7 @@ float getDistance() {
digitalWrite(DIST_TRIG_PIN, HIGH); digitalWrite(DIST_TRIG_PIN, HIGH);
delayMicroseconds(10); delayMicroseconds(10);
digitalWrite(DIST_TRIG_PIN, LOW); digitalWrite(DIST_TRIG_PIN, LOW);
// Reads the signal from the sensor: a HIGH pulse whose // Reads the signal from the sensor: a HIGH pulse whose
// duration is the time (in microseconds) from the sending // duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object. // 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; float distance = (duration/2) / 29.1;
return distance; 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 ");
}
}

BIN
report/report.pdf

Binary file not shown.
Loading…
Cancel
Save