0
\$\begingroup\$

I built the following circuit. When I touch the rogue transistor base wire and GPIO is outputting, the LED lights up (still not quite sure why, so if someone could explain this, that'd be helpful, too.)

My current setup

But now instead of the LED showing the state, I want to use a GPIO input to send it to the Pi. However when I replace base with GPIO.IN, the LED loses a lot of voltage, and thr GPIO only reads 0 (off). If you couldn't tell, I'm new to all this, so a bit more detail could prove helpful.

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

Your body is an antenna and when you touch the base of this transistor some amount of electricity is coupled into that input of the transistor. This transistor is setup as an "emitter follower" which means that it will attempt to keep the voltage at the emitter (Ve) at the same level as the voltage at the base (Vb).

So clearly you are raising Vb to a potential that is high enough to turn the LED ON.

Try a circuit like this to read the GPIO input when your transistor base is touched:

schematic

simulate this circuit – Schematic created using CircuitLab

The idea here is that when an input is present on the base of the transistor, it will turn the transistor ON. When that happens current flows in the collector which will pull the GPIO pin LOW. Keep in mind that the collector current, Ic, is the base current Ib times the hfe value of the transistor. For most small-signal transistors hfe is in the 100s or even 1000s. So you get a sizeable collector current with very little base current.

\$\endgroup\$
10
  • \$\begingroup\$ That is already very helpful to understand, thanks! Concerning the rest of the question, do you know why the GPIO pin doesn't read the voltage. I could imagine the resistance increasing as the GPIO becomes the ground, but admittingly I don't know at all \$\endgroup\$
    – mdre
    Commented Feb 16, 2021 at 12:43
  • \$\begingroup\$ GPIO read what voltage? It's not at all clear what else you are asking or what you are trying to do. \$\endgroup\$
    – jwh20
    Commented Feb 16, 2021 at 12:51
  • \$\begingroup\$ Currently the diode leads to a ground connection, from which I cannot read whether the base is touched ( / the LED is on). So I connected another GPIO Pin after the LED, instead of the Ground. However, the LED is dimmed and the GPIO in pin shows a LOW value.. \$\endgroup\$
    – mdre
    Commented Feb 16, 2021 at 12:57
  • \$\begingroup\$ that's because your circuit is not able to pull the GPIO pin (which I assume is setup for input) to a low enough voltage (i.e. Vil) that is will read a logic 0. \$\endgroup\$
    – jwh20
    Commented Feb 16, 2021 at 13:15
  • \$\begingroup\$ Okay, if I didn't misunderstand that, your saying the voltage arriving at the GPIO.IN pin is too low, no? So could I switch the 330 Ohm resistor for say 100 without hurting the LED since our resistance overall has increased? \$\endgroup\$
    – mdre
    Commented Feb 16, 2021 at 13:20

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.