DHT

DHT con NodeMCU Esp8266 + IDE Arduino

El DHT es un sensor digital de temperatura y humedad relativa de bajo costo y fácil uso. Integra un sensor capacitivo de humedad y un termistor para medir el aire circundante, y muestra los datos mediante una señal digital en el pin de datos.

DHT con NodeMCU Esp8266 + IDE Arduino 51 kstImRQL. AC SY355

¿Cómo conectar el DHT?

Para conectar el DHT11 al Esp8266 necesitaremos:

  • Sensor DHT11
  • 3 Conectores Famale – Famale
  • NodeMCU Esp8266
DHT con NodeMCU Esp8266 + IDE Arduino Presentación1

Como podrás observar el sensor tiene 3 pin (VCC, DATA, GND) a los cual le pondremos un conector a cada uno. El conector que esta en VCC la otra punta la ponemos en VCC del Node que sería 3.3V, el que está conectado Data lo colocamos en D4 ya que por ese pin el sensor estará enviando la información y por último GND del sensor a GND del Node.

¿Qué más necesitamos?

Para hacer que nuestro programa reconozca el sensor debemos de incluir dos librerías en nuestro programa, las cuales son DHT-sensor y adafruit_sensor. Los links de descarga son los siguientes.

DHT-Sensor: http://www.arduinolibraries.info/libraries/dht-sensor-library

Adafruit_Sensor: http://forum.arduino.cc/index.php?topic=413067.0

¿Cómo incluir las librerías?

Para incluir las librerías abrimos el IDE Arduino y vamos a Programa/ Incluir Librería/ Añadir biblioteca .ZIP…

Buscamos la ubicación del archivo y aceptamos. Vale aclarar que una vez incluidas la librerias no es necesario volverlo a hacer para un nuevo proyecto.

DHT con NodeMCU Esp8266 + IDE Arduino screenshut

¿Cómo hacer que funcione?

En el código lo primero que tenemos que hacer es incluir la biblioteca del DHT, luego definimos que tipo de DHT es en este caso es DHT11.

Ahora configuraremos el pin al cual va a estar conectado el sensor donde uint8_t es lo mismo que un byte o sea un tipo de entero sin signo de longitud 8 bits, seguido de esto el nombre del pin al cual está conectado el DHT que yo nombre como DHTPin igualado a 2 que es el GPIO de D4.

Declaramos las variables con las cuales vamos a representar más adelante los parámetros en el monitor serie.

En el setup comenzamos iniciando el monitor serie en 9600 baud como lo indica el Node. Pasamos a declarar la función del pin al cual está conectado el sensor, en este caso es entrada INPUT ya que por ahí estaremos recibiendo los datos e iniciamos el sensor.

En el loop le damos paso a la lectura de los parámetros igualando las variables que declaramos.

Estos parámetros los visualizaremos en el monitor serie por tanto debemos de escribir estos parámetros en el monitor serie con el comando Serial.print y Serial.println.

Subimos el programa y una vez que lo hemos subido abrimos el monitor serie para observar si está funcionando.

#include "DHT.h"
#define DHTTYPE DHT11
//Pin del sensor
uint8_t DHTPin=2;
DHT dht(DHTPin, DHTTYPE);
float Temp;
float Hum;
void setup() {
Serial.begin(9600);
//Configuración del pin DHT
pinMode(DHTPin, INPUT);
dht.begin();
}
Void loop() {
//Lectura del DHT
    Temp = dht.readTemperature();
    Hum = dht.readHumidity();
Serial.println(“La temperatura es de: ”);
Serial.print(Temp);
Serial.println(“La humedad es de: ”);
Serial.print(Hum);
}

Para ver nuestro tutorial anterior: https://ciber-tips.com/efectos-con-leds-ide-arduino/

30 comentarios en “DHT con NodeMCU Esp8266 + IDE Arduino”

  1. Everything wrote made a bunch of sense. However, think on this, what
    if you were to create a killer title? I ain’t saying your content isn’t solid., but what if you added
    a headline that grabbed folk’s attention? I mean DHT
    con NodeMCU Esp8266 + IDE Arduino is a little
    boring. You ought to glance at Yahoo’s front page and watch how they create post headlines to grab viewers interested.
    You might add a related video or a related pic or two to grab readers interested about what you’ve got to say.
    In my opinion, it might make your blog a little bit more interesting.

  2. Hi there, I do think your site could be having web
    browser compatibility issues. Whenever I
    take a look at your blog in Safari, it looks fine but when opening in IE,
    it has some overlapping issues. I just wanted to provide you with a quick heads up!
    Other than that, great website!

  3. Hi, I do think this is a great website. I stumbledupon it 😉 I am going to revisit
    once again since i have bookmarked it. Money and freedom
    is the greatest way to change, may you be rich and
    continue to guide others.

  4. After going over a handful of the articles on your site, I honestly
    appreciate your technique of writing a blog. I added it to my bookmark webpage list and will be checking back in the near future.
    Please visit my web site as well and let me know what
    you think.

  5. Hi! This is my first visit to your blog!
    We are a team of volunteers and starting a new initiative
    in a community in the same niche. Your blog provided us useful information to
    work on. You have done a extraordinary job!

  6. Hi, I do think this is an excellent website.

    I stumbledupon it 😉 I am going to revisit once again since
    i have bookmarked it. Money and freedom is the greatest way to change, may you be rich and continue to guide other people.

  7. Hello there, just became alert to your blog through Google, and found
    that it’s truly informative. I am going to
    watch out for brussels. I’ll appreciate if you continue this in future.

    Many people will be benefited from your writing.
    Cheers!

  8. Does your website have a contact page? I’m having
    problems locating it but, I’d like to shoot you an email.
    I’ve got some suggestions for your blog you might be interested
    in hearing. Either way, great blog and I look forward to seeing it develop over time.

  9. Hi! I know this is somewhat off-topic however I had to ask.
    Does operating a well-established website like yours take a massive amount work?

    I’m completely new to operating a blog however I do write in my journal everyday.
    I’d like to start a blog so I can easily share my personal experience and views online.
    Please let me know if you have any kind of recommendations
    or tips for new aspiring blog owners. Thankyou!

  10. Choose the สล็อตxoใหม่ slot game that suits you best. at present The game has many formats. Slots are designed and different symbols Bettors should choose games that they are skilled at and know how to play well. Consider options with high payment rates. and fun that you are satisfied with, especially choosing slots with a lot of reels Has a high winning line and a payout rate of more than 96%, etc., which slot games with this format Help make a lot of money. Slot websites are good and take a short time to win.

  11. Excellent post. I was checking continuously this blog
    and I’m impressed! Extremely useful information particularly the last part :
    ) I care for such information a lot. I was seeking this certain information for a long time.
    Thank you and best of luck.

  12. Fantastic goods from you, man. I have take note your stuff previous to and you’re simply extremely fantastic.
    I actually like what you’ve bought here, really like
    what you are stating and the way in which by which you say it.

    You make it entertaining and you still take care of to stay it sensible.
    I cant wait to read far more from you. This is
    really a terrific site.

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Top arrow