ESTE PROGRAMA VA A CONTROLAR LAS VARIABLES DE HUMEDAD Y TEMPERATURA SET POINT POR EL USUARIO A TRAVES DE UNA INTERFAZ
Dependencies: mbed TextLCD Keypad DS1307 DHT11
Revision 3:65184d2ffad8, committed 2020-02-17
- Comitter:
- geogarcia
- Date:
- Mon Feb 17 13:38:12 2020 +0000
- Parent:
- 2:0edb81388d5f
- Commit message:
- El proyecto trata de un datalogger de humedad y temperatura con registro en tiempo real, empleando el sensor DHT11, el modulo RTC DS1307, placa STM32M4 Discovery
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 0edb81388d5f -r 65184d2ffad8 main.cpp --- a/main.cpp Sun Feb 16 18:25:15 2020 +0000 +++ b/main.cpp Mon Feb 17 13:38:12 2020 +0000 @@ -1,23 +1,22 @@ -////////////////////////////////// LIBRERIAS DEL PROYECTO///////////////////////////////////////////// +////////////////////////////////// LIBRERIAS DEL PROYECTO/////////////////////////////////////////////////////// #include "mbed.h"// libreria principal mbed #include "TextLCD.h"// libreria lcd #include "Keypad.h"// libreria Keypad #include "DHT11.h"// libreria sensor de humedad y temperatura -//include "clase.h" -#include "math.h" -#include "ds1307.h" -////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////// CONFIGURACION DE GPIO //////////////////////////////////////////// -Serial pc(PA_2,PA_3); +#include "math.h"// libreria matematicas +#include "ds1307.h"// libreria rtc ds1307 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////// CONFIGURACION DE GPIO /////////////////////////////////////////////////////// +Serial pc(PA_2,PA_3);// configuracion de pines de Tx,Rx de comunicacion serial DigitalOut myled(PD_13);// configura salida digital y asigna a myled al pin d13 TextLCD lcd(PB_7,PB_8,PB_15,PB_14,PB_13,PB_12,TextLCD:: LCD16x2);// configuracion de conexion de lcd -Keypad teclado(PC_8,PC_11,PC_7,PC_6,PB_0,PD_6,PD_7,PB_3); -DHT11 dato(PC_5); -DS1307 my1307(PB_7,PB_8); -Ticker flipper1; -Ticker flipper2; -///////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////// DECLARACION DE VARIABLES GLOBALES //////////////////////////////////// +Keypad teclado(PC_8,PC_11,PC_7,PC_6,PB_0,PD_6,PD_7,PB_3);//configuraciones de pines de teclado +DHT11 dato(PC_5);// configuracion de pin de data sensor +DS1307 my1307(PB_7,PB_8);// configuracion de pines de comunicacion I2C(sda,scl) +Ticker flipper1;// configuracion de funcion ticker(interrupcion) +Ticker flipper2;// configuracion de funcion ticker(interrupcion) +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////// DECLARACION DE VARIABLES GLOBALES //////////////////////////////////////////////// int rtc=0; int sec=0; int mins=0; @@ -28,32 +27,23 @@ int year=0; int muestreo; int z; -char key; -int released; +char key;// variable usada en el teclado +int released;// variable usada en el teclado int s; // variable usada en rutina sensor -int temp; -int temp1; -int hum; -int avrtemp; -int avrhum; -int conteo; +int temp;// +int temp1;// +int hum;// +int avrtemp;// +int avrhum;// +int conteo;// //////////////////////////////Declaracion de funciones/////////////////////////////////////////////////////////// - void test_rw(int test); +void lecturads1307(); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////// SUB-RUTina lectura DS1307///////////////////////////////////////////// void lecturads1307(){ - // test_rw(my1307.gettime(&sec,&mins,&hours,&day,&date,&month,&year)); my1307.gettime(&sec,&mins,&hours,&day,&date,&month,&year); - /*pc.printf("seconds set are %.2D \n\r",sec); - pc.printf("minutes set are %.2D\n\r",mins); - pc.printf("hours set are %.2D\n\r",hours); - pc.printf("day set are %.2D\n\r",day); - pc.printf("date set are %.2D\n\r",date); - pc.printf("month set are %.2D\n\r",month); - pc.printf("year set are %.2D\n\r",year); - wait(1);*/ pc.printf("DATE:\r"); pc.printf("%.2D",day); pc.printf(":%.2D",month); @@ -62,27 +52,21 @@ pc.printf(":%.2D",mins); pc.printf(":%.2D\n\r",sec); } -////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////// SUB-RUTina INTERRUPCION2///////////////////////////////////////////// void flip2(){ conteo=conteo + 1; temp1=dato.readTemperature(); muestreo=muestreo+temp1; - - - if (conteo==1000){ avrtemp=(muestreo/conteo) ; pc.printf("*PROMEDIO DE TEMPERATURA: \r"); pc.printf("%2d C \r ",avrtemp); conteo=0; } - } - -///////////////////////////////////////////////////////////////////////////////////////////////////////////// - +//////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////// SUB-RUTina INTERRUPCION1///////////////////////////////////////////// void flip1(){ @@ -97,19 +81,15 @@ pc.printf(":%.2D",mins); pc.printf(":%.2D\n\r",sec); pc.printf("**********FIN DE REGISTRO DE DATOS**********\n\r"); - - - + } - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////// SUB-RUTina test DS1307///////////////////////////////////////////// void test_rw(int test){ if(test==0) pc.printf("Last R/W operation passed\n\r"); else pc.printf("Last R/W operation failed\n\r"); } -////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////// SUB-RUTina DS1307 calibracion de tiempo///////////////////////////////////////////// void DS1307RTC(){ int junk=0; @@ -152,8 +132,8 @@ //} } -/////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////// SUB-RUTina keypad///////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////// SUB-RUTina keypad//////////////////////////////////////////////////// void keypad1(){ // while(1){ key=teclado.ReadKey(); @@ -166,7 +146,7 @@ //} } -/////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////// SUB-RUTina SENSORE DHT11///////////////////////////////////////////// void sensor(){ s=dato.readData(); @@ -176,32 +156,26 @@ else{ lcd.cls(); return; - - } pc.printf("Temperatura:%d C \r ",dato.readTemperature()); //lcd.locate(0,1); //lcd.printf( "Hr:%d hr SP: 75 ",dato.readHumidity()); pc.printf("Humedad:%d Hr \r ",dato.readHumidity()); - - } -/////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////// SUB-RUTINA MENU///////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////// SUB-RUTINA MENU/////////////////////////////////////////////////// void menu(){ //char tr; while(1){ key=teclado.ReadKey(); keypad1(); - if(key=='D' ){ lcd.cls(); return; } //tr=key; - //void inicial(); - + //void inicial(); lcd.locate(0,0);// LOCALIZA INICIO DE TEXTO EN COLUMNAS Y FILAS lcd.printf( " Menu " ); lcd.locate(0,1); @@ -230,9 +204,7 @@ //} sensor(); - lecturads1307(); - - + lecturads1307(); //temp:dato.readTemperature(); //hum: dato.readHumidity(); //lcd.locate(0,0); // LOCALIZA INICIO DE TEXTO EN COLUMNAS Y FILAS