Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.raspberry-pi > #12614 > unrolled thread
| Started by | Björn Lundin <b.f.lundin@gmail.com> |
|---|---|
| First post | 2016-07-06 22:24 +0200 |
| Last post | 2016-08-18 16:40 -0400 |
| Articles | 7 on this page of 27 — 8 participants |
Back to article view | Back to comp.sys.raspberry-pi
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
Page 2 of 2 — ← Prev page 1 [2]
| From | Graham. <graham-usenet@mail.com> |
|---|---|
| Date | 2016-07-11 23:10 +0100 |
| Message-ID | <hs38obt7efgh96hgte9b4af8eo7dfu8tmg@4ax.com> |
| In reply to | #12626 |
On Thu, 7 Jul 2016 10:44:58 -0000 (UTC), Gordon Henderson <gordon+usenet@drogon.net> wrote: >In article <nljpg6$me8$1@dont-email.me>, >Björn Lundin <b.f.lundin@gmail.com> 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? > >Several things. > >Firstly you've bought a cheap relay board which may have said "Raspberry >Pi" on it website, but it really is not Pi compatible. This happens a lot, >especially with sellers in far-off land you have no way to get in-touch >with. They lie and use the Raspberry Pi name to lure unsuspecting buyers. > >So the relay board - the real issue is that it's designed for 5v >operation. It's really for an Arduino or similar running at 5v. The Pi's >3.3v combined with the resistor into the opto coupler does not provide >enough "oomph" to light the internal LED and activate the relay. Thats >the case with most of these cheap boards... > >... however - another issue is that sometimes these relay boards (and I've >seen dozens of different ones )-: effectively connect the LED + resistor >to the 5v line - expecting the driving computer to short it to 0v. > >Try this: > >Leave it wired as it is, but then remove the wire from the Pi'2 GPIO >pin 22 and connect it to 0v/Gnd. > >If the relay fires then you have one of these. > >And by reading the above, this is most likely. > >So do this: > > Re-connect it to the Pi on that pin (bcm_gpio 22) > >and run these commands: > > gpio -g mode 22 in > >Realy ought to be off and stay off. > > gpio -g write 22 0 > >Nothing should happen at this point. > > gpio -g mode 22 out > >Relay should click ON. The pin is in output mode and is sinking >the current from the 5v, via the resistor + LED to 0v. > > gpio -g mode 22 in > >Relay should click off. > >I've seen this make similar relay boards work. It works, BUT ... when >in the off state (ie. gpio pin is in input mode), you are presenting 5v >to the GPIO pin. fortunately via a resistor and diode and the input >protection diodes on the GPIO pin will limit the damage, but it's very >not recommended. It'll work, but for how long... > >Really, you need to throw this relay board away and get something designed >for the Pi. Use something like a PiFace board. > >Gordon >(Author of wiringPi) The two-relay board I mentioned works perfectly with a pi, and is 1/20th the price of a piface. Common emitter buffers, opto-isolators, and channel LEDs The 8 channel version I am playing with now only cost £3.03 I am using it on my RASPBX with 16 shell scripts called from extensions_custom.conf with appropriate voice confirmation. All great fun, but I can't think of any uses for it at the moment. -- Graham. %Profound_observation%
[toc] | [prev] | [next] | [standalone]
| From | Graham. <graham-usenet@mail.com> |
|---|---|
| Date | 2016-07-08 21:45 +0100 |
| Message-ID | <tv10ob5e6d2nnngeep2bl57k3m9ad8b670@4ax.com> |
| In reply to | #12614 |
On Wed, 6 Jul 2016 22:24:59 +0200, Björn Lundin <b.f.lundin@gmail.com> 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? > >-- The relay boards I use are the same as ebay item 291563108767 That one happens to be 2 channel, I also use an 8 channel one. The clue is the jumper between two pins marked "VCC" and "JD-VCC" The idea is that if you remove that link you can power the board with its own local 5v PSU thus taking full advantage of the on-board opto-couplers. However, I can report that the board works fine with the jumper left in place, and connected to the pi gpio in exactly the way you are doing. Interestingly all the single channel ones I can see don't appear to have the opto-coupler or the jumper, so I can't vouch for them. -- Graham. %Profound_observation%
[toc] | [prev] | [next] | [standalone]
| From | Björn Lundin <b.f.lundin@gmail.com> |
|---|---|
| Date | 2016-07-10 17:26 +0200 |
| Message-ID | <nltpcc$579$1@dont-email.me> |
| In reply to | #12650 |
On 2016-07-08 22:45, Graham. wrote: > Interestingly all the single channel ones I can see don't appear to > have the opto-coupler or the jumper, so I can't vouch for them. > Mine does not have any jumpers at all - singel channel -- -- Björn
[toc] | [prev] | [next] | [standalone]
| From | Graham. <graham-usenet@mail.com> |
|---|---|
| Date | 2016-07-11 22:13 +0100 |
| Message-ID | <bf28ob5fvr6o45gu4tvp95beh5pl88pq6g@4ax.com> |
| In reply to | #12682 |
On Sun, 10 Jul 2016 17:26:04 +0200, Björn Lundin <b.f.lundin@gmail.com> wrote: >On 2016-07-08 22:45, Graham. wrote: > >> Interestingly all the single channel ones I can see don't appear to >> have the opto-coupler or the jumper, so I can't vouch for them. >> > > >Mine does not have any jumpers at all - singel channel > Assuming you can afford the space for a dual channel, I suggest you get one like ebay 291563108767. You can defiantly afford the price! -- Graham. %Profound_observation%
[toc] | [prev] | [next] | [standalone]
| From | Björn Lundin <b.f.lundin@gmail.com> |
|---|---|
| Date | 2016-07-12 10:00 +0200 |
| Message-ID | <nm283c$536$1@dont-email.me> |
| In reply to | #12695 |
On 2016-07-11 23:13, Graham. wrote: > On Sun, 10 Jul 2016 17:26:04 +0200, Björn Lundin > <b.f.lundin@gmail.com> wrote: > >> On 2016-07-08 22:45, Graham. wrote: >> >>> Interestingly all the single channel ones I can see don't appear to >>> have the opto-coupler or the jumper, so I can't vouch for them. >>> >> >> >> Mine does not have any jumpers at all - singel channel >> > > > Assuming you can afford the space for a dual channel, I suggest you > get one like ebay 291563108767. > > You can defiantly afford the price! > > Yes, I just ordered some. Thanks -- -- Björn
[toc] | [prev] | [next] | [standalone]
| From | Big Bad Bob <BigBadBob-at-mrp3-dot-com@testing.local> |
|---|---|
| Date | 2016-08-18 10:08 -0700 |
| Message-ID | <1N-dnTbdwtrFdijKnZ2dnUU7-UnNnZ2d@earthlink.com> |
| In reply to | #12614 |
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.
--
your story is so touching, but it sounds just like a lie
"Straighten up and fly right"
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2016-08-18 16:40 -0400 |
| Message-ID | <np56f9$ldf$1@dont-email.me> |
| In reply to | #12941 |
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
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.sys.raspberry-pi
csiph-web