Greenhouse Climate Observation Module

Dependencies:   BSP_DISCO_F746NG DHT

Files at this revision

API Documentation at this revision

Comitter:
chri721u
Date:
Wed Feb 05 13:56:12 2020 +0000
Parent:
7:585a66ea498b
Commit message:
Greenhouse Climate Observation Module; Final version 05/02/2020

Changed in this revision

bootup.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 585a66ea498b -r 03ba8074d634 bootup.cpp
--- a/bootup.cpp	Wed Feb 05 12:28:55 2020 +0000
+++ b/bootup.cpp	Wed Feb 05 13:56:12 2020 +0000
@@ -16,6 +16,9 @@
     BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS);
     BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER);
 
-    // Clear the screen, add black background and red text
-    BSP_LCD_Clear(LCD_COLOR_BLACK);
+    // Clear the screen, add black background and red text    
+    BSP_LCD_Clear(LCD_COLOR_WHITE);
+    BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
+    BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
+    BSP_LCD_DisplayStringAt(0, 0, (uint8_t *) "  Time: Day  ", RIGHT_MODE);
 }
\ No newline at end of file
diff -r 585a66ea498b -r 03ba8074d634 main.cpp
--- a/main.cpp	Wed Feb 05 12:28:55 2020 +0000
+++ b/main.cpp	Wed Feb 05 13:56:12 2020 +0000
@@ -62,7 +62,7 @@
 float humid;
 
 /* Greenhouse mechanisms */
-void Vent_Air(); 
+void Vent_Air();
 void Heat_Lamp();
 void Dehumidifier();
 void Spray_Water();
@@ -74,7 +74,6 @@
 {
     cout << "Enter Greenhouse ID: \n \r";
     cin >> location_id;
-    cout << "Greenhouse ID is: " << location_id;
 }
 
 int main()
@@ -111,11 +110,12 @@
 
 void TimeCounter()
 {
-    // Timecounter counts up to one cycle of 720 minutes (Sim 7.20 secs)
+    // Timecounter counts up to one cycle of 
+    // 720 minutes if not in Simulation mode
     while(1) {
         if(simmode) {
             timecount++;
-            wait(0.01);
+            wait(0.01); // One tenth of a second per tic
             if (timecount == 721) {
                 timeofday = !timeofday;
                 printf("Time of day is %d \n \r", timeofday);
@@ -128,7 +128,7 @@
             }
         } else if(simmode == 0) {
             timecount++;
-            wait(1);
+            wait(60); // 1 minute per tic
             if (timecount == 721) {
                 timeofday = !timeofday;
                 timecount = 0;
@@ -181,24 +181,32 @@
 void Temp_Check()
 {
     while(1) {
-        temp = Temp_Sensor.read() * 100 / 2; // Read temperature sensor input. Since this is flawed, correct to adjust.
-        if(timeofday) { // If it's daytime, keep temps between 25 and 30 celsius
+        temp = Temp_Sensor.read() * 100 / 2; 
+        // Read temperature sensor input. Since this is flawed, correct to adjust.
+        if(timeofday) { 
+        // If it's daytime, keep temps between 25 and 30 celsius
             if (temp >= 25 && temp <= 30) {
-                printf("Greenhouse temperature within acceptable parameters \n \r");
-                wait(1);
+                Temp_LED = 1;
             }  else if (temp < 25) {
-                Heat_Lamp(); // Raise temperature by turning on the heat lamps in the greenhouse
+                Temp_LED = 0;
+                Heat_Lamp(); 
+                // Raise temperature by turning on the heat lamps in the greenhouse
             } else if (temp > 30) {
-                Vent_Air(); // Reduce temperature by venting the hot air out of the greenhouse
+
+                Temp_LED = 0;
+                Vent_Air(); 
+                // Reduce temperature by venting the hot air out of the greenhouse
             }
-        } else if(timeofday == false) { // If it's nighttime, keep temps between 15 and 20
+        } else if(timeofday == false) { 
+        // If it's nighttime, keep temps between 15 and 20
             if (temp >= 15 && temp <= 20) {
                 Temp_LED = 1;
-                wait(1);
             } else if (temp < 15) {
+                Temp_LED = 0;
                 Heat_Lamp();
 
             } else if (temp > 20) {
+                Temp_LED = 0;
                 Vent_Air();
             }
         }
@@ -211,10 +219,12 @@
         humid = Humid_Sensor.ReadHumidity();
         int dataread = Humid_Sensor.readData(); // No idea why, but the humidity won't display on screen without it.
         if (humid >= 55 && humid <= 65) { // Check if humidity is within acceptable parameters (55% - 65%)
-            printf("Greenhouse humidity is within acceptable parameters \n \r");
+            Humid_LED = 1;
         } else if (humid < 55) {
+            Humid_LED = 0;
             Spray_Water(); // Raise humidity by spraying water into the plants and greenhouse.
         } else if ( humid > 65) {
+            Humid_LED = 0;
             Dehumidifier(); // Lower humidity by dehumidifying the greenhouse.
         }
     }