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

Revision:
8:2d462919519e
Parent:
7:1d691f81d455
Child:
9:43c339533f7f
--- a/main.cpp	Fri Apr 11 03:50:38 2014 +0000
+++ b/main.cpp	Fri Apr 11 11:05:02 2014 +0000
@@ -1,3 +1,7 @@
+
+//QUICK REFS:
+// TICKER is using timer 1 for buzzer. 
+
 #include "mbed.h"
 
 #include "keypad.h"
@@ -15,34 +19,119 @@
 #include "airhumidity.h"
 #include "soilmoisture.h"
 #include "soilmoisture_pindefs.h"
+
 #include "ui.h"
 #include "ui_pindefs.h"
 #include "TextLCD.h"
 
-Serial pc(PTE20,PTE21);
+#include "rtcimp.h"
+
+//SERIAL
+Serial bluetooth(PTA2, PTA1);  // tx, rx
+Serial printer(PTC4,PTC3);  // tx, rx
+//TICKERS
 Ticker timer1ms;
-//float a;
-//int b; 
+Ticker clock_mine;
+//FLAGS
+bool startup_flag=true; 
+bool watered_plants = false; 
+
+//SETPOINTS
+float setpoint_air_humidity = 30.00 ;
+float setpoint_soil_humid1 = 0.3 ;
+float setpoint_soil_humid2 = 0.3 ;
+
+//WINDOWING
+float window_f = 2 ;
+int window_i =2 ;
+
+//GLOBAL VARS
+float current_water_level = 0; 
+
+//SAFETY LIMITS
+const float max_peltier_temp = 68 ; //CELCIUS
+
+//**************************FUNCTION TO READ SENSORS ********************************************** 
+void read_sensors(){
+    
+    //Read values for AIR
+    
+    //OUTSIDE
+    outside_humidity = get_air_humid_outside();
+    outside_temp = get_air_temp_outside(temp_unit); 
+    outside_dewpoint = get_air_dewpoint_outside();
+    
+    //INSIDE
+    inside_humidity = get_air_humid_inside();
+    inside_temp = get_air_temp_inside(temp_unit); 
+    inside_dewpoint = get_air_dewpoint_inside();
+    
+    //Read value for soil
+    read_soil_humidity();
+    calc_soil_humid_values(); //values in soil1_humid and soil2_humid perecentages
+    
+}
+
+//****************************Functions that perform tasks**************************************
+void waterplants(){
+    
+    
+    
+    
+}
+//***************************PLACEHOLDER FUNCTION TO DISABLE EVERYTHING **********************
+void disable_everything(){
+    
+    //Disable peltier,vac,fans,pumps.
+    
+}
+
+
+//*********************************************************************************************
+//*                                                                                           *
+//*                                                                                           *
+//*                                                                                           *
+//*                                                                                           *
+//*                                    MAIN ROUTINE                                           *
+//*                                                                                           *
+//*                           DO NOT MODIFY WITHOUT TELLING UMAIR                             *
+//*                                                                                           *
+//*                                                                                           *
+//*********************************************************************************************
 
 int main(void)
 {
+    
+    //call function that disables everything.
+    disable_everything();
+    
+    
+    //FOR BUZZER
     timer1ms.attach(&timer1, 0.001); //interrupt attached function(timer) with interval (1 ms)
-    //pc.baud( BAUDRATE0 );
-    char key;
-    // lcd.cls();
+    //FOR INTERNAL CLOCK
+    clock_mine.attach(&sec_inc, 1.0);
+    char keypad_value;
+    
+    //call LCD boot
+    ui_startup();
+    
+    //SET TIME
+    rtcimp_settime(6,0);
+    //call function that reads values
+    read_sensors();
+    
+    //call function that performs functions.
+    
+    
+    startup_flag = false ;  
     while(1) {
-        //  lcd.cls();
-        key = Keypad();
-        //if (key!=NULL)
-        //{}
-        pc.printf("k\n");
-       // b = static_cast<int>(a);
-        wait(0.2);
-        //  if(key != 100) {
-        //      pc.printf("keypad = %f\n", key);
-        //
-  }
-        //     lcd.printf("%c\n\r",&key);
-        //wait(0.2);
+       
+        wait(1.5);
+        keypad_value = Keypad();
         
-}
\ No newline at end of file
+    }//WHILE END
+
+        
+}
+
+