EasyManua.ls Logo

AZ-Delivery DS3231 - Page 27

AZ-Delivery DS3231
32 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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 -