IoT 101: Leyendo Un Sensor De Humedad Y Temperatura DHT Con Blynk YPhoton
by gmendez3 in Circuits > Microcontrollers
2501 Views, 1 Favorites, 0 Comments
IoT 101: Leyendo Un Sensor De Humedad Y Temperatura DHT Con Blynk YPhoton


Para este segundo tutorial de IoT vamos a utilizar un sensor de temperatura y humedad para poder medir estos valores y mandarlos a una app hecho con blynk.
Supplies
Para este proyecto necesitamos:
- Una computadora con Internet
- Un Smartphone con Android o iOS
- Un sensor DHT11
- Una tarjeta Photon, de Particle https://www.particle.io/
- Breadboard
- Cable USB
Además necesitamos descargar las siguientes aplicaciones:
- Blynk
- Particle
Creando El Circuito
.png)










Para crear nuestro circuito, vamos a usar un breadboard y hacer la siguiente conexión:
Photon--->DHT11
GND--> GND
3V3-->Vcc
D2--> DAT o S según el sensor
Igualmente puede seguir las fotografías o bien el diagrama de fritzing.
Creando La App En Blynk





- Empezamos un nuevo proyecto dándole click a "New project" en Blynk
- Ahora le ponemos el nombre humedadTemperatura y seleccionamos Particle Photon
Le damos "create" y esto nos generará un nuevo token, recuerda que para cada app hay un token especial. Si no sabes que es un token, puedes visitar el proyecto pasado: https://www.instructables.com/id/IoT-101Prendiendo...
Ahora vamos a crear dos botones, yendo al símbolo de más en la parte superior derecha de nuestra app:
- Para la humedad, vamos a utilizar un "Value Display" o Monitor de valores.
- Para la temperatura un "Guage" o Indicador
Configurando Los Botones En Blynk


Para el monitor de valores:
- Pondremos el nombre "Humedad"
- Le diremos que recibirá la información de un pin virtual V5
- Y le diremos que recibirá los datos con "PUSH"
Para el Indicador, donde veremos la temperatura:
- Pondremos el nombre "Temperatura"
- Le diremos que recibirá la información de un pin virtual V6
- Y le diremos que recibirá los datos con "PUSH"
- La escala la limitaremos a 50, osea 50°C
Buscando El Programa De Ejemplo En Examples.blynk.cc
.png)
Vamos a “https://examples.blynk.cc” y buscamos el archivo del sensor DHT 11, lo copiamos.
Agregando Las Librerías
.png)
.png)
.png)
.png)
.png)
.png)
.png)
.png)
.png)
.png)
.png)
.png)
- Ahora vamos al Particle Web IDE y creamos un nuevo código llamado “HumedadYTemperatura”
- Pega el archivo que copiaste de “examples”
Ahora vas a ir a las bibliotecas o "Libraries" y vas a buscar las siguientes:
- blynk
- DHT
- Adafruit sensor
Para cada una, al encontrarla, le damos click y posteriormente le damos:
- Include in Project y elegimos el proyecto HumedadYTemperatura
- Después le damos confirmar o CONFIRM
De esta manera deberemos ver al inicio de nuestro código que se agregan las librerías así:
// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_Sensor.h>
// This #include statement was automatically added by the Particle IDE.
#include <DHT.h>
// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>
Modificando Y Flasheando El Código

- Agregar el token
- Ahora lo cargamos dando click en el ícono de rayo en la parte superior izquierda.