SISTEMA DE MEDICION DE TEMPERATURA CON CONTROL SERIAL

Dependencies:   mbed TextLCD

PROYECTO FINAL CONTROL DE TEMPERATURA POR PUERTO SERIAL

El siguiente proyecto representa un prototito de medicion de temperatura utilizando librerias mbed. Para este ejemplo se utilizo el sensor LM35 con la siguiente configuracion como muestra en la siguiente figura. https://os.mbed.com/media/uploads/jlemap/lm35.jpg

Las diferentes temperaturas son simuladas mediantes 4 leds.

Led 1 Azul Alarma temperatura baja <25grados C

Led 2 Verde temperatura normal desde >25-30 grados C

Led 3 Amarillo temperatura media alta >30 hasta 35 grados C

Led 4 Rojo Alarma temperatura Alta >40 grados C

Al iniciar la programacion de escalizo el sensor de temperatura donde se midio con un multimetro que mide 10mv por grado de temperarura. Este es un dato importante para entender el programa en el compilador esta programado de la siguiente manera.

sensor=ain.read()*290; Donde los 290 significa 29 grados centigrados.

Para visualizar los grados de temperatura se utilizo una LCD 16*2 donde esl costo es de $5 La configuracion de los pines de la pantalla es la siguiente.

VCC -GND

VDD-5V

VO-Contraste con una resistencia de 1k

RS-PB7

RW-GND

E-PB8

D4-PB15

D5-PB14

D6-PB13

D7-PB12

A-VCC con una resistencia de 220 ohmios

K-GND

Se representa en la siguiente imagen.

https://os.mbed.com/media/uploads/jlemap/lcd16x2_interfacing.png

Para visualizar en la pantalla se utilizo la siguiente libreria.

#include "TextLCD.h"

TextLCD lcd(PB_7, PB_8, PB_15, PB_14, PB_13, PB_12);

