For a project related to RTC, my friend is having the arduino IDE with version 1.6.8, whereas in my system am using arduino IDE with version 1.8.5. He is able to view the time of RTC in the serial monitor. but i am getting the display in the serial monitor as DS1307 RTC test.... not able to view the time of RTC.... please guide me
void setup() {
Serial.begin(9600);
while (!Serial) ; // wait for serial
delay(200);
Serial.println("DS1307RTC Read Test");
Serial.println("-------------------");
}
void loop() {
tmElements_t tm;
if (RTC.read(tm)) {
Serial.print("Ok, Time = ");
print2digits(tm.Hour);
Serial.write(':');
print2digits(tm.Minute);
Serial.write(':');
print2digits(tm.Second);
Serial.print(", Date (D/M/Y) = ");
Serial.print(tm.Day);
Serial.write('/');
Serial.print(tm.Month);
Serial.write('/');
Serial.print(tmYearToCalendar(tm.Year));
Serial.println();
} else {
if (RTC.chipPresent()) {
Serial.println("The DS1307 is stopped. Please run the SetTime");
Serial.println("example to initialize the time and begin running.");
Serial.println();
} else {
Serial.println("DS1307 read error! Please check the circuitry.");
Serial.println();
}
delay(9000);
}
delay(1000);
}
void print2digits(int number) {
if (number >= 0 && number < 10) {
Serial.write('0');
}
Serial.print(number);
}
I don't have your hardware so I can't test your program. It may be that you have a different version of the RTC library - or perhaps you need a different version.
Have you tried IDE 1.6.8 on your PC? There is no problem having several versions on a PC. The IDE is just a Java program.
I am running your sketch successfully with ide version 1.8.5 under Windows 10, and a DS1307 and the Michael Margolis DS1307RTC library from the library manager. I can not confirm your problem.