Project Autus - Automated Plant Chamber

Dependencies:   TextLCD mbed

Fork of keypad_test by Plamen Totev

Autus

This is the codebase accompanying the project Autus.

Autus is an automated growth chamber for plants.

Features

Control Humidity inside chamber wrt to external humidity. Control Temperature inside chamber. ( Peltier Heaters/Coolers ) Water and shower plants. Control soil humidity. Monitor water tanks level (Load Cell) /media/uploads/umairaftab/frdm_-_new_page1.png

Code Base Features

Fixed timing and CRC for DHT-11 Sensor. Fixed OneWire bug for ds18b20

Cyclic Executive Scheduler with Priority. Async IPC framework for PC App over bluetooth

Fake RTC systick, I was having some trouble with the on board rtc.

/media/uploads/umairaftab/download.png

Files at this revision

API Documentation at this revision

Comitter:
umairaftab
Date:
Sat Apr 12 06:35:04 2014 +0000
Parent:
10:1a0fe96381b0
Child:
12:b3137bb72ef7
Commit message:
Fixed type error in soil humidity.cpp ;

Changed in this revision

SoilMoisture/soilmoisture.cpp Show annotated file Show diff for this revision Revisions of this file
SoilMoisture/soilmoisture.h Show annotated file Show diff for this revision Revisions of this file
UI/ui.cpp Show annotated file Show diff for this revision Revisions of this file
UI/ui.h 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
--- a/SoilMoisture/soilmoisture.cpp	Fri Apr 11 13:42:45 2014 +0000
+++ b/SoilMoisture/soilmoisture.cpp	Sat Apr 12 06:35:04 2014 +0000
@@ -2,7 +2,7 @@
 #include "soilmoisture.h"
 /*https://mbed.org/users/chris/notebook/Getting-best-ADC-performance*/
 static const int MAX_DATAPOINTS=500;
-static const unsigned int MAX_ADC_VALUE=65535;
+static const float MAX_ADC_VALUE=65535;
 
 unsigned short current_soil_humid1=0;
 unsigned short current_soil_humid2=0;
@@ -10,8 +10,8 @@
 unsigned int current_soil_humid1_int=0;
 unsigned int current_soil_humid2_int=0;
 
-unsigned int CMA_soil1=0;
-unsigned int CMA_soil2=0; 
+unsigned short CMA_soil1=0;
+unsigned short CMA_soil2=0; 
 
 float soil1_humid=0;
 float soil2_humid=0;
@@ -25,11 +25,11 @@
         current_soil_humid2 = soil_sense2.read_u16();
         
         //convert from short to int
-        current_soil_humid1_int = (unsigned int)current_soil_humid1;
-        current_soil_humid2_int = (unsigned int)current_soil_humid2;
+        //current_soil_humid1_int = (unsigned int)current_soil_humid1;
+        //current_soil_humid2_int = (unsigned int)current_soil_humid2;
         
-        CMA_soil1 =  (current_soil_humid1_int + (count*CMA_soil1))/(count+1);
-        CMA_soil2 =  (current_soil_humid2_int + (count*CMA_soil2))/(count+1); 
+        CMA_soil1 =  (current_soil_humid1 + (count*CMA_soil1))/(count+1);
+        CMA_soil2 =  (current_soil_humid2 + (count*CMA_soil2))/(count+1); 
         
         wait_ms(5);
         count++;    
@@ -38,8 +38,8 @@
 }
 
 void calc_soil_humid_values(){
-    
-    soil1_humid = CMA_soil1/MAX_ADC_VALUE;    
-    soil2_humid = CMA_soil2/MAX_ADC_VALUE;
-    
+    printf("%d \n\r",CMA_soil1);
+    soil1_humid = (float)CMA_soil1/MAX_ADC_VALUE;    
+    soil2_humid = (float)CMA_soil2/MAX_ADC_VALUE;
+    printf("%4.2f \n\r",soil1_humid);
 }
\ No newline at end of file
--- a/SoilMoisture/soilmoisture.h	Fri Apr 11 13:42:45 2014 +0000
+++ b/SoilMoisture/soilmoisture.h	Sat Apr 12 06:35:04 2014 +0000
@@ -2,8 +2,8 @@
 extern AnalogIn soil_sense2;
 
 
-extern unsigned int CMA_soil1;
-extern unsigned int CMA_soil2; 
+extern unsigned short CMA_soil1;
+extern unsigned short CMA_soil2; 
 
 extern float soil1_humid;
 extern float soil2_humid;
