Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.raspberry-pi > #12942

Re: control a relay from the pi via GPIO

From rickman <gnuarm@gmail.com>
Newsgroups comp.sys.raspberry-pi
Subject Re: control a relay from the pi via GPIO
Date 2016-08-18 16:40 -0400
Organization A noiseless patient Spider
Message-ID <np56f9$ldf$1@dont-email.me> (permalink)
References <nljpg6$me8$1@dont-email.me> <1N-dnTbdwtrFdijKnZ2dnUU7-UnNnZ2d@earthlink.com>

Show all headers | View raw


On 8/18/2016 1:08 PM, Big Bad Bob wrote:
> On 07/06/16 13:24, Björn Lundin so wittily quipped:
>> Hi!
>> I got a pi model B that I want to control a relay.
>>
>> I've got one just like the ome on the picture in the link here
>>
>> <https://halckemy.s3.amazonaws.com/uploads/image_file/file/76359/PoolSchematicDC.jpg>
>>
>>
>> I connect just as the picture, +5v to vcc and ground to ground.
>> The green diod then ligths up.
>>
>> So I connect a gpio to the middle pin marked Inl.
>> GPIO low = nothing happens
>> GPIO high = nothing happens.
>>
>> I grab a voltmeter and measure between the GPIO and ground,
>> and I get ca 0 V resp 3.3 V. So - correct pin, but no action in the relay.
>>
>> Ok, thinking 3.3 might be to small to drive the relay, testing +5 V on
>> the middle pin. Still nothing.
>> Frustrated - testing ground to middle pin - and then the relay clicks,
>> and the red diod lights up, somewhat brighter than the green one.
>>
>> Surley - this is not supposed to happen - or ?
>>
>> I got 3 of those relays, and all three behave the same - ground the
>> middle pin and then action.
>>
>>
>> What am I doing wrong here?
>>
>
> you probably need a bipolar transistor or MOSFET to drive the relay from
> the GPIO.  a simple method might be like this:
>
>
>               Q1 /-----O to relay
>          R1    |/
> GPIO  0-/\/\/--|
>                |\
>                  V
>                  |
>                 ---
>                  -
>
> Q1 can be any general purpose NPN power transistor, with the collector
> connected to the relay pin (which apparently needs 'ground' to trigger
> it), the emitter to ground, and the base through R1 to the GPIO pin.
>
> R1 should be at least 300 ohms to limit current to 10ma (for the RPi
> GPIO to prevent frying it)
>
> if you pick component values that work, a '1' output would put 'ground'
> on the relay control pin, and that should do ya.  If needed, put a 2k
> pullup to 'whatever voltage' on the collector of Q1.

I think this was solved some time ago.  The board already has a 
transistor on it which is not much different from the circuit you have 
drawn except the opposite polarity (PNP).  So you pull down to activate 
it.  Trouble is you need to let it rise to 5 volts to turn it off.

-- 

Rick C

Back to comp.sys.raspberry-pi | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

control a relay from the pi via GPIO Björn Lundin <b.f.lundin@gmail.com> - 2016-07-06 22:24 +0200
  Re: control a relay from the pi via GPIO rickman <gnuarm@gmail.com> - 2016-07-06 16:45 -0400
    Re: control a relay from the pi via GPIO rickman <gnuarm@gmail.com> - 2016-07-06 17:03 -0400
      Re: control a relay from the pi via GPIO Dennis <dennis@none.none> - 2016-07-06 18:00 -0500
        Re: control a relay from the pi via GPIO Dennis <dennis@none.none> - 2016-07-06 21:10 -0500
          Re: control a relay from the pi via GPIO rickman <gnuarm@gmail.com> - 2016-07-06 23:55 -0400
            Re: control a relay from the pi via GPIO Dennis <dennis@none.none> - 2016-07-07 12:30 -0500
      Re: control a relay from the pi via GPIO Björn Lundin <b.f.lundin@gmail.com> - 2016-07-07 19:21 +0200
        Re: control a relay from the pi via GPIO rickman <gnuarm@gmail.com> - 2016-07-07 14:34 -0400
          Re: control a relay from the pi via GPIO Dennis <dennis@none.none> - 2016-07-07 17:10 -0500
            Re: control a relay from the pi via GPIO rickman <gnuarm@gmail.com> - 2016-07-08 00:29 -0400
        Re: control a relay from the pi via GPIO Björn Lundin <b.f.lundin@gmail.com> - 2016-07-12 10:18 +0200
          Re: control a relay from the pi via GPIO Rob Morley <nospam@ntlworld.com> - 2016-07-12 12:49 +0100
  Re: control a relay from the pi via GPIO Gordon Henderson <gordon+usenet@drogon.net> - 2016-07-07 10:44 +0000
    Re: control a relay from the pi via GPIO Björn Lundin <b.f.lundin@gmail.com> - 2016-07-10 17:40 +0200
      Re: control a relay from the pi via GPIO rickman <gnuarm@gmail.com> - 2016-07-10 12:43 -0400
        Re: control a relay from the pi via GPIO Björn Lundin <b.f.lundin@gmail.com> - 2016-07-12 10:06 +0200
          Re: control a relay from the pi via GPIO The Natural Philosopher <tnp@invalid.invalid> - 2016-07-12 09:20 +0100
          Re: control a relay from the pi via GPIO rickman <gnuarm@gmail.com> - 2016-07-12 04:23 -0400
            Re: control a relay from the pi via GPIO The Natural Philosopher <tnp@invalid.invalid> - 2016-07-12 09:58 +0100
    Re: control a relay from the pi via GPIO Graham. <graham-usenet@mail.com> - 2016-07-11 23:10 +0100
  Re: control a relay from the pi via GPIO Graham. <graham-usenet@mail.com> - 2016-07-08 21:45 +0100
    Re: control a relay from the pi via GPIO Björn Lundin <b.f.lundin@gmail.com> - 2016-07-10 17:26 +0200
      Re: control a relay from the pi via GPIO Graham. <graham-usenet@mail.com> - 2016-07-11 22:13 +0100
        Re: control a relay from the pi via GPIO Björn Lundin <b.f.lundin@gmail.com> - 2016-07-12 10:00 +0200
  Re: control a relay from the pi via GPIO Big Bad Bob <BigBadBob-at-mrp3-dot-com@testing.local> - 2016-08-18 10:08 -0700
    Re: control a relay from the pi via GPIO rickman <gnuarm@gmail.com> - 2016-08-18 16:40 -0400

csiph-web