EasyManua.ls Logo

AZ-Delivery DS3231 - Python Script

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...
Python script
The following is the script for controlling the RTC module:
import time
import rtc_lib # importing library functions
degree_sign = u'\xb0'
ds3231 = rtc_lib.SDL_DS3231(1, 0x68)
ds3231.write_now() # saves the current date and time of R. Pi
# ds3231.write_all(seconds=None, minutes=None, hours=None,
day=None, date=None, month=None, year=None, save_as_24h=True)
# Range: seconds [0-59]; minutes [0-59]; hours [0-23]; day [1-7];
# date [1-31]; month [1-12]; year [0-99]
def check(num):
'''A fucntion that put leading zero to single digit number
return: string
'''
if num < 10:
return '0{}'.format(num)
else:
return str(num)
- 24 -