update
This commit is contained in:
10
RTC/read.py
10
RTC/read.py
@@ -1,4 +1,10 @@
|
||||
'''
|
||||
____ _____ ____
|
||||
| _ \_ _/ ___|
|
||||
| |_) || || |
|
||||
| _ < | || |___
|
||||
|_| \_\|_| \____|
|
||||
|
||||
Script to read time from RTC module
|
||||
I2C connection
|
||||
Address 0x68
|
||||
@@ -9,7 +15,6 @@ import time
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
# DS3231 I2C address
|
||||
DS3231_ADDR = 0x68
|
||||
|
||||
@@ -44,7 +49,7 @@ def main():
|
||||
utc_time = datetime.utcnow() #UTC
|
||||
|
||||
# If RTC is not connected, set default message
|
||||
# Calculate time difference (in seconds) if RTC is connected
|
||||
# Calculate time difference (in seconds) if RTC is connected
|
||||
if rtc_time:
|
||||
rtc_time_str = rtc_time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
time_difference = int((utc_time - rtc_time).total_seconds()) # Convert to int
|
||||
@@ -52,7 +57,6 @@ def main():
|
||||
rtc_time_str = "not connected"
|
||||
time_difference = "N/A" # Not applicable
|
||||
|
||||
|
||||
# Print both times
|
||||
#print(f"RTC module Time: {rtc_time.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
#print(f"Sys local Time: {system_time.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
|
||||
Reference in New Issue
Block a user