FrAgFo0d
Published © MIT

Arduino DTH22 Humidity Temperature With LCD I2C 16x2 Display

Check the humidity & temperature of your terrarium with a DTH22 humidity and temperature sensor and display this on an LCD I2C 16x2 display.

BeginnerFull instructions provided94,577
Arduino DTH22 Humidity Temperature With LCD I2C 16x2 Display

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1
White on Blue 16×2 LCD Module with I2C Backpack Module – 5V
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
9V battery (generic)
9V battery (generic)
×1
Adafruit 9V battery clip with 5.5mm/2.1mm plug
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Male/Male Jumper Wires
×1

Story

Read more

Schematics

Fritzing Schema

Schema Fritzing

Schema

Code

hygroThermo.ino

C/C++
/* How to use the DHT-22 sensor with Arduino uno
   Temperature and humidity sensor
   More info: http://www.ardumotive.com/how-to-use-dht-22-sensor-en.html
   Dev: Michalis Vasilakis // Date: 1/7/2015 // www.ardumotive.com 
*/

//Libraries
#include <DHT.h>
#include <Wire.h> 
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

//Constants
#define DHTPIN 4     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino

//ALWAYS USE THIS WITH LCD I2C and Addres 0x3F
#define I2C_ADDR 0x3F
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

//Variables
int chk;
float hum;  //Stores humidity value
float temp; //Stores temperature value

void setup()
{
  Serial.begin(9600);
  dht.begin();
  lcd.begin(16,2);
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
}

void loop()
{
  
  delay(2000);
  //Read data and store it to variables hum and temp
  hum = dht.readHumidity();
  temp = dht.readTemperature();
  //Print temp and humidity values to serial monitor
  Serial.print("Humidity: ");
  Serial.print(hum);
  Serial.print(" %, Temp: ");
  Serial.print(temp);
  Serial.println(" Celsius");

  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Temp: ");
  lcd.print(temp);
  lcd.print(" ");
  lcd.print((char)223);
  lcd.print("C");
  lcd.setCursor(0,1);
  lcd.print("Hum:  ");
  lcd.print(hum);
  lcd.print(" %");

  delay(2000); //Delay 2 sec.

}

Credits

FrAgFo0d

FrAgFo0d

1 project • 21 followers
Thanks to ianbren and attari.

Comments