1
\$\begingroup\$

I have a cirtuit which consists of Resistor, Photoresistor, PNP Transistor, Voltage supply from raspberry pi like on the schema below:

enter image description here

Purpose of this circut is to detect light as a dawn detection sensor. As I know voltage on the base of transistor is expressed by voltage divider:

enter image description here

If the voltage on the base of transistor is 0.7V smaller than voltage on the emitter, then transistor conducts(change from darkness to light).

I would like to connect this circut to Raspbery pi GPIO port configured as INPUT with Pull up resistor and detect the light.

But I don't know how should I do it exaclty. Should I connection below collector directly to GPIO configured as input?

I would be grateful for some advices.

Maybe connection like below could work properly?

enter image description here

Best regards.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Um, that's not really a detector. That's a "the transistor gets warm or not, depending on how bright it is" circuit. What of this schematic do you want to attach to an input pin? \$\endgroup\$ Jun 2, 2020 at 18:42
  • \$\begingroup\$ Agreed this circuit is not correct. The transistor is just shorting out the power supply when the photoresistor is in darkness. \$\endgroup\$
    – Drew
    Jun 2, 2020 at 19:01
  • \$\begingroup\$ Yes I would like to attach this circut to gpio input and detect light based on transistors activation. \$\endgroup\$ Jun 2, 2020 at 19:48
  • \$\begingroup\$ Your update wont work. The GPIO is pulled to ground. \$\endgroup\$
    – Passerby
    Jun 2, 2020 at 20:58
  • 1
    \$\begingroup\$ Why do you think you even need a transistor? Properly selected photocell and a resistor on it in many cases is sufficient. You can also use ADC input and trim the threshold in software. \$\endgroup\$
    – Maple
    Jun 2, 2020 at 21:07

2 Answers 2

2
\$\begingroup\$

You really should want some hysteresis in the circuit. This can be achieved pretty simply:

schematic

simulate this circuit – Schematic created using CircuitLab

The output will be HI to the I/O pin when there is no light and it will be LO when there is sufficient light. Feel free to adjust \$R_2\$ up or down a bit in order to select the desired light level for the circuit.

The above circuit provides an output that reaches the rail voltage but does not reach ground (it should get within a diode drop, though.) If you want to have a rail-to-rail output then you'll need to add another active device to buffer the output.

\$\endgroup\$
3
\$\begingroup\$

I would suggest you pull the gpio pin up to 3.3v using a sizeable resistor ,and then pulling down that same pin by connecting it to the collector

here is a Quick solution , please calculate the values depending on the components you are using.

schematic

simulate this circuit – Schematic created using CircuitLab

hope it helps.

\$\endgroup\$
3
  • \$\begingroup\$ oh you are right, my bad,ill fix that. \$\endgroup\$
    – theCNN
    Jun 3, 2020 at 5:46
  • \$\begingroup\$ Is pull up resistor is the same which internally resistor in Raspberry connected to GPIO port? I can activate it in Python. \$\endgroup\$ Jun 5, 2020 at 19:16
  • \$\begingroup\$ I suppose so, if it is the same as in the Arduino types where you declare a PULL_UP in the pin initialisation. So then you can connect the collector directly to the gpio pin and just erase that resistor from circuit \$\endgroup\$
    – theCNN
    Jun 6, 2020 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.