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:
38:9f4107db1bff
Parent:
14:72176f1e4907
Child:
41:f484ea386062
--- a/peltier/peltier.cpp	Mon Apr 14 00:52:14 2014 +0000
+++ b/peltier/peltier.cpp	Mon Apr 14 03:34:02 2014 +0000
@@ -1,8 +1,22 @@
 #include "mbed.h"
 
 #include "TextLCD.h"
+//#include "DS18B20.h"
+#include "peltier.h"
+//----------------------------------
 #include "DS18B20.h"
-#include "peltier.h"
+#include "OneWireDefs.h"
+
+#define THERMOMETER DS18B20
+
+float temp;
+float dsen_temp_in;
+float dsen_temp_out;
+// device( mbed pin )
+THERMOMETER device(PTE0);
+
+
+//-----------------------------------
 //Serial pc(USBTX, USBRX); // tx, rx
 
 unsigned int peltier_hot_pulsewidth=1000;
@@ -17,7 +31,7 @@
 bool alarm_lo_temp_out=false;
 
 //TextLCD lcd(PTE29, PTE30, PTC12, PTD0, PTD5, PTA13, TextLCD::LCD20x2);   // rs, e, d4-d7 ok
-
+//DigitalOut backlight(PTD6);
 //unsigned int peltier_hot_pulsewidth=1000;
 //unsigned int peltier_cold_pulsewidth=1000;
 //unsigned int peltier_period =1000;
@@ -29,6 +43,21 @@
 //bool alarm_lo_temp_out=false;
 float dsen_temp;
 
+void readTemp(int deviceNum)
+{
+    temp = device.readTemperature(deviceNum);
+    // pc.printf("Device %d is %f\n\r",deviceNum, temp);
+    wait(0.5);
+}
+void tempinit(void)
+{
+    while (!device.initialize());    // keep calling until it works
+
+    int deviceCount = device.getDeviceCount();
+    //printf("Found %d sensors\n\r",deviceCount);
+
+    device.setResolution(twelveBit);
+}
 unsigned int pwm_cold_peltier(int brightness )
 {
     if (brightness==1) {
@@ -55,8 +84,10 @@
 }
 void peltier(bool fan_in,bool fan_out,bool cold,bool hot,int pwm_procent)
 {
+    //tempinit();
     //sensor.mode(PullUp);
-    //dsen_temp=mytemp();
+   // readTemp(1);
+   // dsen_temp_in=temp;
     //  ROM_Code_t ROM_Code = ReadROM();
     //  lcd.setCursor(TextLCD::CurOff_BlkOn);
     //  lcd.locate(0,0);
@@ -92,7 +123,15 @@
         peltier_hot_pulsewidth=pwm_procent*10;
         peltier_hot.pulsewidth_us(peltier_hot_pulsewidth);
     }
-    //pc.printf("Temp is %2.1fC,dsen temp= %d \n\r", dsen_temp,10);
+
+        readTemp(1);
+        dsen_temp_in=temp;
+        readTemp(0);
+        dsen_temp_out=temp;
+       // printf("inside Temp is %2.1fC, outside temp plate is %2.1fC\n\r", dsen_temp_in,dsen_temp_out);
+    //lcd.cls();
+   // lcd.locate(0,1);
+   // lcd.printf("Temp is %2.1fC\n\r", dsen_temp_in);
 
 }
 void pel_c(int pwm)
@@ -108,36 +147,44 @@
     peltier_hot_pulsewidth=pwm*10;
     peltier_hot.pulsewidth_us(peltier_hot_pulsewidth);
 }
-void peltier_auto(int degree)
-{
-    sensor.mode(PullUp);
+void peltier_auto(float degree){
+//tempinit();
+
+   // backlight=1;
+
     en_drv1=1;
     en_drv2=1;
     fan_in_peltier=1;//enable
     fan_out_peltier=1;//enable
     while(1) {
 
-        dsen_temp=mytemp();
+        readTemp(1);
+        dsen_temp_in=temp;
 
-        if (degree>dsen_temp) {
+        /* (degree>dsen_temp) {
             pel_h(0);
-            pel_c(100);
-        }
-        if (degree<dsen_temp) {
+            pel_c(90);
+        }*/
+        if (degree<dsen_temp_in) {
             pel_c(0);
-            pel_h(100);
+            pel_h(90);
 
         }
-        if (degree==dsen_temp) {
+        if (degree==dsen_temp_in) {
             pel_c(0);
             pel_h(0);
 
         }
 
-        /*lcd.cls();
-        lcd.locate(0,1);
-        pc.printf("Temp is %2.1fC,dsen temp= %d \n\r", dsen_temp,degree);
-        lcd.printf("Temp is %2.1fC\n\r", dsen_temp);*/
+        //lcd.cls();
+        //lcd.locate(0,1);
+
+        readTemp(1);
+        dsen_temp_in=temp;
+        readTemp(0);
+        dsen_temp_out=temp;
+        //pc.printf("Temp is %2.1fC,dsen temp= %2.1f , outchamber plate temp =%2.1fC\n\r", dsen_temp_in,degree,dsen_temp_out);
+        // lcd.printf("Temp is %2.1fC\n\r", dsen_temp);