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

main.cpp

Committer:
umairaftab
Date:
2014-04-11
Revision:
8:2d462919519e
Parent:
7:1d691f81d455
Child:
9:43c339533f7f

File content as of revision 8:2d462919519e:


//QUICK REFS:
// TICKER is using timer 1 for buzzer. 

#include "mbed.h"

#include "keypad.h"
#include "buzz.h"

#include "pindefs.h" //led pin definitions
#include "led_lights.h"

#include "peltier.h"
#include "peltier_pindefs.h"

#include "pumps.h"
#include "pumps_pindefs.h"

#include "airhumidity.h"
#include "soilmoisture.h"
#include "soilmoisture_pindefs.h"

#include "ui.h"
#include "ui_pindefs.h"
#include "TextLCD.h"

#include "rtcimp.h"

//SERIAL
Serial bluetooth(PTA2, PTA1);  // tx, rx
Serial printer(PTC4,PTC3);  // tx, rx
//TICKERS
Ticker timer1ms;
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)
    //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) {
       
        wait(1.5);
        keypad_value = Keypad();
        
    }//WHILE END

        
}