How to display Temperature and Humidity on Serial Monitor using DHT11 sensor on Arduino!

First of all, me being a child always used to get around with motors, batteries, etc making up light circuits to play with. I was always excited about these kinds of stuff. Growing up, I got to know about Arduino microcontrollers which motivated me to make complex circuits with several items like buzzer, LED, etc.

Using Arduino, several models can be made both on a heavy scale and light scale. For those interested in Arduino, I might suggest you buy an Arduino starter kit which might probably have all the items required for this project. Like you know, nothing is easy in the starting phase. In the same way, even getting used to Arduino, the connections and code won’t be that easy in the starting phase. So, I guess that the project below would be a great help for the starters to know and learn about the connections and also coding that works within the Arduino.

The items that we need for this project are jumper wires, Arduino Uno, breadboard, and a DHT11 sensor.

Going towards the code, it’s quite simple. Firstly, we have imported the DHT library to utilize the DHT11 sensor to measure temperature and humidity for the project. Now the required variables are initialized. After this, I have included two main methods void loop and void setup.

As we move to the connections part, all the connections are directly done to the sensor. Here, the 5V and ground connections are done with the sensor itself. Unlike other circuits, here we don’t use the positive and negative rails.

Having done all the connections properly according to the circuit diagram, we can proceed to connect the Arduino to the USB port, and using the Arduino IDE software you can upload the code included below. Those are completely new to this, do select the proper model of your Arduino and select the proper port under appropriate options on the Arduino IDE software. Ultimately, you will be able to view the humidity and temperature results on the Serial Monitor within the IDE. To the freshers again, you need not be connected with the computer anymore, you can just use a source of electricity like a power bank.

Overview – In this project, we will be using a DHT11 sensor to measure temperature and humidity and display it on the Serial Monitor.

Circuit

Serial Monitor Output

Circuit Diagram

Note

You should have dht library added to your libraries in order to upload the code. Also check whether all pins are connected in proper positions.

Code

 #include <dht.h>  
 dht DHT;  
 #define DHT11_PIN 7  
 void setup() {  
  Serial.begin(9600);  
 }  
 void loop() {  
  int chk = DHT.read11(DHT11_PIN);  
  Serial.print("Temperature = ");  
  Serial.println(DHT.temperature);  
  Serial.print("Humidity = ");  
  Serial.println(DHT.humidity);  
  delay(1000);  
 }  
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO