lcd display not showing time and date when using rtc 1307

hi

i am currently using the setup and codes from this website(http://cyaninfinite.com/tutorials/rtc-module-with-serial-lcd-display/) to display date and time on lcd display using rtc and arduino.However, my lcd is not showing the time and date and is just showing 16 empty blocks.Does anyone know how to solve this issue.Is the connection of components or the codes wrong?

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <RTClib.h>
 
#if defined(ARDUINO) && ARDUINO >= 100
#define printByte(args)  write(args);
#else
#define printByte(args)  print(args,BYTE);
#endif
 
uint8_t clock[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0};
 
 
RTC_DS1307 RTC;
LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display
 
void setup()
{
  lcd.init();                      // initialize the lcd 
  // Print a message to the LCD.
  lcd.backlight();
  lcd.print("Initialising...");
    lcd.createChar(2, clock);
  Wire.begin();
   RTC.begin();
   
   // following line sets the RTC to the date & time this sketch was compiled
    //RTC.adjust(DateTime(__DATE__, __TIME__));
}
 
void loop()
{
  lcd.clear();
   DateTime now = RTC.now();
   lcd.printByte(2);
   lcd.print(" ");
  lcd.print(now.hour(), DEC);
    lcd.print(':');
    lcd.print(now.minute(), DEC);
    lcd.print(':');
    lcd.print(now.second(), DEC);
   lcd.setCursor(0, 1);
   lcd.print(now.day(), DEC);
    lcd.print('/');
    lcd.print(now.month(), DEC);
    lcd.print('/');
    lcd.print(now.year(), DEC);
    lcd.print(' ');
  delay(1000);
}

Thank you

mcd17:
hi

i am currently using the setup and codes from this website(RTC module with Serial LCD Display – Cyan Infinite) to display date and time on lcd display using rtc and arduino.However, my lcd is not showing the time and date and is just showing 16 empty blocks.Does anyone know how to solve this issue.Is the connection of components or the codes wrong?

#include <Wire.h> 

#include <LiquidCrystal_I2C.h>
#include <RTClib.h>

#if defined(ARDUINO) && ARDUINO >= 100
#define printByte(args)  write(args);
#else
#define printByte(args)  print(args,BYTE);
#endif

uint8_t clock[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0};

RTC_DS1307 RTC;
LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                      // initialize the lcd
  // Print a message to the LCD.
  lcd.backlight();
  lcd.print("Initialising...");
    lcd.createChar(2, clock);
  Wire.begin();
  RTC.begin();
 
  // following line sets the RTC to the date & time this sketch was compiled
    //RTC.adjust(DateTime(DATE, TIME));
}

void loop()
{
  lcd.clear();
  DateTime now = RTC.now();
  lcd.printByte(2);
  lcd.print(" ");
  lcd.print(now.hour(), DEC);
    lcd.print(':');
    lcd.print(now.minute(), DEC);
    lcd.print(':');
    lcd.print(now.second(), DEC);
  lcd.setCursor(0, 1);
  lcd.print(now.day(), DEC);
    lcd.print('/');
    lcd.print(now.month(), DEC);
    lcd.print('/');
    lcd.print(now.year(), DEC);
    lcd.print(' ');
  delay(1000);
}




Thank you

Your posting had disappeared with my reply.
I was working on getting that understood tonight.
I will resume on the morning.
I have to find the right LCD. I have 3 dozen of these 16x2 LCD displays so far none are TWI.
Go figure.

Should be able to solve it tomorrow.

@mcd17:. If I find another copy of this thread, you'll be looking at a forum timeout.

@artisticforge

I have 3 dozen of these 16x2 LCD displays so far none are TWI.

Are you sure?

The I2C trademark belongs to Philips (now NXP). Atmel uses the term TWI for essentially the same interface in order to avoid any potential legal issues.

Don

You need to isolate the issue.
I would recommend that you first get something to display on the LCD before you attempt to do something more complicated.
i.e. run the HelloWorld sketch that came with the LCD library.

Also, it would be useful to provide some photos of your setup so we can take a look to see if we seen any issues.

That said, if you have the same or similar LCD h/w from the tutorial, I'm guessing that either you are telling the library the incorrect i2c address, or you have an LCD/backpack that is not compatible with the i2c library you are using.
There are several different versions of the i2c backpack h/w that use different pin mappings and since that library is hard coded for a particular one, it may not be for the i2c backpack used on your device.

Alternatively, you could use my hd44780 library as it can auto detect the i2c address and the pin mappings used on the backpack.
It can be installed using the IDE library manager. (Do not install it using a zip file)
The i/o class for LCDs that use a i2c backpack is hd44780_I2Cexp.
You can read more about it on the github site: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library
And the wiki: Home · duinoWitchery/hd44780 Wiki · GitHub

I'd recommend that you first run the included diagnostic sketch I2CexpDiag to verify that the library is properly communicating with the LCD h/w.
Then look at the other hd44780_I2Cexp included sketches like HelloWorld to see what header files need to be included and how to declare the lcd object.

--- bill

floresta:
@artisticforge
Are you sure?

The I2C trademark belongs to Philips (now NXP). Atmel uses the term TWI for essentially the same interface in order to avoid any potential legal issues.

Don

yes, I am sure. They are Tinkerkit LCD Module boards. These are basically a Arduino Leonardo with an attached 16x2 LCD. There are sketches which will allow it to function either as a display with serial or TWI connections. I have never tried them. I bought the box of them at a yard sale. The yardsale had hundreds of Tinkerkit items.
I figure I paid $1.00 USD per Tinkerkit LCD Module, which gives me an Arduino Leonardo.
it was perhaps 50GBP total for everything i purchased that day.

I like them because I do not have to breadboard an Arduino and a LCD 16x2 display.

Can you provide a datasheet for the device or a schematic?
Without this we have no idea what you really have and cannot help you.

In terms of guessing what you have, I'll make a few guesses, which I HATE to do as it wastes lots of time,

From what I've seen googling around, the device is effectively a Leonardo with a LCD on it that is wired up for 4 bit parallel mode.
Here is a link to the s/w I found: GitHub - TinkerKit/TKLCD-Library: A library for the TinkerKit! LCD module
That s/w shows how to talk to the LCD using the local processor or how to use the device as an intelligent slave device that can receive messages on a serial port or through I2C as a slave from another Arduino.

But regardless of how external hosts communicates with the device, the local processor on the device always uses 4 bit mode with direct Arduino pin control.

That is very different from what you are trying to do - which is attempting to access the device as if it were a PCF8574 based backpack attached to a hd44780 LCD.

You can see the pins used in TKLCD.h
So you could talk to it using the the local processor with IDE bundled LiquidCrystal library.

The examples show both how to talk to the LCD using the local processor as well as how to talk to the device using another Arduino.

All that said, we really need a schematic for the device to really know what you have and what is needed to make it work.

--- bill