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

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

$
0
0
- does the program print errors ?
Well the one I used with the brightness sensor prints 0s and 1s as expected, the one I used with the YL-40 prints only 0s in a loop, no matter which channel I choose, no errors.
- use "sudo i2cdetect -y 1", the pcf8591 address should be reported
Yeah, about that... When connecting the brightness sensor, this got only empty slots. Now with the YL-40 it has all slots filled:

Code:

pi@raspberrypi:~ $ sudo i2cdetect -y 1     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f00:                         08 09 0a 0b 0c 0d 0e 0f 10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70: 70 71 72 73 74 75 76 77 
- when using the pcf8591 module with the LDR on board, then close P5 (with a jumper)
Yeah, I had all three jumpers closed (the default configuration), then I should be able to access all three on board sensors, but it kept giving 0s for all three of them...
- use 3.3V to provide supply voltage to the pcf8591 module (same for the module with digital output)
So, if I understand correctly:

YL-40 -> RPi

SCL -> SCL (Pin 5)
SDA -> SDA (Pin 3)
GND -> GND (Pin 6)
VCC -> 3V3 (Pin 1)


Brightness Sensor -> RPi

VCC -> 3V3 (Pin 17)
GND -> GND (Pin 20)


Brightness Sensor -> YL-40

AO -> AIN0


YL-40 configuration

Remove the P5 jumper

Is this the way it is supposed to be wired?

Statistics: Posted by PhotonX — Wed Aug 27, 2025 4:53 pm



Viewing all articles
Browse latest Browse all 8041

Trending Articles