Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7503

Automation, sensing and robotics • Using a photocell with a Raspi 4

$
0
0
Hi guys,

I would like to use a photocell to read the ambient brightness. I bought the following module and followed the HowTo to make it work: https://www.uugear.com/portfolio/using- ... pberry-pi/ However, I got only a digital output (0 or 1 depending on whether some brightness threshold has been reached or not). I'd like to have a brightness value, so I figured, I need an ADC to get the brightness value instead of just 0 and 1.

So I bought an YL-40 (https://www.best-microcontroller-projec ... f8591.html) to use it as an ADC. However, it turned out that it has a photocell already integrated, so I figured, I can try to use it as well. I connected the YL-40 to the RasPi and used the following code: https://raw.githubusercontent.com/jyheo ... er/yl40.py However, I get only zeroes as output, independent of the ambient brightness.

Maybe I actually need to use the YL-40 as an ADC and connect it to the photocell module I initially bought, but I'm not sure about how to do so. Do both modules require GND/VCC or just the YL-40? Do I need to remove one of the jumpers on the YL-40 to make one of the input analog channels free for the other module?

Please let me know, if you need more details of my problem, and sorry for the very basic questions!

Best,
PhotonX

Statistics: Posted by PhotonX — Wed Aug 27, 2025 2:45 pm — Replies 4 — Views 114



Viewing all articles
Browse latest Browse all 7503

Trending Articles