Greetings.
Usually I never have problems with the Teensys but I'm helping someone on this new project and we are noticing some issues when setting the RTC. Does it need a battery attached explicitly even when powered?
I went back and used the example code to check it:
#include <DS1307RTC.h>
#include <Time.h>
#include <Wire.h>
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);
}
Get the following output on the monitor:
DS1307RTC Read Test
-------------------
DS1307 read error! Please check the circuitry.
i2c basically shows a request for the device 0x68 but no response.
I'm sure there is something being overlooked but would appreciate input.
Rebelbot
Usually I never have problems with the Teensys but I'm helping someone on this new project and we are noticing some issues when setting the RTC. Does it need a battery attached explicitly even when powered?
I went back and used the example code to check it:
#include <DS1307RTC.h>
#include <Time.h>
#include <Wire.h>
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);
}
Get the following output on the monitor:
DS1307RTC Read Test
-------------------
DS1307 read error! Please check the circuitry.
i2c basically shows a request for the device 0x68 but no response.
I'm sure there is something being overlooked but would appreciate input.
Rebelbot