Failing to interface with a DS1307 RTC

Hello...

I'm currently working on a project that is essentially an alarm clock with the DS1307 RTC module and an LCD. Did I mention that the alarm would be set by a remote control?

Everything is working great in my project, except for the fact the the Arduino is displaying something like Mon 165/165/85 /165/165/85, which I have no idea. It is currently (at the time of posting) Sunday, March 11, 2018, at some time after 3:00 PM mountain time.

What? :o

Code:

#include <RTClib.h> // A port of Jeelab's RTC library by Adafruit
#include <Wire.h>
#include <LiquidCrystal.h>

RTC_DS1307 rtc;

LiquidCrystal lcd(7, 6, 5, 4, 3, 2); // RS, E, D7, D6, D5, D4

void setup(){
     lcd.begin(16, 2);
     rtc.begin();

     if(!rtc.isrunning()){
          lcd.print("RTC failed");
     }
}

void loop(){
     DateTime now = rtc.now();
    
    lcd.setCursor(0, 1);
    lcd.print(now.hour());
    lcd.print(':');
    lcd.print(now.minute());
    lcd.print(':');
    lcd.print(now.second());
    lcd.print("   ");

    lcd.setCursor(0, 0);
    lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
    lcd.print(" ,");
    lcd.print(now.day());
    lcd.print('/');
    lcd.print(now.month());
    lcd.print('/');
    lcd.print(now.year());
}

P.S. I am quite a newbie to RTC modules and using I2C with the Arduino; please keep things simple.

Any help here would be accepted gratefully. I can handle the infrared handling and the buzzer, but my RTC and LCD are failing.

Also, the RTC is an I2C device, so it is connected to SDA and SCL. The LCD's RS pin is on pin 7, E on pin 6, and D7-D4 on pins 5-2.

Thanks.

What attachment?

Whoops.... Something's wrong...

The RTC may not be getting set with the correct time/date info so your reading back defaults. How are you initializing it with the correct time/date information.

ResExention:
Arduino is displaying something like Mon 165/165/85 /165/165/85,

Could be caused by inadequate power. Please don't tell us that you are using a 9v PP3 battery

Nope. I am not using a battery with this project. The RTC is getting only 5V; and that's all it needs.

As asked by noweare, how did you set the RTC? Also do you have the backup battery attached? If it's not, the time will revert to zero every time you restart.

Also, the RTC is an I2C device, so it is connected to SDA and SCL.

What Arduino are you using and what pins are you using?

I don't think the rtc module is being recognized on the i2c bus. Run this scanner program and see what it reports. Does it show a device at 0x68? If not, check the connections to sda/scl.

// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011

#include <Wire.h>

void setup() {
  Serial.begin (115200);

  // Leonardo: wait for serial port to connect
  while (!Serial) 
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}