0
\$\begingroup\$

It's unorthodox and probably not recommended by anyone but, for my project of driving a relay only with scrap parts and on the cheap, I managed to get a 12v relay, but, the GPIO ports on the RPi only output 3.3V (and the power supply pins are not switchable, meaning I cannot use them in order to control the relay).

I managed to drive the relay to the on position this way:

enter image description here

The 9V battery alone isn't enough to switch the relay's position so, assuming the 3.3V GPIO pin is pin number X, and I turn on the output and write a logical 1 to pin X, that's enough voltage to turn on the relay. But, the problem with this circuit is evident when we try to turn back off the relay, we write a logical 0 to pin X, but the 9V from the battery are still being supplied and the relay won't change state again until it reaches approx. 2V.

Thus, I want to remove the battery middleman and instead of connecting the battery in series with the pins, I want to connect some of these pins in series in order to add each pin's voltage:

  • 1 Pin on: 3.3V
  • 2 Pins on: 6.6V
  • 3 Pins on: 9.9V etc.

How can I achieve this? (N.B: current is unimportant here, it merely needs 30mA and that's easy to supply, so, voltage is my problem)

N.B #2: Here's the pinout of the GPIO pins of the RPi, for reference (remember that there's no way to control the power pins):

enter image description here

\$\endgroup\$
9
  • 4
    \$\begingroup\$ You can't do that \$\endgroup\$ Jan 30, 2015 at 0:20
  • 2
    \$\begingroup\$ Indeed. You will destroy your Pi (if not dead already) with your proposed setup. \$\endgroup\$
    – Dzarda
    Jan 30, 2015 at 0:25
  • 3
    \$\begingroup\$ Connecting a 9V battery as shown places -9 Volts in the I/I pin. Permanent damage to the RP may occur. Even if it appears to work OK it is a fundamentally flawed concept and should not be used. \$\endgroup\$
    – Russell McMahon
    Jan 30, 2015 at 0:43
  • 1
    \$\begingroup\$ @PatoSáinz The pin risking damage is the I/O pin. If you consider ground as fixed zero reference then the +ve terminal of the battery is at 0 volts (via the relay coil) so the -ve pole of the battery is 9 volts lower so it is at 0-9 = -9V. If the I/O pin is an input or floating it will be driven negative. This will drive current through the IC's internal protection diodes. ... \$\endgroup\$
    – Russell McMahon
    Jan 30, 2015 at 0:58
  • 1
    \$\begingroup\$ ... Current will be limited by the relay coil resistance. Whether damage occurs is partially a matter of luck, . \$\endgroup\$
    – Russell McMahon
    Jan 30, 2015 at 0:58

1 Answer 1

5
\$\begingroup\$

You cannot increase the voltage by connecting GPIO pins in series, as they all are referenced to a common ground.

To drive your relay you should do something like:

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
5
  • \$\begingroup\$ well yea, I've seen countless designs that use transistors and others, but, I wanted to impose a challenge that I shall only use scrap pieces. Do you know, by the way, where could I scrap that transistor? (For example, I scavenged the relay from an old UPS) (btw, many thanks for the answer, upvoted and chosen.) \$\endgroup\$
    – ppp
    Jan 30, 2015 at 0:29
  • \$\begingroup\$ Any handy NPN transistor should work in that circuit. \$\endgroup\$ Jan 30, 2015 at 0:32
  • \$\begingroup\$ Bennet: I'm already googling for possible places from where to scrap them, but I won't loose much by asking you, do you know where I can find a handy NPN? \$\endgroup\$
    – ppp
    Jan 30, 2015 at 0:34
  • \$\begingroup\$ @PatoSáinz most older electronics will have through hole transistors like that. Look for VCRs, clock radios. Newer electronics will have smd transistors. And Stay away from TVs for your own health. \$\endgroup\$
    – Passerby
    Jan 30, 2015 at 2:51
  • \$\begingroup\$ @Passerby I'm not that naïve to go behind CRT TV's and receive a huge discharge :) --I may be new to Doing It Yourself but I've been DIWO (doing it with others, no innuendo surely) for enough time to not be a risk for myself and others. Also, thanks for the suggestion, I'll go check my stash of old VCRs right now :) Thanks! \$\endgroup\$
    – ppp
    Jan 30, 2015 at 2:53

Your Answer

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

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