From: jimmy Date: Tue, 16 Jul 2024 21:26:55 +0000 (-0500) Subject: update distanceLux.py to account for senstitivity of lux sensor X-Git-Url: https://vault307.fbx.one/gitweb/garage_door_sensor.git/commitdiff_plain/b6ac3df69b9a88ebbb8507f595d756139864076a update distanceLux.py to account for senstitivity of lux sensor create garageStatus.py to run on zero, will read serial port and output data based on serial data. still need to integrate into webserver --- diff --git a/distanceLux.py b/distanceLux.py index 8125d35..ca939f1 100644 --- a/distanceLux.py +++ b/distanceLux.py @@ -38,15 +38,15 @@ def distance(): def measure(): global lux_val lux_val = veml.read_lux() - if lux_val<=4: + if lux_val<=2: lux_val=0 - if lux_val >= 5: + if lux_val >= 3: lux_val=1 return(lux_val) while True: measure() distance() - print(str(lux_val)+' '+str('%.0f'%distance_cm)+'\n') + print(str(lux_val)+' '+str('%.0f'%distance_cm)) time.sleep(.5) diff --git a/garageStatus.py b/garageStatus.py new file mode 100755 index 0000000..6fe6ac7 --- /dev/null +++ b/garageStatus.py @@ -0,0 +1,21 @@ +#!/usr/bin/python3 +import serial, time + +ser=serial.Serial('/dev/ttyACM0',9600,timeout=.5) + +l='' #lightsensor +g='' #garagedoor sensor + +def readLine(): + global l + global g + data=str(ser.readline()) + l=data[2] + g=data[4] + return l + return g + +while True: + readLine() + print(l,g) + time.sleep(1)