forked from switchdoclabs/RTC_SDL_DS3231
-
Notifications
You must be signed in to change notification settings - Fork 2
/
testSDL_DS3231.py
40 lines (31 loc) · 921 Bytes
/
testSDL_DS3231.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
#
# Test SDL_DS3231
# John C. Shovic, SwitchDoc Labs
# 08/03/2014
#
#
import time
import datetime
import SDL_DS3231
# Main Program
print("")
print("Test SDL_DS3231 Version 1.0 - SwitchDoc Labs")
print("")
print("")
print("Program Started at:" + time.strftime("%Y-%m-%d %H:%M:%S"))
print("")
filename = time.strftime("%Y-%m-%d%H:%M:%SRTCTest") + ".txt"
start_time = datetime.datetime.utcnow()
ds3231 = SDL_DS3231.SDL_DS3231(1, 0x68)
# comment out the next line after the clock has been initialized
ds3231.write_now()
# Main Loop - sleeps 10 seconds, then reads and prints values of all clocks
while True:
current_time = datetime.datetime.utcnow()
deltaTime = current_time - start_time
print("")
print("Raspberry Pi=\t" + time.strftime("%Y-%m-%d %H:%M:%S"))
print("DS3231=\t\t%s" % ds3231.read_datetime())
print("DS3231 Temp=", ds3231.get_temp())
time.sleep(10.0)