Arduino temperature and humidity station with DHT11 and 1602 LCD + I2C shield

DHT11 humidity and temperature sensor is perfect for your electronics projects. i.e. weather stations, home environment control systems, and agricultural/garden monitoring systems. 



The DHT11 is a digital sensor that lets you easily get relative humidity and temperature readings in your projects. First some background information about DHT11DHT11
Technical Specifications:

  • Humidity Range: 20-90% RH
  • Humidity Accuracy: ±5% RH
  • Temperature Range: 0-50 °C
  • Temperature Accuracy: ±2% °C
  • Operating Voltage: 3V to 5.5V

There is many tutorials how to connect sensor and LCD to your Arduino. My problem was my LCD and specific I2C address that it's used I found my on eBay it's 1602 with MH on the I2C board. 



This little baby use 0x3F I2C Address instead of 0x27 like most of the boards. 



LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);


Arduino Sketch

/*-----( WELCOME )-----*/
// This tutorial is based on Arduino UNO R3
// and DHT11 Sensor + LCD 16x2 with I2C Board
// Enjoy and visti my blog piotrgisworks.blogspot.com
/*-----( Import needed libraries )-----*/
#include <Wire.h> // Comes with Arduino IDE
#include <dht.h> // Download from https://github.com/adafruit/DHT-sensor-library
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>
dht DHT;
#define DHT11_PIN 7 //Declare sensor pin on Your Arduino UNO Board
/*-----( Declare Constants )-----*/
/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 16 chars 2 line display
// A FEW use address 0x3F
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
/*-----( Declare Variables )-----*/
//NONE
void setup() /*----( SETUP: RUNS ONCE )----*/
{
lcd.begin(16,2); // initialize the lcd for 16 chars 2 lines, turn on backlight
// ------- Quick 3 blinks of backlight , just for fun -------------
for(int i = 0; i< 3; i++)
{
lcd.backlight();
delay(250);
lcd.noBacklight();
delay(250);
}
lcd.backlight(); // finish with backlight on
//-------- Write characters on the display ------------------
// NOTE: Cursor Position: (CHAR, LINE) start at 0
lcd.setCursor(0,0);
lcd.print("Hello, world!"); //Welcome Message
delay(1000);
lcd.setCursor(0,1);
lcd.print("Second Line");
delay(8000); // Delay betwen first screen and sensor data
}
void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
// Display Temp and Humidity to LCD
{
lcd.clear();
lcd.setCursor(0,0); //Start at character 0 on line 0
int chk = DHT.read11(DHT11_PIN);
lcd.print("Temp: ");
lcd.print(DHT.temperature); //Read tempreature from DHT11 Sensor
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0,1);//Start at character 0 on line 1
lcd.print("Humidity: ");
lcd.print(DHT.humidity);//Read humidity from DHT11 Sensor
lcd.print("%");
delay(1000); //Set sensor data refresh time
}
/* ( THE END ) */

1 comment:

  1. The Eight-Wheel Classic - TITIAN Arts
    The eight-wheel classic bicycle is available in six sizes. The Bicycle wooricasinos.info Wheel is a classic sol.edu.kg bicycle ford escape titanium made in USA, ventureberg.com/ but there worrione are three variations in

    ReplyDelete

Fork me on GitHub