From b6ac3df69b9a88ebbb8507f595d756139864076a Mon Sep 17 00:00:00 2001 From: jimmy Date: Tue, 16 Jul 2024 16:26:55 -0500 Subject: [PATCH 1/1] 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 --- distanceLux.py | 6 +++--- garageStatus.py | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100755 garageStatus.py 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) -- 2.47.3