5151+ reviews
Order by 16:00 for same day shipping
14 days return
EN
Individual
Business
If you ever wonder what the humidity level is in your home, this project is for you!
During this project you will learn how to make a humidity meter using a DHT11 sensor and a 16X2 LCD display. A DHT11 is a sensor that measures temperature and humidity. With the display you have the choice whether or not you want to add it. If you do want to add a display you can choose whether you want to connect it with or without I2C. The different versions are listed below.
Now that you have all the parts you can start wiring.
You will need five cables for wiring.
A cable goes from the 5V on the Arduino to the positive of the breadboard and from the ground on the Arduino to the negative of the breadboard.
Once you have done that, insert the DHT11 into the breadboard with the blue side facing you. This is also how we define the pins.
Now you go with a cable from the I/O pin 8 to the leftmost pin of the DHT11, then a cable from the middle pin of the DHT 11 to the positive of the breadboard and a cable from the rightmost pin to the negative of the breadboard.
It is important that you connect the cables in the correct order, otherwise your values will not be correct.
//hier importeren we de DHT library
#include <DHT.h>
//nu geven we de DHT11 een naam
dht DHT;
//en defineren zijn pin
#define DHT11_PIN 8
void setup()
{
//hier starten we de seriële connectie
Serial.begin(9600);
}
void loop()
{
//hier lezen we de sensor waardes
int chk = DHT.read11(DHT11_PIN);
//en zorgen dat ze in de seriële com te zien zijn
Serial.print(“Humidity: “);
Serial.print(DHT.humidity);
Serial.print(” %, Temp: “);
Serial.print(DHT.temperature – 5);
Serial.println(” Celsius”);
delay(2000);
}
Now that you have connected the display, you can start programming it.
You need to use the LiquidCrystal library for this, which is standard in the Arduino IDE. Once you have imported it, you can start copying the code below.
//hier importeren we de DHT library
//en de LiquidCrystal library
#include <dht.h>
#include <LiquidCrystal.h>
//op deze plek defineren we de LCD pinnen
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
//hier geven we de DHT11 een naam
dht DHT;
//en defineren zijn pin
#define DHT11_PIN 8
void setup(){
//nu selecteren we de LCD lampjes
lcd.begin(16, 2);
}
void loop()
{
//nu lezen we de waardes van de DHT11
int chk = DHT.read11(DHT11_PIN);
//en hier zorgen we dat ze
//op het beeldscherm komen
lcd.setCursor(2,0);
lcd.print(“Temp: “);
lcd.print(DHT.temperature – 5);
lcd.print(“C”);
lcd.setCursor(2,1);
lcd.print(“Humi: %”);
lcd.print(DHT.humidity);
delay(2000);
}
In this step I will show you how to connect an I2C LCD. The advantage of this is that the display only needs four jumper wires in total and is standalone.
It is important that you import the LiquidCrystal_I2C library and the Wire library for this, otherwise you will not be able to control the screen.
The LiquidCrystal_I2C library can be found if you go to sketch in the Arduino IDE, then to use library and then click on manage library. Then you should see a pop-up tab there you will see a search bar on the top right. Type LiquidCrystal_I2C there and select one and then click on install. Do the same with the Wire library.
Now you will start wiring.
First, a jumper wire goes from the 5V on the Arduino to the positive of the breadboard and a jumper wire goes from the GND on the Arduino to the negative of the breadboard.
Then you connect the GND of the I2C LCD to the minus, the VCC to the plus, SDA to A4 and SCL to A5.
The connection for the DHT 11 is the leftmost pin to I/O pin 8, the middle pin to positive, and the rightmost pin to negative.
Now you will modify the LCD program so that you can control the I2C LCD with it.
Make sure you have imported the wire and the LiquidCrystal_I2C library. Once you have that you can make a few small changes and your program will work on an I2C LCD display.
//hier importeren we de juiste librarys
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <dht.h>
//hier laten we het programma weten wat het I2C adres
//is en dat het een 16 bij 2 beeldscherm is
LiquidCrystal_I2C lcd(0x3F,20,4);
dht DHT;
#define DHT11_PIN 8
void setup(){
lcd.begin(16, 2);
//hier initializeren we de lampjes van
//het beeldscherm het is belangrijk dat je 2 keer
//lcd.init() hebt wantanders werkt je programma niet
lcd.init();
lcd.init();
lcd.backlight();
}
void loop()
{
int chk = DHT.read11(DHT11_PIN);
lcd.setCursor(2,0);
lcd.print(“Temp: “);
lcd.print(DHT.temperature – 8);
lcd.print(“C”);
lcd.setCursor(2,1);
lcd.print(“Humi: %”);
lcd.print(DHT.humidity);
delay(2000);
}