Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LightSensor() no longer works under Raspbian Bookworm / Linux 6.6.20 #1135

Open
danny-andersen opened this issue Mar 28, 2024 · 3 comments
Open

Comments

@danny-andersen
Copy link

danny-andersen commented Mar 28, 2024

Operating system: Raspbian Bookworm
Python version: 3.11.2
Pi model: Pi Zero 2W
GPIO Zero version: 2.0
Pin factory used: lgpio version 0.2.2.0

Recent upgrade of Bookworm that uplifted the Linux vernal from 6.1.0 to 6.6.20, the LightSensor() class no longer works. Simple test programme below, the when_light() callback is never called and the LightSensor value always returns 0.0, regardless of the light level.

from gpiozero import LightSensor
from time import sleep

ldr = LightSensor(17, charge_time_limit=0.04)
ldr.when_light = lambda : print("Light")
while True:
	print(f"LDR: {ldr.value}")
	sleep(1)

Same circuit was used before and after. Also proved that the circuit still works by testing using OutputDevice() and InputDevice() to discharge the capacitor and timing how long it takes to charge based on whether it is light or not.

@bennuttall
Copy link
Member

@waveform80?

@8119436437056971
Copy link

Looks as if there is a pulldown enabled when switching the GPIO to input.
Measured the voltage level on the capacitor; when input is floating then voltage should raise to Vcc, but the voltage raises to a limit much lower than Vcc.

Checked with bookworm on a Pi5.

@nkreipke
Copy link

Can confirm this for both Pi Zero 2W and Pi 4. Not sure about the pull down thing though, the capacitor voltage peaks at around 3.3V as expected (measured at the GPIO pin).

Screenshot_20240524_220632

Previously, the capacitor immediately got discharged when the positive edge was detected. After upgrading, the library now always waits until the charge_time_limit has run out, failing to detect the edge.

I've also had this issue on ArchLinux ARM. As RPi.GPIO still works there, I was able to fix it by uninstalling lgpio and letting gpiozero fall back to RPi.GPIO. The issue seems to be specific to lgpio.

Unfortunately, RPi.GPIO is unusable on Bookworm because of this bug, so there seems to be no way to actually get it to work, which is kind of disappointing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants