print('[Press CTRL + C to end the script!]')
try:
while True:
print('\nSystem time: {}'.format(
time.strftime('%Y-%m-%d %H:%M:%S')))
data = ds3231.read_datetime() # return tuple
print('RTC date: {} {}.{}.{}'.format(data[0],
data[1], check(data[2]), check(data[3])))
print('RTC time: {}:{}:{}'.format(check(data[4]),
check(data[5]), check(data[6])))
# return string
print('RTC date_time: {}'.format(ds3231.read_str()))
print('Temperature: {:.1f}C'.format(ds3231.getTemp(),
degree_sign))
time.sleep(1)
except KeyboardInterrupt:
print('\nScript end!')
- 25 -