]> vault307.fbx.one Git - mu_code.git/blob - luxLog.py
early learning in mu editor
[mu_code.git] / luxLog.py
1 #!/usr/bin/env python3
2 import time
3 import datetime
4 import board
5
6 import adafruit_veml7700
7 import adafruit_bh1750
8
9 i2c = board.I2C()
10
11 veml7700=adafruit_veml7700.VEML7700(i2c)
12 bh1750=adafruit_bh1750.BH1750(i2c)
13
14
15 logFile=open('lightLog.txt','w')
16 while True:
17 tH=time.strftime('%H', time.localtime())
18 time.sleep(1)
19 while int(tH) <= 7:
20 ti=datetime.datetime.now()
21 logFile.write("Ambient Light: %d lux\n" % veml7700.light)
22 logFile.write("Light: %d lux\n" % bh1750.lux)
23 logFile.write(ti.strftime("%I:%M %p %d/%m/%y\n"))
24 logFile.flush()
25 print("Ambient Light: %d lux" % veml7700.light) # print statements are for debugging
26 print("Light: %d lux" % bh1750.lux)
27 print(ti.strftime("%I:%M %p %d/%m/%y\n"))
28 time.sleep(60.0)
29 else:
30 logFile.close()
31 print("out of time")
32 quit("after 7 am")