You are reading a single comment by @StuntMonkeh and its replies. Click here to read the full conversation.
  • 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.

About

Avatar for StuntMonkeh @StuntMonkeh started