DHT11 Temperature & Humidity sensor with Arduino – Tutorial

We have an you know, but you could use a mini a micro, whatever you have on hand, so lets make the connections Im going to use a breadboard. So you can see the connections a little bit better. So Im going to put my sensor right here as so and were going to start by making the ground connection from our Arduino to the negative pin of the sensor right there and then Ill. Do my single pin to analog zero or a zero on the uno to the center pin of the sensor like that and last its going to be the voltage so five volt to the plus pin on the sensor like that and thats it thats all the connections. We need to make so were going to go to the computer screen to look at the code and then well upload the code to our uno and start receiving data from our little sensor here that we can monitor and the serial monitor so well be right. Back. Okay, so where we are, this is the old code right here to get the information from our dht11. As you can see here at the top, we have an include library and you need to download that if youre on youtube find the link below and if youre on a website, you should see the link. So basically, we put that library in our app where we install arduino in the libraries folder, so arduino libraries and its a folder, so DHT and inside youll find two files which has the information to actually access our humidity and temperature sensor.

So after that were going to go ahead and define an analog pin, we connect it to a zero, so were going to say a zero here, but you could change that to any pin you you connected to the middle sensor, pin to so that doesnt you can Change that to whatever you want as long as its an analog pin – and here we have the set up to basically output and prepare for the serial monitor, so were going to say, sir youll begin 9600. So thats our speed were going to give it a delay of five hundred. So five hundred milliseconds to you know let the system boot up and then were going to put were going to print a title to our serial monitor. You know the HT one humidity and temperature sensor, so that will be the title that will appear when we open our s serial monitor then another delight just wait. Another like a second just before accessing the sensor and well n set up here now. This is the main part of the program right here from void loop and its very simple since were using a library everything that all the prior all the program is basically in the library, so we dont have to put it in here. So its a lot, its a lot easier so were going to read the were going to say: DHT read, dll its a pin so thats our a 0 up. There then, were going to do a serial print current humidity, which is a title equals to serial.

Print DHT humidity, so that information is going to be from the sensor itself and we put a percentage sign after that, because its a percentage humidity and then serial print the Temperature equals to DHT temperatures, temperature, sorry and Celsius. Now you can always change the Celsius to tonight by doing the calculation to actually convert from Celsius. So you change for an F here and you put that x or divided by something the delay after we did all this. So we put a delay of five seconds, so we wait five seconds before accessing the sensor again, because the sensor, I think, get the fastest. You should accessing is every two seconds since it so there you go thats all you need to do to integrate one of these little sensors into your future projects.

Share.
Exit mobile version