This project uses a DHT11 temperature and humidity sensor and an LDR to measure humidity, temperature and light levels and display the values on an LCD.
You can set this up in your home to measure temperature, humidity and light.
A DHT11 temperature and humidity sensor and an LDR are used to measure temperature, humidity and light respectively. The values are sent to the Arduino which then displays them on the LCD.
Components You’ll need
Here are the components you’ll need for this project
- Arduino Uno
- DHT11 Temperature and humidity sensor
- LCD with I2C backpack (I2C backpack not required)
- Solderless Breadboard
- 10k potentiometer
- A number of male to male jumpers
If you live in Ghana, you can get these components from Invent Electronics. If you live elsewhere, look for an electronics or hobby store near you.
Here is a breadboard circuit of the project designed in Fritzing.
We are going to be using the LCD in the I2C mode with the I2C backpack connected. You will have to install the LDC I2C library if you haven’t done so already or if you don’t know how to do that, check out this I2C LCD backpack tutorial that I wrote before proceeding.
NOTE: If your DHT11 sensor comes on a breakout board with only 3 pins, connect the 1st pin to VCC, the middle pin to your Arduino digital input and the last pin to ground and ignore the 1k resistor as shown in the Fritzing circuit.
If your LDR also comes on a breakout board with 3 pins, you won’t need the potentiometer shown on the Fritzing diagram. Just connect the pins to the appropriate Arduino pins as indicated on the breakout board.
In order to use the DHT11 temperature and humidity sensor with an Arduino, you will have to download and install a DHT11 library. In this tutorial, I use Adafruit’s DHT library. Download the DHT11 Arduino library from Adafruit and the Adafruit Sensor library and extract it into your Arduino libraries folder. Check out this Sparkfun tutorial on how to install an Arduino library if you don’t know how to do so already.
Here is the code for the project
By: Isaac Sesi - Current City
Date: 28th January, 20170
#include "Wire.h" // For I2C
#include "LCD.h" // For LCD
#include "LiquidCrystal_I2C.h" // Added library*
#define DHTPIN 10
#define DHTTYPE DHT11
int ldr = A3;
DHT dht(DHTPIN, DHTTYPE);
//Set the pins on the I2C chip used for LCD connections
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7); // 0x27 is the default I2C bus address of the backpack-see article
// Set off LCD module
lcd.begin (16,2); // 16 x 2 LCD module
lcd.setBacklightPin(3,POSITIVE); // BL, BL_POL
// pinMode(DHTPIN, INPUT);
int ldrValue = analogRead(ldr);
float humidity = dht.readHumidity();
float temp = dht.readTemperature();
Here’s how the final project looks like. If all goes well, you should have something like this.
So, that’s it!
I hope you enjoyed this tutorial. Please leave a comment. The feedback gives me a lot of motivation to do more tutorials.