Thanks, I had not found this when searching!
So I tried this suggestion for my own connections:
Code:
from gpiozero import LightSensor, Buzzerldr = LightSensor(18) # alter if using a different pinwhile True: print(ldr.value)
Code:
0.0repeated some 50 times 0.00.18500409985426813repeated some 50 times 0.185004099854268130.0repeated some 50 times 0.00.4979024995700456repeated some 50 times 0.4979024995700456
What can one do to make the program just read the value and print it, then exit?
All these zeros should not be there for instance.
But I tried commenting out the while :
Code:
from gpiozero import LightSensor, Buzzerldr = LightSensor(18) # alter if using a different pin#while True: print(ldr.value)
Code:
File "/home/pi/projects/photoresistor/lightsensor.py", line 5 print(ldr.value)IndentationError: unexpected indent
This Zero is running bullseye.*Why stay away, things have moved on in Pis and the Pi5 and maybe other cannot use it as is. Your Zero is fine, I assume an older OS too? Bullseye or buster?
Has been used to monitor outdoors temperatures for a couple of years now.
But I want it to also monitor outside light level.
It reports via MQTT.
All else is being done using bash scripting...
Statistics: Posted by Bosse_B — Tue Dec 03, 2024 9:53 am