while(1) {

lcd.locate(0,0);

lcd.printf("sensor:%2.3f%",sensor);

lcd.printf("ALAR TEMP. BAJA \n");

device.printf("ALARMA TEMPERATURA BAJA\n");

Se reprenta las siguientes imagenes del proyecto.

https://os.mbed.com/media/uploads/jlemap/img_20200215_123438.jpg


https://os.mbed.com/media/uploads/jlemap/img_20200215_123418.jpg

El programa es el siguiente.

  1. include "mbed.h"

#include "sub_temp.h"

  1. include "TextLCD.h"

AnalogIn ain(PC_1);

DigitalOut led1(PD_13); rojo

DigitalOut led2(PD_12); amarillo

DigitalOut led3(PD_14);verde

DigitalOut led4(PD_15);azul

float sensor=0;

Serial device(PA_2,PA_3,115200);

TextLCD lcd(PB_7, PB_8, PB_15, PB_14, PB_13, PB_12);

int main()

{

device.baud(115200);

while(1) {

lcd.locate(0,0);

lcd.printf("sensor:%2.3f%",sensor);

sensor=ain.read()*290;

wait(0.5);

if (sensor < 25) {

led3=0;

led1=0;

led2=0;

led4=1;

lcd.locate(0, 1);

lcd.printf("ALAR TEMP. BAJA \n");

device.printf("ALARMA TEMPERATURA BAJA\n");

}

if (sensor>=25 and sensor<30) {

wait(0.5);

led3=1;

led1=0;

led2=0;

led4=0;

lcd.locate(0, 1);

lcd.printf("TEMPER. NORMAL \n");

device.printf("TEMPERATURA NORMAL\n");

}

if (sensor>=30 and sensor<35) {

wait(0.5);

led2=1;

led1=0;

led3=0;

led4=0;

lcd.locate(0, 1);

lcd.printf("TEMPER. MEDIANA \n");

device.printf("TEMPERATURA MEDIANA\n");

}

if (sensor>=35) {

wait(0.5);

led1=1;

led2 = 0;

led3=0;

led4=0;

lcd.locate(0, 1);

lcd.printf("ALAM TEMP. ALTA \n");

device.printf("ALARMA TEMPERATURA ALTA\n");

}

comparacion();

device.printf("Valor de temperatura:%2.3f grados%\n",sensor);2.1

device.printf("ain:%2.3f grados%\n",sensor);2.1

/* if(sensor>=40.0) { TEMPERATURA >=50 GRADOS LED ROJO

wait(0.5);

led1=1;

device.printf("ALARMA TEMPERATURA ALTA\n");

} else {

wait(0.5);

led1=0; }

if(sensor>=30.0 and sensor<40.0) { TEMPERATURA DE 30-40 GRADOS LED AMARILLO

wait(0.5);

led2=1;

device.printf("TEMPERATURA NORMAL");

} else {

led2=0;

}

if(sensor>=12.0 and sensor<30.0) { TEMPERATURA DE 12-30 GRADOS LED VERDE

wait(0.5);

led3=1;

device.printf("TEMPERATURA MEDIA BAJA\n");

} else {

led3=0;

}

if(sensor<12.0) { TEMPERATURA DE 0-12 GRADOS LED AZUL

wait(0.5);

led4=1;

device.printf("ALARMA TEMPERATURA BAJA\n");

} else {

led4=0;

}

  • /

wait(0.2);

} }

Files at this revision

API Documentation at this revision

Comitter:
jlemap
Date:
Sat Feb 15 17:16:55 2020 +0000
Commit message:
PROYECTO FINAL DE TEMPERATURA MAESTRIA

Changed in this revision

TextLCD.lib 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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Sat Feb 15 17:16:55 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Feb 15 17:16:55 2020 +0000
@@ -0,0 +1,108 @@
+#include "mbed.h"
+//#include "sub_temp.h"
+#include "TextLCD.h"
+
+AnalogIn ain(PC_1);
+DigitalOut led1(PD_13); //rojo
+DigitalOut led2(PD_12); //amarillo
+DigitalOut led3(PD_14);//verde
+DigitalOut led4(PD_15);//azul
+
+
+float sensor=0;
+Serial device(PA_2,PA_3,115200);
+
+TextLCD lcd(PB_7, PB_8, PB_15, PB_14, PB_13, PB_12);
+
+int main()
+{
+
+    device.baud(115200);
+
+    while(1) {
+        lcd.locate(0,0);
+        lcd.printf("sensor:%2.3f%",sensor);
+        sensor=ain.read()*290;
+        wait(0.5);
+        if (sensor < 25) {
+            led3=0;
+            led1=0;
+            led2=0;
+            led4=1;
+            lcd.locate(0, 1);
+            lcd.printf("ALAR TEMP. BAJA      \n");
+            device.printf("ALARMA TEMPERATURA BAJA\n");
+        }
+        if (sensor>=25 and sensor<30) {
+            wait(0.5);
+            led3=1;
+            led1=0;
+            led2=0;
+            led4=0;
+            lcd.locate(0, 1);
+            lcd.printf("TEMPER. NORMAL  \n");
+            device.printf("TEMPERATURA NORMAL\n");
+        }
+        if (sensor>=30 and sensor<35) {
+            wait(0.5);
+            led2=1;
+            led1=0;
+            led3=0;
+            led4=0;
+            lcd.locate(0, 1);
+            lcd.printf("TEMPER. MEDIANA  \n");
+            device.printf("TEMPERATURA MEDIANA\n");
+        }
+        if (sensor>=35) {
+            wait(0.5);
+            led1=1;
+            led2 = 0;
+            led3=0;
+            led4=0;
+            lcd.locate(0, 1);
+            lcd.printf("ALAM TEMP. ALTA      \n");
+            device.printf("ALARMA TEMPERATURA ALTA\n");
+        }
+        //comparacion();
+
+        device.printf("Valor de temperatura:%2.3f grados%\n",sensor);//2.1
+//        device.printf("ain:%2.3f grados%\n",sensor);//2.1
+        /*        if(sensor>=40.0) { //TEMPERATURA >=50 GRADOS LED ROJO
+                     wait(0.5);
+                     led1=1;
+                     device.printf("ALARMA TEMPERATURA ALTA\n");
+                 } else {
+                     wait(0.5);
+                     led1=0;
+                 }
+                 if(sensor>=30.0 and sensor<40.0) { //TEMPERATURA DE 30-40 GRADOS LED AMARILLO
+                     wait(0.5);
+                     led2=1;
+                //            device.printf("TEMPERATURA NORMAL");
+                 } else {
+                     led2=0;
+                 }
+
+                 if(sensor>=12.0 and sensor<30.0) { //TEMPERATURA DE 12-30 GRADOS LED VERDE
+                     wait(0.5);
+                     led3=1;
+
+                     device.printf("TEMPERATURA MEDIA BAJA\n");
+                 } else {
+                     led3=0;
+                 }
+
+                 if(sensor<12.0) { //TEMPERATURA DE 0-12 GRADOS LED AZUL
+                     wait(0.5);
+                     led4=1;
+                     device.printf("ALARMA TEMPERATURA BAJA\n");
+                 } else {
+                     led4=0;
+                 }
+
+         */
+//       wait(0.2);
+
+
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Feb 15 17:16:55 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file