Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.raspberry-pi > #12642
| From | Dennis <dennis@none.none> |
|---|---|
| Newsgroups | comp.sys.raspberry-pi |
| Subject | Re: control a relay from the pi via GPIO |
| Date | 2016-07-07 12:30 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <nlm3js$ppl$1@dont-email.me> (permalink) |
| References | (1 earlier) <nljqk9$p7j$1@dont-email.me> <nljrnb$udt$1@dont-email.me> <nlk2is$nov$1@dont-email.me> <nlkdmm$i8n$1@dont-email.me> <nlkjro$pe$1@dont-email.me> |
On 07/06/2016 10:55 PM, rickman wrote: > On 7/6/2016 10:10 PM, Dennis wrote: >> On 07/06/2016 06:00 PM, Dennis wrote: >>> On 07/06/2016 04:03 PM, rickman wrote: >>>> On 7/6/2016 4:45 PM, rickman wrote: >>>>> On 7/6/2016 4:24 PM, Björn Lundin wrote: >>>>>> 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? >>>>> >>>>> Mostly you aren't reading the specifications of your components. >>>>> Cough >>>>> up a part number and maker of the relay and I'll see if I can find a >>>>> data sheet that explains how the relay is intended to be used. >>>> >>>> I dug on the Internet a bit and it looks like your device is an HL-51 >>>> which is a bit hard to read from the image. Digging further if I read >>>> the part number from the relay correctly, SRD-05VDC-SL-C, this is a 5 >>>> volt mechanical relay. >>>> >>>> So you have two problems. One is that the relay coil is rated for 5 >>>> volts which means it should have 3.75 volts on the coil to work >>>> properly. The rPi I/Os won't survive with this much voltage across >>>> them >>>> when the output is not driven low. >>>> >>>> The other is the rated current, 71.4 mA. This is far higher than what >>>> the rPi I/Os can drive. >>>> >>>> To solve both problems you simply need to add a transistor to your >>>> circuit. In reality your relay module should have the transistor on >>>> it, >>>> but it doesn't look like it does. >>>> >>>> There seem to be tons of available references on how to interface this >>>> type of relay to your rPi. If you provide better info on what you have >>>> I can give you more info on what you can do to use it. >>>> >>> There appears to be a three terminal blob to the right of the green LED >>> which could be a switching transistor. I have a two relay board that >>> looks remarkably similar. I haven't tried it on 3.3 volts, but it works >>> fine with an Arduino at 5v. >> >> I tried it with my RPi with I/O pin 24 and and it works fine. In looking >> at the picture in the link again they have the pins numbered wrong. Pin >> 22 is actually to the left of the blue wire termination - the one they >> show connected is actually pin 23. >> >> The green LED is the power indicator, the red one is the relay state. >> The center relay terminal is common which is switched to the one on >> either side based on the input. The red LED in on with a low input. > > I see the transistor blob you refer to. Do you know the circuit on your > module? Is the transistor switched by 3.3 volts rather than 5? > > If the relay is activated by a low the circuit would need to be a PNP > transistor or P channel FET on the high side switched by pulling the > base/gate to ground. This means the high would need to be 5 volts which > is not entirely compatible with the rPi I//Os. > > Does your relay activate on a high input or a low? > OK I traced out the circuit. It is a PNP transistor. Input through 1K to the base, 5V on the emitter, relay (with diode across the coil) and red LED (through 1K) on the collector to ground. The relay is energized by a low input (it has a NC and NO contact so the definition of on depends on which contact you are using). With 5V Vcc the input pin is about 4.6V with no connection. This may be a problem for long term use on a RPi. I'm not sure how the RPi handles a voltage above 3.3V on an output pin. A level shifter may be a good idea. If I change the Vcc to 3.3V the relay still switches, but I'm not sure how reliable that would be long term.
Back to comp.sys.raspberry-pi | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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