Projeto de microcontroladores para monitoramento de um vaso.

Dependencies:   BME280 LM75B mbed

Fork of Serial_To_Bluetooth_Helloworld_WIZwiki-W7500 by WIZnet

Revision:
1:cf760564ee8e
Parent:
0:22832bff21a1
--- a/main.cpp	Tue Feb 02 08:05:34 2016 +0000
+++ b/main.cpp	Mon Jun 25 01:39:57 2018 +0000
@@ -1,13 +1,34 @@
 #include "mbed.h"
+#include "LM75B.h"
+#include "BME280.h"
+
 
 /* Digital Out Pin Configuration */
-DigitalOut RED(D8,1);
-DigitalOut GREEN(D9,1);
-DigitalOut BLUE(D10,1);
+DigitalOut RED(p23,1);
+DigitalOut GREEN(p24,1);
+DigitalOut BLUE(p25,1);
+
+AnalogIn LDR(p16);// 1 para iluminado e 0.1 para escuro 
+
+AnalogIn moisture(p15); // 1 para seco , 0.47 para molhado
+
+AnalogIn fogo(p17); // 1 para fogo e 0.6 pra suave 
+
+DigitalOut motor(p21);// 1 para ligado , 0 para desligado
+
+DigitalIn presente(p5);// 1 tem alguem , 0 nao tem ninguem
 
 /* UART Pin Configuration */
 Serial pc(USBTX, USBRX);    
-Serial bt(D1,D0);           
+Serial bt(p13,p14); 
+
+ 
+
+#if defined(TARGET_LPC1768)
+BME280 thp(p28, p27); // scl no 27,
+#else
+BME280 thp(I2C_SDA, I2C_SCL);
+#endif         
 
 
 int main(void)
@@ -16,44 +37,69 @@
     pc.baud(115200);
     bt.baud(9600);
     
+    
     pc.printf("WIZwiki-W7500 BT\n\r");
     
     char ch;
     char msg[256];
     
-    while(1)
-    {
-        /* WIZwiki-W7500 to Bluetooth */
-        if(pc.readable())
+    
+    float vfogo = 0.0f;    
+    float value = 0.0f;
+       
+        
+        while(1)
         {
-            pc.scanf("%s",&msg);
-            bt.printf("%s",msg);
-        }
-        
-        /* Bluetooth to WIZwiki-W7500 */
-        if(bt.readable())
-        {
-            ch = bt.getc();
-            pc.putc(ch);
+            
+                
+            value = moisture;
+            vfogo = fogo;
+            if (vfogo >= 0.6){
+                bt.printf ("TA PEGANDO FOGO BIXOOO\n");
+                }    
+            if (value <= 0.5){
+                motor = 1;
+                wait(0.8);
+                motor =0;
+                }
+            if (presente == 1){
+                bt.printf("\n OPA!!!! \n Tem Alguem Aqui");
+                }
+            wait(1.0);
             
-            /* Control 3 colors LED */
-            if(ch == 'r'){
-                RED = !RED;
-                /* Notice RED LED condition to Bluethooth */
-                if(RED == 0)    bt.printf("RED ON");
-                else            bt.printf("RED OFF");
-            }else if(ch == 'g'){
-                GREEN = !GREEN;
-                /* Notice GREEN LED condition to Bluethooth */
-                if(GREEN == 0)    bt.printf("GREEN ON");
-                else              bt.printf("GREEN OFF");
-            }else if(ch == 'b'){
-                BLUE = !BLUE;
-                /* Notice BLUE LED condition to Bluethooth */
-                if(BLUE == 0)    bt.printf("BLUE ON");
-                else             bt.printf("BLUE OFF");
+
+            /* WIZwiki-W7500 to Bluetooth */
+            if(pc.readable())
+            {
+                pc.scanf("%s",&msg);
+                bt.printf("%s",msg);
             }
+            
+            /* Bluetooth to WIZwiki-W7500 */
+            if(bt.readable())
+            {
+                ch = bt.getc();
+                pc.putc(ch);
+                
+    
+                if(ch == 'r'){
+                    /* Mostra todas as Informações da estufa */
+                    bt.printf ("\n\n\n\n\n\n\n\n\n\n\n\n\n");
+                    bt.printf ("MWMWMWMWMWMWMWMWMWMW\n");
+                    bt.printf ("Luminosidade = %f\n", LDR.read());
+                    bt.printf ("Humidade do Solo = %f\n", (float)value);
+                    bt.printf ("Pressao = %04.2f hPa\n", thp.getPressure());
+                    bt.printf ("Temperatura = %2.2f °C\n", thp.getTemperature());
+                    bt.printf ("MWMWMWMWMWMWMWMWMWMW\n");
+                    bt.printf ("\n");
+                    
+                }else if(ch == 'g'){
+                    motor = 1;
+                    wait(0.8);
+                    motor =0;
+                }
+            }
+            
         }
-        
     }
-}
+