From 78d56b5194ef7fe124bced8d99b920e07389fdfa Mon Sep 17 00:00:00 2001 From: Thomas Klaehn Date: Thu, 7 Apr 2016 04:00:06 +0000 Subject: [PATCH] light sensor test expanded --- light_sensor_test.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/light_sensor_test.py b/light_sensor_test.py index 5fc24c8..95ce6af 100755 --- a/light_sensor_test.py +++ b/light_sensor_test.py @@ -1,10 +1,19 @@ #!/usr/bin/python2 from light_sensor import light_sensor -from time import sleep +from time import sleep, time +from datetime import datetime ls = light_sensor(1, 0x23) while True: - print "light: " + str(ls.read()) + " lx." + now = datetime.now() + now_str = str(now.year) + "-" + str(now.month) + "-" + str(now.day) + " " + str(now.hour) + ":" + str(now.minute) + ":" + str(now.second) + line = str(int(time())) + " " + now_str + " light: " + str(ls.read()) + " lx." + print line + + log = open("light.log", "a") + log.write(line) + log.write("\n") + log.close() sleep(1)