0
\$\begingroup\$

I am trying to control a 12 VDC Bosch Automotive relay with an RPi. I am using a separate 12 VDC power supply to trigger the relay. The RPi is using GPIO18 which is connected to a 1k resistor, which is connected to the base of a 2N2222 transistor whose collector is connected to the relay output and emitter connected to the 12 VDC power supply negative lead.

I am not sure if the correct grounding of the RPI would be past the transistor to the 12 VDC PS? See line with "?" in below diagram. I have read in multiple posts that RPi GPIO does not need grounding, and then have been told it could not work without grounding (but mine actually does). I would love clarification and correction of my schematic if I have it wrong.

enter image description here

\$\endgroup\$
9
  • 1
    \$\begingroup\$ cut the connection that is short circuiting the collector and the emitter ... then it looks ok \$\endgroup\$
    – jsotola
    Dec 8, 2021 at 18:00
  • 1
    \$\begingroup\$ It totally depends if the grounds are alreay connected via another route. You tell absolutely nothing about the RPi suppy or the 12 supply. \$\endgroup\$
    – Justme
    Dec 8, 2021 at 18:13
  • \$\begingroup\$ You can use optocoupler if you do not want to connect grounds. \$\endgroup\$
    – user263983
    Dec 8, 2021 at 18:36
  • \$\begingroup\$ jsotola - could you kindly indicate which connection is shorting collector to emitter? I am not understanding which it is. If I am shorting, it would be of great help to know where. TY \$\endgroup\$
    – rfeyer
    Dec 8, 2021 at 19:46
  • 1
    \$\begingroup\$ nsayer - TY tons - I do not have that connection ion my board, but the line certainly should be erased from the schematic. My mistake for sure \$\endgroup\$
    – rfeyer
    Dec 8, 2021 at 19:50

1 Answer 1

0
\$\begingroup\$

Recall that collector current (from collector to emitter) is allowed to flow by a BJT transistor in response to a current from the base to the emitter. In order for the base current to flow, there must be a common ground between the Pi and the emitter. So, yes, you must make that connection if there isn't already a common ground in place.

\$\endgroup\$
9
  • \$\begingroup\$ TY nsayer!! I needed that confirmation - was afraid to blow the RPi with that 12VDC ground connection \$\endgroup\$
    – rfeyer
    Dec 8, 2021 at 19:51
  • \$\begingroup\$ It's conceivable that you could have problems making that ground connection - if both power supplies are not isolated and don't have a common ground, then you could wind up with current flowing between the two grounds, which would be bad. However, most modern DC power "wall wart" supplies are isolated, so tying grounds together is ok. \$\endgroup\$
    – nsayer
    Dec 8, 2021 at 20:00
  • \$\begingroup\$ so, would you also suggest an isocoupler as user263983 suggested? Between RPi ground and common PS common ground? \$\endgroup\$
    – rfeyer
    Dec 8, 2021 at 20:28
  • \$\begingroup\$ If you're powering the pi and the relay from isolated supplies, then I would not bother. Optocouplers are useful in situations where either safety or noise immunity demands galvanic isolation, and I don't think either is the case here. \$\endgroup\$
    – nsayer
    Dec 8, 2021 at 20:58
  • \$\begingroup\$ Oh, one more thing. You should give consideration to the potential for coil collapse blowback to damage the transistor. The textbook way of solving this is to place a small diode across the relay coil, cathode to positive. Another method is a zener diode (voltage > 12V, but < Vcemax) across the transistor. But when the transistor opens, all of the energy stored in the relay coil is going to induce a large voltage on the transistor collector, and if that exceeds the abs max Vce, the transistor may be destroyed. \$\endgroup\$
    – nsayer
    Dec 8, 2021 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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