Está en la página 1de 4

Proyecto 3

UEA: Microcontroladores
Profe: Jaimes Ponce Jorge Miguel
Matricula: 2203030275
Alumno: Granados Gonzalez Juan Carlos
En este proyecto se hizo una aplicación en APP inventor y un código en Arduino, en que se basa
esto, en que estos dos códigos se conecten vía Bluetooth a tu celular o dispositivo, y los datos que te
mandara es la humedad del medio en el que estas y su temperatura
Este es el código que se diseño.
#include <BluetoothSerial.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#define DHTPin Sens_DHT11
const byte Sens_DHT11=19;
DHT Sens_DHT(DHTPin,DHT11);
float hum=0;
float temp=0;
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enable! Please run `make menuconfig` to and enable it
#endif
#define Led_1 23
char dato;
BluetoothSerial SerialBT;
void setup()
{
Sens_DHT.begin();
Serial.begin(115200);
SerialBT.begin("ESP32JuanGr");
Serial.println("Dispositivo iniciado, ahora puede ser dado de alta por BT");
pinMode(Led_1,OUTPUT);
}
void loop()
{
hum=Sens_DHT.readHumidity();
temp=Sens_DHT.readTemperature();
SerialBT.print(hum);
SerialBT.print(" &HR");
SerialBT.print(" , ");
SerialBT.print(temp);
SerialBT.print(" °C");
delay(1000);
On_Off();
}
void On_Off()
{
if(Serial.available())
{
}
if(Serial.available())
{
dato=SerialBT.read();
Serial.write(dato);
if(dato=='A')
{
digitalWrite(Led_1,HIGH);
}
if(dato=='X')
{
digitalWrite(Led_1,LOW);
}
}
}
Esto es lo que se hizo en App Inventor, es el código y la presentación de la App:
Así es como se ve en el celular:
De esta forma va conectado al ESP32:

También podría gustarte