--- a/UI/ui.cpp	Fri Apr 11 13:42:45 2014 +0000
+++ b/UI/ui.cpp	Sat Apr 12 06:35:04 2014 +0000
@@ -51,8 +51,8 @@
     lcd.printf("T: %3.1f%c",inside_temp,temp_unit_char);
     lcd.printf(" H: %3.1f",inside_humidity);   
     lcd.locate(0,1);
-    lcd.printf("S1: %3.1f",soil1_humidity);
-    lcd.printf(" S2: %3.1f",soil2_humidity);
+    lcd.printf("S1: %4.2f",soil1_humidity);
+    lcd.printf(" S2: %4.2f",soil2_humidity);
 }
 
 void ui_screen2() {
@@ -79,4 +79,16 @@
     lcd.locate(0,1);
     lcd.printf("oT: %3.1f%c",outside_temp,temp_unit_char);
     lcd.printf(" oH: %3.1f",outside_humidity);
+}
+void ui_screen4() {
+    
+    //set_temp_unit();
+    lcd.cls();
+    lcd.setCursor(TextLCD::CurOff_BlkOn);
+    lcd.locate(0,0);
+    lcd.printf("iT: %3.1f%c",inside_temp,temp_unit_char);
+    lcd.printf(" iH: %3.1f",inside_humidity);   
+    lcd.locate(0,1);
+    lcd.printf("oT: %3.1f%c",outside_temp,temp_unit_char);
+    lcd.printf(" oH: %3.1f",outside_humidity);
 }
\ No newline at end of file
--- a/UI/ui.h	Fri Apr 11 13:42:45 2014 +0000
+++ b/UI/ui.h	Sat Apr 12 06:35:04 2014 +0000
@@ -20,4 +20,5 @@
 void ui_startup();
 void ui_screen1() ;
 void ui_screen2() ;
-void ui_screen3() ;
\ No newline at end of file
+void ui_screen3() ;
+void ui_screen4() ;
\ No newline at end of file
--- a/main.cpp	Fri Apr 11 13:42:45 2014 +0000
+++ b/main.cpp	Sat Apr 12 06:35:04 2014 +0000
@@ -32,6 +32,7 @@
 //TICKERS
 Ticker timer1ms;
 Ticker clock_mine;
+Timer lcd_timeout;
 //FLAGS
 bool startup_flag=true; 
 bool watered_plant1 = false;
@@ -44,13 +45,16 @@
 float setpoint_soil_humid1 = 0.3 ;
 float setpoint_soil_humid2 = 0.3 ;
 
+int setpoint_red_lights;
+int setpoint_blue_lights;
+int setpoint_green_lights;
 //WINDOWING
 float window_f = 5 ;
 int window_i =2 ;
 
 //GLOBAL VARS
 float current_water_level = 0; 
-
+bool screen_timeout=false;
 //SAFETY LIMITS
 const float max_peltier_temp = 68 ; //CELCIUS
 const int MAX_WATERING_TIME_GAP = 20;
@@ -73,7 +77,9 @@
     //Read value for soil
     read_soil_humidity();
     calc_soil_humid_values(); //values in soil1_humid and soil2_humid perecentages
-    
+    soil1_humidity = soil1_humid ;
+    soil2_humidity = soil2_humid ;
+    printf("%4.2f \n\r",soil1_humidity);
 }
 
 //****************************Functions that perform tasks**************************************
@@ -118,7 +124,7 @@
 // Air Humidity Level
 void airhumidity(){
     
-    if( (setpoint_air_humidity+window_f > inside_humidity) && (setpoint_air_humidity-window_f < inside_humidity) ){
+    if( !( (setpoint_air_humidity+window_f > inside_humidity) && (setpoint_air_humidity-window_f < inside_humidity) ) ){
     
         //Turn on Air humidity fan 
         wait(5);
@@ -165,7 +171,7 @@
     //FOR INTERNAL CLOCK
     clock_mine.attach(&sec_inc, 1.0);
     char keypad_value;
-    
+    int ui_current_screen = 1;
     //************************************BOOT SEQUENCE*********************
     //call LCD boot
     ui_startup();
@@ -214,6 +220,13 @@
     
     cycleair();
     
+    wait(2);
+    lcd.cls();
+    lcd.locate(0,0);
+    lcd.printf("Testing Lights");
+    //led_test();
+    
+    
     wait(5);
     ui_screen1();
     wait(5);
@@ -225,7 +238,9 @@
         //FOR BUZZER
         timer1ms.attach(&timer1, 0.001); //interrupt attached function(timer) with interval (1 ms)
         keypad_value = Keypad();
-        timer1ms.detach();
+        //timer1ms.detach();
+        
+        
     }//WHILE END