EasyManua.ls Logo

AZ-Delivery DS3231 - Page 29

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...
The script starts with importing two libraries, time and rtc_lib.
Next, the variable called degree_sign is created. The value of this
variable represents the UTF8 symbol for degree sign.
Then, the object called ds3231 is created with the following line of code:
ds3231 = rtc_lib.SDL-DS3231(1, 0x68)
Where the number 0x68 represents the I2C address of the RTC module.
After this, the date and time in RTC is updated with the following line of
code:
ds3231.write_now()
The function write_now() stores in the RTC module the current date and
time of the Raspbian operating system.
There is another option to store time and date data. It can be done with the
following line of code:
ds3231.write_all(seconds=None,minutes=None,hours=None,day=None,
date=None,month=None,year=None,save_as_24h=True)
- 27 -