i2c and a Dallas RTC Anyone??

Hi there, I have modified slightly the code to give me the full set of data the module outputs, and removed the code specific to the display.

the problem I'm getting is that the data returned doesn't seem to make much sense... :slight_smile:

time is: 34:49:66 day, 2 date, 5 month, 5 year, 0
time is: 34:49:67 day, 2 date, 5 month, 5 year, 0
time is: 34:49:68 day, 2 date, 5 month, 5 year, 0
time is: 34:49:69 day, 2 date, 5 month, 5 year, 0
time is: 34:49:70 day, 2 date, 5 month, 5 year, 0

Thanks.

Well first things first, you need to mask off a few bits on the second and the hrs. Note in the original code there was "hrs & 0x3f" when it was writing it, and "secs & 0x7f".. yes that should've been up there on the same line with Wire.receive() but oh well. This is because the 'clock halt' sits in the top bit of secs and there are all kinds of state variables in the top 3 bits of hrs.

Looking at the diagram, note that date is split into two nibbles - the most significant holds '10 date'. The date is stored in BCD so for the 31st day of the month you'd see 0x31 instead of e.g. 0x1f if it were straight binary.

To program the clock (which you may not need to do after fixing the above) just uncomment the code at the top, and pick reasonable values for the time/date. It was originally set for 9:52pm. Make sure the CH bit is zero or the clock won't run. I also think there's a bug up there, 0x80 should've been 0x40 when setting the hours to 24 hour time.

HTH,
Bob