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.
¿Cómo conectar el DHT?
Para conectar el DHT11 al Esp8266 necesitaremos:
- Sensor DHT11
- 3 Conectores Famale – Famale
- NodeMCU Esp8266
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.
¿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/
Great article. I will be going through a few of these issues
as well..
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.
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!
I am in fact grateful to the holder of this site who has shared this fantastic piece of
writing at here.
I was suggested this blog by my cousin. I am not sure whether this post is written by him
as nobody else know such detailed about my trouble.
You are amazing! Thanks!
Asking questions are actually good thing if you are not
understanding anything fully, but this piece of writing offers nice understanding yet.
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.
If you desire to obtain a good deal from this article then you have to apply these techniques to your won weblog.
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.
Peculiar article, exactly what I was looking for.
Hi Dear, are you really visiting this site daily,
if so afterward you will definitely take good know-how.
Buy Real And Fake Diplomas at https://fakediplomabar.com/ WhatsApp: ++44 7730754370
Buy Real And Fake Diplomas at https://fakediplomabar.com/ WhatsApp:
++44 7730754370
Buy Real And Fake Diplomas at https://fakediplomabar.com/ WhatsApp: ++44 7730754370
Very nice post. I just stumbled upon your weblog
and wished to say that I’ve really enjoyed surfing around
your blog posts. In any case I’ll be subscribing to your feed and I hope you write again very soon!
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!
This is my first time visit at here and i am genuinely happy to read everthing at one place.
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.
Generally I don’t learn article on blogs,
however I wish to say that this write-up very pressured me to check out and do
so! Your writing taste has been surprised me. Thanks, quite nice post.
You could certainly see your enthusiasm in the work
you write. The world hopes for even more passionate writers such as you who aren’t afraid to mention how they believe.
Always go after your heart.
If you want to increase your experience only keep visiting this website and be
updated with the most up-to-date news update posted here.
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!
It’s really a great and helpful piece of info.
I’m glad that you just shared this useful info with us.
Please keep us informed like this. Thanks for sharing.
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.
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!
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.
Text Inmate
https://www.contactmeasap.com/
You have made some good points there. I checked on the net to find out
more about the issue and found most individuals will go along with your views on this website.
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.
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.