I2C LCD Controller Part II





Introduction: I2C LCD Controller Part II

About: Master Diesel Tech, in California. I love electronics and everything science .
Now that we have install and assemble the controller here is a little project. we are going to build a thermometer.

Parts list

1. Arduino

1. I2C LCD

1. DHT11 Temp Sensor

1. 1k Resistor

7. Jumper wires


Step 1:

Connecting the LCD is very simple

LCD                 Arduino

5VCD               5VCD

GND                 GND

SDA                  PIN 20 (SDA on MEGA)

SCL                   PIN 21 (SCL on Mega)

Now the DHT11

DHT 11              Arduino

PIN 1                 5VCD

PIN2                  PIN 2

PIN 3                 N/A ( not used)

PIN 4                 GND

note: you can use a pull up resitor on PIN 2, but not necessary. Also you will need to install the library for the DHT11.

Step 2: THe Code

I am a beginner at this, so my programing  is not that great but it works.
It is very very basic and very simple.  

#include <Wire.h>                        //libraries needed
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <dht11.h>

//I2C Controller
#define I2C_ADDR    0x20  // Define I2C Address for controller
#define BACKLIGHT_PIN  7
#define En_pin  4
#define Rw_pin  5
#define Rs_pin  6
#define D4_pin  0
#define D5_pin  1
#define D6_pin  2
#define D7_pin  3
#define  LED_OFF  0
#define  LED_ON  1

#define DHT11PIN 2

LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
dht11 DHT11;

void setup()
    lcd.begin (16,2);
    // Switch on the backlight

void loop() 
  int chk = DHT11.read(DHT11PIN);
  lcd.print("Humy (%): ");
  lcd.print((float)DHT11.humidity, 2);
  lcd.print("Temp (oF): ");
  lcd.print(Fahrenheit(DHT11.temperature), 2);


//temp conversion
double Fahrenheit(double celsius)
        return 1.8 * celsius + 32;



    • Clocks Contest

      Clocks Contest
    • Casting Contest

      Casting Contest
    • Make it Move Contest

      Make it Move Contest

    We have a be nice policy.
    Please be positive and constructive.




    i test code manytime and have alltime different error, dht.h lcd.h not found, liguidcrystal.h not work. but i no found all libraries anywere. were have LCD and DHT11 and goow liguidcrystal_i2c, because i test many liguidc.h and any not working. my lcd addres i cahnge and work only test "hello world" 0x3F addres and this code(under) not working me alltiem error lcd.h, dht11.h and liguidcrustal.h i has load many different library but any not working :( i tes arduino ide 1.6.5 r2 1.6.7 1.6.11 and last not working anythink ecample code. what have proplem whit libraries ? i no understand.

    Had to modify it for my LCD:

    //I2C Controller

    #define I2C_ADDR 0x3F // Define I2C Address for controller

    #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

    #define LED_OFF 1

    #define LED_ON 0

    this should help https://arduino-info.wikispaces.com/LCD-Blue-I2C


    very thanks works after change somethings but it's works and i understand a little more how wire sensors


    lcd.print((char)223); //degree sign
    lcd.print("F"); instead of "oF" for degree F ;)