Skip to content

Instantly share code, notes, and snippets.

@sensorian
Created April 26, 2016 19:39
Show Gist options
  • Save sensorian/252510d11058ba3665fd183b9b2da9c2 to your computer and use it in GitHub Desktop.
Save sensorian/252510d11058ba3665fd183b9b2da9c2 to your computer and use it in GitHub Desktop.
Uses the SensorsInterface Python module for reading both RTCC data and magnetometer data.
#!/usr/bin/python
import sys
import time
import SensorsInterface
def main(argv):
print "=== Real Time Clock and Calendar ==="
print "*************************************"
SensorsInterface.setupSensorian() #Initialize the library
while True:
rtcTime = SensorsInterface.getRTCCtime()
sys.stdout.write(str(rtcTime[0]) + "/" + str(rtcTime[1]) + "/" + str(rtcTime[2]) + " " +str(rtcTime[3]) + ":" + str(rtcTime[4]) + ":" + str(rtcTime[5]))
sys.stdout.write(" <----> ")
magnetometer = SensorsInterface.getMagnetometer()
print magnetometer
if __name__ == '__main__':
try:
main(sys.argv[1:])
except KeyboardInterrupt:
print("")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment