Wednesday, January 20, 2016

Clock and calendar using Arduino due internal RTC and I2C LCD display

I wanted to make a clock and calendar since long time. Ordered RTC chip is taking more than two months to arrive, so finally decided to find way out and found beautiful RTC library by 
and I2C LCD library by .
Although apparently simple project, it took long time for me to make I2C LCD display work (tried a dozen LCD libraries), get data from inbuilt RTC of Arduino due and do some animated scrolling text on LCD.

This quick project introduces us to -

1) Arduino due internal real time clock RTC to be used as date and time display. No need of external RTC chip/board

2) Running I2C LCD display on arduino due using Arduino IDE version 1.6.6

3) Displaying fixed text and scrolling text

4) Fixing issue of only one character being displayed on LCD displays, especially using higher version arduino IDE.

Although generally LCD displays are easy to connect and get working, it took long time for me to make it work on new Arduino IDE 1.6.6 and Arduino due. Initially I was getting only blinking white dark screen, then only one character and then text spread randomly so on... after lot of digging into google, i came up with this scheme... thanks to those who have done bits and pieces of work that helped me to do this herculean but simple project :).

Pin connections are as given below. Please note that LCD display needs 5V supply and not 3.3V.
I hooked up LCD directly from Arduino due 5V power supply and connected SCL and SDA pics of I2C LCD driver directly to pin 21 and 20 respectively. I didnt use any 5V to 3.3V step down conversion, it worked without burning my Arduino Due :).

Note - If your LCD display shows only one or first character of complete string, do not panic, just go in libraries folder of your Arduino installation directory, open the LiquidCrystal_I2C.cpp file and change the return value from 0 to 1, 
#define printIIC(args) Wire.write(args)
inline size_t LiquidCrystal_I2C::write(uint8_t value) {
send(value, Rs);
return 1;   this should be 1 and not 0

* Final working Sketch/code is given at the bottom of this page or is available on my - Github page with explanation of important commands given as comments.

I am not very active on blog these days, for comments and suggestions please comment on my youtube video here .

Have fun... :)

* Links to Libraries etc-

-- RTC library

-- Library for I2C LCD display

-- Sketch for Arduino I2C address scanner 

-- I2C LCD driver board from ebay 

-- 1602 LCD display is part of Arduino uno starter kit from

Catch Electromania on-
Blog -