Clock With Thermometer Using Arduino, I2c 16x2 Lcd, DS1307 RTC and DHT11 Sensor.


Introduction: Clock With Thermometer Using Arduino, I2c 16x2 Lcd, DS1307 RTC and DHT11 Sensor.

Hello! It's been a while I've didn't posted anything on Instructables, but now I made a simple project that I've seen on internet in various forms. I managed to build a code using other codes I've found on internet and I got to say it's working good.
For this project you need:
- Arduino Uno
- 16x2 LCD with i2c module
- DS1307 RTC
- DHT11 temperature and humidity sensor
- a bread board
- some wires for connections.

As you can see the RTC is homemade because I had a DS1307 chip and a battery extracted from an old german electronic cash registering device.
So the connections are very simple:
The RTC and the i2c LCD are connected to A4 pin (SDA) and A5(SCL) and DHT11 sensor is connected to D2 pin. DHT11 has 4 pins, but only 3 are actually used. First pin is Vcc, the second is for data and the forth pin is for ground. As I said, connect data pin of the sensor to D2 on Arduino.

Now, the hardest part: the code. !!!DOWNLOAD THE ORIGINAL SKETCH FROM HERE!!! 
I've tried some sketches I've found on internet, but there were alot of errors caused by incompatible libraries and so on. I managed to build a code made from parts of other codes and it's working like a charm now. There is a single problem though. You can find in the sketch a bit of code for displaying first 3 letters of the week day, but for some reason it doesn't work. Instead of those letters it shows some unknown characters and it's pretty ugly. I suspect that is a problem caused by i2c communication because in standard connection (4bits) it works without problems.

My inspiration came from this page,  and this page

This is the library used for this project and don't forget to use the new LCD library that can be found right here (when you add this new library in the folder, delete the old LiquidCrystal folder!)

And this is a PREVIEW of the code:


/* Example Software Sketch
   DHT11 Humidity and Temperature Sensor test
   Displayed on I2C LCD Display
   Credits: Rob Tillaart
   Combined with:
   Mark Johnson's code
   December 2012
   License: GNU General Public License
   Modiffied by Timofte Andrei ( )
   January 2014
/*-----( Import needed libraries )-----*/

//const char* zile[] =
// { "Lun", "Mar", "Mie", "Joi", "Vin", "Sam", "Dum"}; //days of the week in romanian (not used)
const char* luni[] =
{"Dec", "Ian", "Feb", "Mar", "Apr", "Mai", "Iun", "Iul", "Aug", "Sep", "Oct", "Noi" }; //months of the week also in romanian

byte termometru[8] = //icon for termometer

byte picatura[8] = //icon for water droplet

/*-----( Declare objects )-----*/

// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x20, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE);  // Set the LCD I2C address
dht11 DHT11;

/*-----( Declare Constants, Pin Numbers )-----*/
#define DHT11PIN 2 //dht11 signal pin connected to D2

void setup()   /*----( SETUP: RUNS ONCE )----*/
  lcd.begin(16,2);         // initialize the lcd for 16 chars 2 lines, turn on backlight
   // part code from
Wire.write(0x07); // move pointer to SQW address
Wire.write(0x10); // sends 0x10 (hex) 00010000 (binary) to control register - turns on square wave
// end part code from

}/*--(end setup )---*/

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
   afisare_temperatura(); //displaying temperature
   data_si_ora(); //displaying date and time
void afisare_temperatura()
  int chk =;
  lcd.setCursor(1, 1);
  lcd.setCursor(3, 1);
  lcd.print((float)DHT11.temperature, 0);
  lcd.setCursor(5, 1);
  lcd.print((char)223); //degree sign
  lcd.setCursor(9, 1);
  lcd.setCursor(11, 1);
  lcd.print((float)DHT11.humidity, 0);


void data_si_ora()

  tmElements_t tm;

  lcd.setCursor(0, 0);
  lcd.print(" ");
  lcd.print(" ");
// lcd.setCursor(12,1); // this code is used for displaying day of the week
//  lcd.print(tm.Wday[zile-2]); //it's disabled because for some reason it doesn't work on i2c display
void afisare2cifre(int numar) { //this adds a 0 before single digit numbers
  if (numar >= 0 && numar < 10) {

/* ( THE END ) */


9 People Made This Project!


  • Creative Misuse Contest

    Creative Misuse Contest
  • Clocks Contest

    Clocks Contest
  • Water Contest

    Water Contest

44 Discussions


6 months ago

Can you send me a schematic please?

Thanks! It was really helpful for me. To share some wiring there is a good tool -


1 year ago

Yes It's work ..

Where i plug RTC?????

For everyone of you who's going to use this project for himself: please learn basic electronics before crying out loud around because it's not my fault you don't have any idea of pull-up resistors, anti-parallel diodes and so on. The schematic is described in words just to see the amount of people which are understanding electronics or not. I know I have some issues with terms in english, but you have to start getting informations from elsewhere to understand a project. I know I'm rude in this comment, but if you don't start to understand what are you doing, you just waste your time and time is expensive, but you don't know that yet!

2 replies

why on earth would you make an instructable with deliberate mistakes in it? whinging about people needing help, make the instructable correct and people wont ask questions, you dead set wanker.

I have one comment :

//months of the week also in romanian

basic nowledge ? ;D

Can i use DSI 1502 with the same code ?

Timofte, thanks for posting this project. Very helpful!

Hey, can i change the lcd with bluetooth module for controlling by android? Please for the respon

Hey i want complete code and diagram of this project because when i tried i got error please some one send me code and diagram at

I think will be nice if the " : " able to blink for each second, have any one already try and willing to share the sketch ?

It is not works!!! I trying do this for six hours and I did nothing. Error and error and error. I regret that I bought parts, in Poland I spent 150 zloty`s its a lot of money in Poland.

3 replies THIS IS THE CODE

Here's the schematic. It is described in the project text, but it's hard to read. I'm usualy not providing schematics just to see how people are handling this...
You really have to learn how electronic systems are working, otherwise you only waste your time.
Read the code to see what pins are used by each sensor/device. If it uses i2c bus, in arduino uno there are only 2 pins used: A4(SDA) and A5(SCL), with the coresponding 4.7K pull-up resistors. In my case the pull-up resistors are integrated in the RTC module. Do no copy-paste the code from the page because it's not going to work because of html issues of the page.


you must adding librarys
and LCD need right addres

LiquidCrystal_I2C lcd(0x20, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE); // Set the LCD addres what you LCD have about 0x20-27, i have 0x27(LCD 20x4,i2c)