Electronic – arduino – Real Time Clock DS1307 interfacing with Arduino Uno

arduinointerfacertcserial

I am currently working on an electronics project of building my own Digital wall clock. For that I tried making a RTC module with DS1307 IC.

I followed the following instruction from this website.

But when I tried to read and write the time to the IC using the serial monitor on Arduino software I got the following result.

Serial Monitor Output

My inputs were as follows:

first i/p : T000021240114

second i/p: R

And this is the connections I have made

Can someone help me find my mistake.

Best Answer

From the code:

second = (byte) ((Serial.read() - 48) * 10 + (Serial.read() - 48));
minute = (byte) ((Serial.read() - 48) *10 +  (Serial.read() - 48));
hour  = (byte) ((Serial.read() - 48) *10 +  (Serial.read() - 48));
dayOfWeek = (byte) (Serial.read() - 48);
dayOfMonth = (byte) ((Serial.read() - 48) *10 +  (Serial.read() - 48));
month = (byte) ((Serial.read() - 48) *10 +  (Serial.read() - 48));
year= (byte) ((Serial.read() - 48) *10 +  (Serial.read() - 48));

All have two characters except for dayOfWeek

So for right now (2014-01-25 13:58:00) it would be 14 characters (including 'T')

T0058136250114

You only have 13 characters in your command.

Also you need 4K7 - 10K pullups on SDA and SCL. Note that "Command: 13" in the log is just the carriage return character (enter). Since you had too few characters in the command, it was interpreted as part of the command.