Well I think I may have it working! Only reading the time off it at the moment. Need to figure out how to set the date and the time.
The following code appears to be reading the time okay.
I2C1.setup({scl:B6,sda:B7}); var rtcTime = ''; function time() { I2C1.writeTo(0x68/* I2C slave address*/, 0/* register addr*/); var data = I2C1.readFrom(0x68, 3/* bytes */); var seconds = (data[0] >> 1).toString(); var minutes = (data[1] >> 1).toString(); var hours = (data[2] >> 1).toString(); if (hours < 10) { hours = ("0" + hours); } if (minutes < 10) { minutes = ("0" + minutes); } if (seconds < 10) { seconds = ("0" + seconds); } rtcTime = (hours+":"+minutes+":"+seconds); return; } setInterval(time,500);
I just need to leave it running a while to see if its keeping the right time.
@StuntMonkeh started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Well I think I may have it working!
Only reading the time off it at the moment. Need to figure out how to set the date and the time.
The following code appears to be reading the time okay.
I just need to leave it running a while to see if its keeping the right time.