Greenhouse Climate Observation Module

Dependencies:   BSP_DISCO_F746NG DHT

Revision:
1:4363657c576d
Parent:
0:a5831f680465
Child:
2:739ba85b7a90
--- a/main.cpp	Tue Jan 21 12:28:42 2020 +0000
+++ b/main.cpp	Wed Jan 22 07:27:47 2020 +0000
@@ -14,6 +14,8 @@
 - Water plants at regular intervals (Twice a day)
 - Plants must have light for at least 12 hours. If weather is cloudy, artificial lights.
 - Testmode: Alternate time-tracking system, much faster than 24 hour system.
+
+REMEMBER TO RETURN BORROWED LED SOCKETS
 */
 
 #include "mbed.h" // Mbed header from mbed-os version 5
@@ -27,6 +29,7 @@
 AnalogIn light_sensor(A2);
 
 /* LED Outputs */
+DigitalOut humid_led(D2); // Blue LED
 DigitalOut temp_led(D5); // Red LED
 DigitalOut water_led(D6); // Blue LED
 DigitalOut window_led(D7); // Green LED
@@ -53,6 +56,15 @@
     window_led = 0;
 }
 
+void Water_Spray()
+{
+    // While humidity is under acceptable levels, this function would spray water. Since it cannot be acurately simultaed, this function will largely remain empty.
+    humid_led = 1;
+    wait(0.5);
+    humid_led = 0;
+
+}
+
 void Temp_Display()
 {
     while(1) {
@@ -67,11 +79,19 @@
 void Humid_Display()
 {
     while(1) {
+        humid_led = 1;
         // Monitor humidity and display results on LCD screen
         float humid = humid_sensor.ReadHumidity();
+        int dataread = humid_sensor.readData();
         wait(1);
         sprintf((char*)text, "Humidity: %.1f", humid);
         BSP_LCD_DisplayStringAt(0, 175, (uint8_t *)&text, CENTER_MODE);
+
+        if(humid > 70) {
+            Window_Open();
+        } else if(humid < 50) {
+            Water_Spray();
+        }
     }
 }
 
@@ -79,6 +99,7 @@
 {
     LCD_Start.LCD_Bootup();
     // Start multithread
+    tHumid.start(&Humid_Display);
     tTemp.start(&Temp_Display);
-    tHumid.start(&Humid_Display);
+    while(1) {}
 }