-- John Longworth December 2017 -- Set time on an external RTC -- Uses I2C module -- NOTE: time is stored in BCD format (base 16) local id, sda, scl, device = 0, 3, 4, 0x68 i2c.setup(id, sda, scl, i2c.SLOW) i2c.start(id) i2c.address(id, device, i2c.TRANSMITTER) i2c.write(id, 0) i2c.write(id, tonumber(0,16)) -- seconds i2c.write(id, tonumber(59,16)) -- minutes i2c.write(id, tonumber(23,16)) -- hours i2c.write(id, tonumber(6,16)) -- wday i2c.write(id, tonumber(31,16)) -- day i2c.write(id, tonumber(12,16)) -- month i2c.write(id, tonumber(17,16)) -- year i2c.stop(id) -- Set time to 23:59:00 - Day 6 on 31/12/2017