ds3231-example.lua 398 B

123456789101112131415
  1. -- ESP-01 GPIO Mapping
  2. gpio0, gpio2 = 3, 4
  3. i2c.setup(gpio0, gpio2, scl, i2c.SLOW) -- call i2c.setup() only once
  4. require("ds3231")
  5. second, minute, hour, day, date, month, year = ds3231.getTime();
  6. -- Get current time
  7. print(string.format("Time & Date: %s:%s:%s %s/%s/%s", hour, minute, second, date, month, year))
  8. -- Don't forget to release it after use
  9. ds3231 = nil
  10. package.loaded["ds3231"]=nil