Sometimes, my RTC shows time like " 2165/165/165 (Saturday) 165:165:85 ". Why?
The RTC I am using is DS1307 Serial Real-Time Clock. Please help!!
Sometimes, my RTC shows time like " 2165/165/165 (Saturday) 165:165:85 ". Why?
The RTC I am using is DS1307 Serial Real-Time Clock. Please help!!
And your code is?
And it is wired up how?
Is the chip even connected properly ?
Does an I2C scanner program detect the RTC at the right address ?
Grumpy_Mike:
And it is wired up how?
That also means the power supply. Please don't tell us you are making a portable clock powered by a 9v PP3 battery......
It is powered by the arduino board, and my code is
#include "RTClib.h"
void setup()
{
if (! rtc.begin())
{
Serial.println(F("Couldn't find RTC"));
while (1);
}
if (! rtc.isrunning())
{
Serial.println(F("RTC is NOT running!"));
}
rtc.adjust(DateTime(2017,8,02,16,07,00));
}
void loop()
{
DateTime now = rtc.now();
delay(150);
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(F(" ("));
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(F(") "));
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.print(F(" "));
delay(3000);
}
I forgot to mention the global variables I am using
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
RTC_DS1307 rtc;
Welcome to the Forum. Please read these two posts:
How to use this forum - please read. and
Read this before posting a programming question ...
You may also find useful information that would answer your question here:
Useful links - check here for reference posts / tutorials
You have posted code without using code tags. The code tags make the code look
like this
when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don't do it, some of the character sequences in the code can be misinterpred by the forum code as italics or funny emoticons.
If you have already posted without using code tags, open your message and select "modify" from the pull down menu labelled, "More", at the lower left corner of the message. Highlight your code by selecting it (it turns blue), and then click on the "</>" icon at the upper left hand corner. Click on the "Save" button. Code tags can also be inserted manually in the forum text using the code and /code metatags.
Unless the sketch is too large, it's better if you post your code, rather than attach it. When it's attached, we have to download it, create a folder then open your code in our IDE. And afterwards, the folder remains unless we navigate to the "Temp" folder and manually remove it. It's much easier to just view the code in your post.
Many questions can be answered by reading the documentation which is provided with the IDE, available under the help tab, or online here.
Please post your entire sketch in one piece.
Grumpy_Mike:
And it is wired up how?
Your answers have not addressed this question. Without this we haven't got a clue where you are making your mistake.
shashsp47:
Sometimes
What about other times?
Is there anything different between "sometimes" and "other times"?- same / different power, code, connections etc? Kepner and Tregoe would tell us there has to be something different.
shashsp47:
It is powered by the arduino board
That is being rather opaque, but the output you quote would suggest not too well.