How to Use ESP32 with DHT11 Temperature and Humidity sensor and Arduino IDE

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys harsh here back in the video so in this video I'll be showing you how you can connect the dst11 temperature and humidity sensor with esp32 board and this is just a simple basic video on how you can get started with the esp32 model and collect data from different types of sensors so without wasting time let's get started so to make this happen obviously you will need the esp32 model as you can see I have the W room 32 module over here and this is a huge upgrade from the esp8266 model because I really wanted the analog to digital film converter so that's why I bought this particular module then to read our temperature and humidity we will use the DST 11 sensor you can also use the dsd22 sensor which has a lot more accuracy and temperature range but this is quite cheaper to get so if you are just building a small project then this would just work fine then we will in a breadboard to connect all these together and some jumper wires so let's start off by placing the esp32 on the breadboard and as you can see this the breadboard is actually quite small for the esp32 so I will just use one side one row over here on this side and and the rest will remain in use so I will just this in place just like so and as you can see right now it's placed in perfectly and the pins are poking out from here so if you want to do some further connection you can just use the female jumper wire to do that so now let's connect our DHT 11 sensor we will first connect the power which is 3.3 volts and will connect it to the VCC on the DHT 11 sensor which is the topmost PIN then we will connect the ground which is the bottom hose pin as you can see and we will obviously connect it to the ground on the esp32 model which is right over here next to the 3.3 volts now we will connect the digital pin number four which is labeled as D4 as you can see over here and we will connect it to the data output of the dhd11 sensor just like so so that's it for the connection now we can go ahead and connect the micro USB cable from here to our computer and program the board okay so before we do anything further first we need to make sure that our Arduino IDE is capable of programming the esp32 board so first of all what you have to do is just copy this link I have given it in the description then what you have to do is just go to files then click on preferences so here you will find the additional board manager URL and you have to paste your link here just like so I have done over here but let's say if you have a additional link then you can just place in comma and then paste the link so as you can see I have put a comma right over here so this is my esp8266 package that I have installed previously and then I put a comma then pasted the link for the esp32 package so after that you can just go ahead and click on OK then head over to tools and go to the boards and select the board managers so this little window will open up and it will update the boards manager so on the search bar on the top you have to type in esp32 so this will show up and all you have to do is just click on the install button as you can see I have already installed it so that's why I am not getting the install option but it will just show up right here so once that's installed you can go ahead and close it and restart your Arduino IDE so here is the code that we'll upload on the esp32 board and first we will install our DST library because without using the library this will be a pretty tough code to code so just go to sketch and then go ahead and click on lgrew library and then manage lab so in this you have to install two different libraries so first we'll type the dht11 and here you can see the GST sensor Library by Adafruit and you have to install this particular Library this will allow you to use dht11 and DHT 22 sensor so that's pretty nice then you have to install the second Railway ready which is Adafruit unified sensor Library so just type unified over here and just scroll down a bit then you will see this particular Library over here so install this as well now coming to the code we can see obviously we have included the DST Library over here then here we have defined the pin number for which our DST 11 sensor is connected to so in this case it's pin number four obviously you can use any pin you like and this directly translates to the gpio number of the esp32 board so if you remember on the ESP board we have d4d22 like that sort of number and that directly translates to the GPI number of that particular print now coming to the type we have to define the DST type will which will be dst11 obviously if you are using the dst22 sensor then all you have to just do this so now you're using the dst2 now here we can see we are initializing the DST liability so we are initializing it with the pin and the DHT type which is obviously 11 and 4. now in the setup function you can see we are defining the serial with 9600 word rate and we are initializing the DST Library over here as you can see with the dot begin then in the loop function first we are reading the temperature in Celsius because there is nothing in the brackets over here but if you want to read the temperature in fahrenheit then you can just set it to true and obviously if I set it to false over here it will just act basically act as the same thing so if you set it to false it will get the readings in celsius if you set it to true then it will get the readings in Fahrenheit then in this line obviously we are reading the humidity with the daughter eat humidity function and below that you can see we are printing all these in a nice pattern so first we will print temperature in celsius than in Fahrenheit and then at the last we'll print our humidity in all same line and then at last move on to the different line and print our new rating so let's just go to tools and select our board which will be the esp32 dev module in this case as you can see right over here and all these other thing I think are pre-selected so we don't need to chain anything here but obviously if you're getting some errors then you might need to fiddle with these settings a bit but for me it's working fine I will just leave it at that then we will select our com port in which our esp32 board is connected which is com5 in my case so we'll just select that and once it is all done then you can just go ahead and simply click on upload and this will first compile the sketch and upload the code to the esp32 module so finally itself done uploading and it took a lot of time because the esp32 module is not very good with the Arduino ID so takes a lot of time to compile and upload the code so now once the code is done compiling and uploaded to the board we can just go ahead and open a silly monitor just by clicking this button over here and obviously if you don't get this button here for some reason then obviously you can go to tools and then just click the serial monitor here so you might be seeing that I am getting a lot of gibberish text over here for some reason and that is because my birth rate is a mismatched so as you can see the serial dot backend it the bud rate is 9600 and in the serial monitor it is at 74880 so all you have to do is just change the word rate so just go to the budget option and click on 9600 this will clear up the screen and now you will get your temperature reading sensor so as you can see temperature 35.4 degree celsius and in Fahrenheit it is 95.72 humidity is at 38 so if you want to test it out you can just blow on the sensor and watch the temperature go up so I just blown on the sensor and as you can see the temperature went up to 36 and the humidity obviously at 95 and if you leave it for some time then it will revert back to its room settings so so there it is guys that's how you can read the temperature and humidity data from the dht11 sensor on your esp32 module so thanks for watching video guys if you have any doubts regarding this video you can comment down below I will try to answer them as soon as possible so until then I will see you all later
Info
Channel: INOVATRIX
Views: 6,118
Rating: undefined out of 5
Keywords: #creative, #hobby, #inovation
Id: yQxk5pGRUYg
Channel Id: undefined
Length: 8min 3sec (483 seconds)
Published: Tue May 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.