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


Groups > comp.sys.raspberry-pi > #12614 > unrolled thread

control a relay from the pi via GPIO

Started byBjörn Lundin <b.f.lundin@gmail.com>
First post2016-07-06 22:24 +0200
Last post2016-08-18 16:40 -0400
Articles 20 on this page of 27 — 8 participants

Back to article view | Back to comp.sys.raspberry-pi


Contents

  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 1 of 2  [1] 2  Next page →


#12614 — control a relay from the pi via GPIO

FromBjörn Lundin <b.f.lundin@gmail.com>
Date2016-07-06 22:24 +0200
Subjectcontrol a relay from the pi via GPIO
Message-ID<nljpg6$me8$1@dont-email.me>
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?

-- 
--
Björn

[toc] | [next] | [standalone]


#12615

Fromrickman <gnuarm@gmail.com>
Date2016-07-06 16:45 -0400
Message-ID<nljqk9$p7j$1@dont-email.me>
In reply to#12614
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.

-- 

Rick C

[toc] | [prev] | [next] | [standalone]


#12617

Fromrickman <gnuarm@gmail.com>
Date2016-07-06 17:03 -0400
Message-ID<nljrnb$udt$1@dont-email.me>
In reply to#12615
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.

-- 

Rick C

[toc] | [prev] | [next] | [standalone]


#12618

FromDennis <dennis@none.none>
Date2016-07-06 18:00 -0500
Message-ID<nlk2is$nov$1@dont-email.me>
In reply to#12617
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.

[toc] | [prev] | [next] | [standalone]


#12622

FromDennis <dennis@none.none>
Date2016-07-06 21:10 -0500
Message-ID<nlkdmm$i8n$1@dont-email.me>
In reply to#12618
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.

Here is my test code - modify as needed for the I/O pin you use.

import RPi.GPIO as GPIO
import time

#set up GPIO using BCM numbering
GPIO.setmode(GPIO.BCM)

#setup GPIO using Board numbering
#GPIO.setmode(GPIO.BOARD)

outpin = 24  # pin to control relay

GPIO.setup(outpin, GPIO.OUT) # make it an output pin

try:
   while True:
     GPIO.output(outpin,GPIO.LOW)
     time.sleep(5)
     GPIO.output(outpin,GPIO.HIGH)
     time.sleep(5)
except KeyboardInterrupt: # If CTRL+C is pressed, exit cleanly:
   GPIO.cleanup() # cleanup all GPIO

[toc] | [prev] | [next] | [standalone]


#12623

Fromrickman <gnuarm@gmail.com>
Date2016-07-06 23:55 -0400
Message-ID<nlkjro$pe$1@dont-email.me>
In reply to#12622
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?

-- 

Rick C

[toc] | [prev] | [next] | [standalone]


#12642

FromDennis <dennis@none.none>
Date2016-07-07 12:30 -0500
Message-ID<nlm3js$ppl$1@dont-email.me>
In reply to#12623
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.

[toc] | [prev] | [next] | [standalone]


#12641

FromBjörn Lundin <b.f.lundin@gmail.com>
Date2016-07-07 19:21 +0200
Message-ID<nlm31a$nj7$1@dont-email.me>
In reply to#12617
On 2016-07-06 23:03, rickman wrote:

Thanks rickman, for your replies

> 
> 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.

Hmm, yes, but I did try feeding it 5 V as well. no go


> The other is the rated current, 71.4 mA.  This is far higher than what
> the rPi I/Os can drive.

That might be the problem.
Still, if I grounded the signal pin, the relay came to life,
so the coil was fed enough to click/switch the relay



> 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.

Yes, I realize that now. Either I do that or try it with an arduino.
I could communicate with the arduino via the serial port


> 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.

Yes and I read a good part. Some info indicates it is ok to use directly
with the pi, while other indicates that a transistor is needed. I just
thought it was very strange that I got movement when I grounded the
middle pin. As you can tell, electronics is not my strongest subject.

<https://www.youtube.com/watch?v=OvWOcNiQe1c>
indicates 3 min into the movie that no transistor i needed.

I try the arduino , and it it works, I'll use that instead

I got a big server in the garage that gathers data at night.
I don't want to run it during the day, so I'm thinking of
automatically ssh in to it and issue a sudo halt using expect from the
pi. This still leaves the fans on, so I'd like to kill the power to it
via the relay. and when power is restored, it boots automatically.



-- 
--
Björn

[toc] | [prev] | [next] | [standalone]


#12644

Fromrickman <gnuarm@gmail.com>
Date2016-07-07 14:34 -0400
Message-ID<nlm7b7$7vo$1@dont-email.me>
In reply to#12641
On 7/7/2016 1:21 PM, Björn Lundin wrote:
> On 2016-07-06 23:03, rickman wrote:
>
> Thanks rickman, for your replies
>
>>
>> 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.
>
> Hmm, yes, but I did try feeding it 5 V as well. no go
>
>
>> The other is the rated current, 71.4 mA.  This is far higher than what
>> the rPi I/Os can drive.
>
> That might be the problem.
> Still, if I grounded the signal pin, the relay came to life,
> so the coil was fed enough to click/switch the relay
>
>
>
>> 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.
>
> Yes, I realize that now. Either I do that or try it with an arduino.
> I could communicate with the arduino via the serial port
>
>
>> 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.
>
> Yes and I read a good part. Some info indicates it is ok to use directly
> with the pi, while other indicates that a transistor is needed. I just
> thought it was very strange that I got movement when I grounded the
> middle pin. As you can tell, electronics is not my strongest subject.
>
> <https://www.youtube.com/watch?v=OvWOcNiQe1c>
> indicates 3 min into the movie that no transistor i needed.
>
> I try the arduino , and it it works, I'll use that instead
>
> I got a big server in the garage that gathers data at night.
> I don't want to run it during the day, so I'm thinking of
> automatically ssh in to it and issue a sudo halt using expect from the
> pi. This still leaves the fans on, so I'd like to kill the power to it
> via the relay. and when power is restored, it boots automatically.

As Dennis pointed out there is a fuzzy blob on the photo that looks like 
it is three terminal and likely a transistor.  So you would need to 
trace out the circuit to see what they have designed.  The circuit on 
the module Dennis has turned out to be a high side switch which means it 
is handling the higher current for you, but is referenced to 5 volts and 
so will over stress your rPi I/O pin.  If this is what is on your module 
it is not a good idea to drive this relay directly from your rPi I/O. 
It will need another transistor to handle the voltage translation.  Just 
one transistor and two resistors.  I would use a common base arrangement 
with the base biased to about 1 volt.  Or you can use a common emitter 
arrangement which will invert the sense of the signal which you can 
compensate for in the software.

Some Arduinos are 5 volt devices which will drive this I/O directly. 
But first you need to trace out the circuit to see just what you have.

-- 

Rick C

[toc] | [prev] | [next] | [standalone]


#12645

FromDennis <dennis@none.none>
Date2016-07-07 17:10 -0500
Message-ID<nlmjvp$pq8$1@dont-email.me>
In reply to#12644
On 07/07/2016 01:34 PM, rickman wrote:
> On 7/7/2016 1:21 PM, Björn Lundin wrote:
>> On 2016-07-06 23:03, rickman wrote:
>>
>> Thanks rickman, for your replies
>>
>>>
>>> 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.
>>
>> Hmm, yes, but I did try feeding it 5 V as well. no go
>>
>>
>>> The other is the rated current, 71.4 mA.  This is far higher than what
>>> the rPi I/Os can drive.
>>
>> That might be the problem.
>> Still, if I grounded the signal pin, the relay came to life,
>> so the coil was fed enough to click/switch the relay
>>
>>
>>
>>> 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.
>>
>> Yes, I realize that now. Either I do that or try it with an arduino.
>> I could communicate with the arduino via the serial port
>>
>>
>>> 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.
>>
>> Yes and I read a good part. Some info indicates it is ok to use directly
>> with the pi, while other indicates that a transistor is needed. I just
>> thought it was very strange that I got movement when I grounded the
>> middle pin. As you can tell, electronics is not my strongest subject.
>>
>> <https://www.youtube.com/watch?v=OvWOcNiQe1c>
>> indicates 3 min into the movie that no transistor i needed.
>>
>> I try the arduino , and it it works, I'll use that instead
>>
>> I got a big server in the garage that gathers data at night.
>> I don't want to run it during the day, so I'm thinking of
>> automatically ssh in to it and issue a sudo halt using expect from the
>> pi. This still leaves the fans on, so I'd like to kill the power to it
>> via the relay. and when power is restored, it boots automatically.
>
> As Dennis pointed out there is a fuzzy blob on the photo that looks like
> it is three terminal and likely a transistor.  So you would need to
> trace out the circuit to see what they have designed.  The circuit on
> the module Dennis has turned out to be a high side switch which means it
> is handling the higher current for you, but is referenced to 5 volts and
> so will over stress your rPi I/O pin.  If this is what is on your module
> it is not a good idea to drive this relay directly from your rPi I/O. It
> will need another transistor to handle the voltage translation.  Just
> one transistor and two resistors.  I would use a common base arrangement
> with the base biased to about 1 volt.  Or you can use a common emitter
> arrangement which will invert the sense of the signal which you can
> compensate for in the software.
>
> Some Arduinos are 5 volt devices which will drive this I/O directly. But
> first you need to trace out the circuit to see just what you have.
>
I am pretty sure mine has the same circuit as his but with 2 relays. It 
looks similar and has "2 Relay Module" and "HL-52" on the board. I think 
they make 1, 2, 4 and 8 relay versions that are just multiple copies of 
the same circuit.

The question is why high switching (PNP) rather than low side (NPN) 
which would work fine with either 3.3 or 5 volts. My guess is for 
safety. The processors I know of come up with the I/O in input mode 
which would look like a high signal (tri-state or pull-up) which would 
leave the relay unenergized. You can then do your set up before changing 
to output mode and selecting the relay. Using an NPN could energize the 
relay immediately on power up which you may not want.

[toc] | [prev] | [next] | [standalone]


#12647

Fromrickman <gnuarm@gmail.com>
Date2016-07-08 00:29 -0400
Message-ID<nlna7g$em8$1@dont-email.me>
In reply to#12645
On 7/7/2016 6:10 PM, Dennis wrote:
> On 07/07/2016 01:34 PM, rickman wrote:
>> On 7/7/2016 1:21 PM, Björn Lundin wrote:
>>> On 2016-07-06 23:03, rickman wrote:
>>>
>>> Thanks rickman, for your replies
>>>
>>>>
>>>> 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.
>>>
>>> Hmm, yes, but I did try feeding it 5 V as well. no go
>>>
>>>
>>>> The other is the rated current, 71.4 mA.  This is far higher than what
>>>> the rPi I/Os can drive.
>>>
>>> That might be the problem.
>>> Still, if I grounded the signal pin, the relay came to life,
>>> so the coil was fed enough to click/switch the relay
>>>
>>>
>>>
>>>> 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.
>>>
>>> Yes, I realize that now. Either I do that or try it with an arduino.
>>> I could communicate with the arduino via the serial port
>>>
>>>
>>>> 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.
>>>
>>> Yes and I read a good part. Some info indicates it is ok to use directly
>>> with the pi, while other indicates that a transistor is needed. I just
>>> thought it was very strange that I got movement when I grounded the
>>> middle pin. As you can tell, electronics is not my strongest subject.
>>>
>>> <https://www.youtube.com/watch?v=OvWOcNiQe1c>
>>> indicates 3 min into the movie that no transistor i needed.
>>>
>>> I try the arduino , and it it works, I'll use that instead
>>>
>>> I got a big server in the garage that gathers data at night.
>>> I don't want to run it during the day, so I'm thinking of
>>> automatically ssh in to it and issue a sudo halt using expect from the
>>> pi. This still leaves the fans on, so I'd like to kill the power to it
>>> via the relay. and when power is restored, it boots automatically.
>>
>> As Dennis pointed out there is a fuzzy blob on the photo that looks like
>> it is three terminal and likely a transistor.  So you would need to
>> trace out the circuit to see what they have designed.  The circuit on
>> the module Dennis has turned out to be a high side switch which means it
>> is handling the higher current for you, but is referenced to 5 volts and
>> so will over stress your rPi I/O pin.  If this is what is on your module
>> it is not a good idea to drive this relay directly from your rPi I/O. It
>> will need another transistor to handle the voltage translation.  Just
>> one transistor and two resistors.  I would use a common base arrangement
>> with the base biased to about 1 volt.  Or you can use a common emitter
>> arrangement which will invert the sense of the signal which you can
>> compensate for in the software.
>>
>> Some Arduinos are 5 volt devices which will drive this I/O directly. But
>> first you need to trace out the circuit to see just what you have.
>>
> I am pretty sure mine has the same circuit as his but with 2 relays. It
> looks similar and has "2 Relay Module" and "HL-52" on the board. I think
> they make 1, 2, 4 and 8 relay versions that are just multiple copies of
> the same circuit.

I have seen Chinese boards made to do the same job but by different 
companies.  They can vary widely while appearing very similar.  So I 
don't share your confidence of the two circuits being the same, but I 
certainly can't rule it out.


> The question is why high switching (PNP) rather than low side (NPN)
> which would work fine with either 3.3 or 5 volts. My guess is for
> safety. The processors I know of come up with the I/O in input mode
> which would look like a high signal (tri-state or pull-up) which would
> leave the relay unenergized. You can then do your set up before changing
> to output mode and selecting the relay. Using an NPN could energize the
> relay immediately on power up which you may not want.

It would not be an issue if the output comes up high impedance (which is 
not a pull-up).  Either a high side or low side switch could default to 
off.  A pull up or a pull down as appropriate should be on the relay 
module.  I agree that there seems to be little difference between the 
high side and the low side switch.  So I can't say why they would use 
the high side switch.

-- 

Rick C

[toc] | [prev] | [next] | [standalone]


#12700

FromBjörn Lundin <b.f.lundin@gmail.com>
Date2016-07-12 10:18 +0200
Message-ID<nm295b$82f$1@dont-email.me>
In reply to#12641
On 2016-07-07 19:21, Björn Lundin wrote:

> I try the arduino , and it it works, I'll use that instead

It does work as expected.
So the current solution to the problem below is
a small arduino program that reads serial input
and sets/clears a pinout depending on input.

On the other side, a raspberry pi,
connected to the serial port. A MAX-232 is between them.


> 
> I got a big server in the garage that gathers data at night.
> I don't want to run it during the day, so I'm thinking of
> automatically ssh in to it and issue a sudo halt using expect from the
> pi. This still leaves the fans on, so I'd like to kill the power to it
> via the relay. and when power is restored, it boots automatically.
> 

This setup will likely change.
I've ordered 2 things to make my life easier in the future.
* the double relay with integrated transistors as per Gordon's
recommendations.

* a 5 V to 3.3 V converter (Ebay 272249807035)

So I'll experiment a bit with them when arrived.

Thanks all for your inputs


-- 
--
Björn

[toc] | [prev] | [next] | [standalone]


#12704

FromRob Morley <nospam@ntlworld.com>
Date2016-07-12 12:49 +0100
Message-ID<20160712124959.7715b29a@Mars>
In reply to#12700
On Tue, 12 Jul 2016 10:18:51 +0200
Björn Lundin <b.f.lundin@gmail.com> wrote:
 
> Thanks all for your inputs
> 
> 
And outputs?


[toc] | [prev] | [next] | [standalone]


#12626

FromGordon Henderson <gordon+usenet@drogon.net>
Date2016-07-07 10:44 +0000
Message-ID<nllbra$3ga$1@dont-email.me>
In reply to#12614
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)

[toc] | [prev] | [next] | [standalone]


#12683

FromBjörn Lundin <b.f.lundin@gmail.com>
Date2016-07-10 17:40 +0200
Message-ID<nltq7o$8kj$1@dont-email.me>
In reply to#12626
On 2016-07-07 12:44, Gordon Henderson wrote:

>>
>> 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.
> 

Well, what can I say. One born any minute ?


> 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.

correct, it does.

> 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.

and it does


> 
>   gpio -g mode 22 in
> 
> Relay should click off.
> 

this one too.
toggling the port bewteen in and out toggles the relay


> Really, you need to throw this relay board away and get something designed
> for the Pi. Use something like a PiFace board.

I'll hook it up via my arduiono, if I can bring that to life again.

> Gordon
> (Author of wiringPi)

And thanks a lot for the walk-trough for dummies,
and for wiringPi.




-- 
--
Björn

[toc] | [prev] | [next] | [standalone]


#12684

Fromrickman <gnuarm@gmail.com>
Date2016-07-10 12:43 -0400
Message-ID<nlttuo$m3v$1@dont-email.me>
In reply to#12683
On 7/10/2016 11:40 AM, Björn Lundin wrote:
> On 2016-07-07 12:44, Gordon Henderson wrote:
>
>>>
>>> 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.
>>
>
> Well, what can I say. One born any minute ?
>
>
>> 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.
>
> correct, it does.

Info on this module is scant.  Is there a reason why you don't trace out 
the circuit so you know for sure what the circuit is?  It shouldn't be 
that hard to do.

If you only have one transistor, the circuit you have is most likely the 
one Gordon is thinking of.  But it is always possible not.  Trace it out 
and we'll know for sure.


>> 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.
>
> and it does
>
>
>>
>>   gpio -g mode 22 in
>>
>> Relay should click off.
>>
>
> this one too.
> toggling the port bewteen in and out toggles the relay
>
>
>> Really, you need to throw this relay board away and get something designed
>> for the Pi. Use something like a PiFace board.
>
> I'll hook it up via my arduiono, if I can bring that to life again.

It can be used with the rPi if you use something to limit the voltage on 
the I/O pin.  A blue, white or UV LED would be perfect for this.  As 
long as the circuit on the relay board has a resistor in the path from 5 
volts to the input pin, the LED can safely clamp the voltage at that pin 
to about 3.3 volts protecting the rPi I/O.  Use an IR LED in series 
between the rPi and the relay board and it will drop the excess voltage 
so the visible LED won't cause the relay circuit to activate.

           |                     |    Relay          _____
           |                     |    Module        /     |
           |          IR LED     |                |_     ---
  rPi      |           | /|      |               |/      Gnd
Header  -->>----+-----|< |------<<----\/\/\-----|  PNP
Output    |     |     | \|      |               |\
           |    _|_              |                 \
           |    \ /              |                 |
           |     V   Blue, White |                 |
           |   ----- or UV LED   |                 C||
           |     |               |                 C|| Relay
                 |                                 C|| Coil
                 |                                 |
                ---                               ---
                Gnd                             5 volts

If the circuit on the relay board doesn't have the resistor on the base 
you need to add it to your circuit, but I find that unlikely.

The base-emitter junction of the transistor will drop 0.7 volts when 
forward biased.  The IR LED will drop about 1.2 volts and the blue LED 
will drop around 3.4 volts.  This adds up to more than 5 volts which 
means only a very small current will flow (your goal) when the rPi 
output is not pulling low.  This should not be enough to pull in the 
relay.  If the relay still activates without being pulled low by the rPi 
output, use a red LED in place of the IR (or add some series 
resistance), but I'm pretty sure this won't be needed.  The relay needs 
significant current to activate and the transistor only has so much gain.

Just an idea to let you use this module with your rPi.  This circuit 
works for a lot of 5 volt circuits as long as a small trickle current 
won't trigger it.

Rick C.


>> Gordon
>> (Author of wiringPi)
>
> And thanks a lot for the walk-trough for dummies,
> and for wiringPi.



-- 

Rick C

[toc] | [prev] | [next] | [standalone]


#12699

FromBjörn Lundin <b.f.lundin@gmail.com>
Date2016-07-12 10:06 +0200
Message-ID<nm28f3$62f$1@dont-email.me>
In reply to#12684
On 2016-07-10 18:43, rickman wrote:
> 
> Info on this module is scant.  Is there a reason why you don't trace out
> the circuit so you know for sure what the circuit is?  It shouldn't be
> that hard to do.
> 
> If you only have one transistor, the circuit you have is most likely the
> one Gordon is thinking of.  But it is always possible not.  Trace it out
> and we'll know for sure.

Yes, there is a reason. I'm a software guy,
and although I do understand Ohms law,
when it comes to transistors, I'm lost.

So I would not know where to start.


> 
> It can be used with the rPi if you use something to limit the voltage on
> the I/O pin.  A blue, white or UV LED would be perfect for this.  As
> long as the circuit on the relay board has a resistor in the path from 5
> volts to the input pin, the LED can safely clamp the voltage at that pin
> to about 3.3 volts protecting the rPi I/O.  Use an IR LED in series
> between the rPi and the relay board and it will drop the excess voltage
> so the visible LED won't cause the relay circuit to activate.
> 
>           |                     |    Relay          _____
>           |                     |    Module        /     |
>           |          IR LED     |                |_     ---
>  rPi      |           | /|      |               |/      Gnd
> Header  -->>----+-----|< |------<<----\/\/\-----|  PNP
> Output    |     |     | \|      |               |\
>           |    _|_              |                 \
>           |    \ /              |                 |
>           |     V   Blue, White |                 |
>           |   ----- or UV LED   |                 C||
>           |     |               |                 C|| Relay
>                 |                                 C|| Coil
>                 |                                 |
>                ---                               ---
>                Gnd                             5 volts
> 
> If the circuit on the relay board doesn't have the resistor on the base
> you need to add it to your circuit, but I find that unlikely.
> 
> The base-emitter junction of the transistor will drop 0.7 volts when
> forward biased.  The IR LED will drop about 1.2 volts and the blue LED
> will drop around 3.4 volts.  This adds up to more than 5 volts which
> means only a very small current will flow (your goal) when the rPi
> output is not pulling low.  This should not be enough to pull in the
> relay.  If the relay still activates without being pulled low by the rPi
> output, use a red LED in place of the IR (or add some series
> resistance), but I'm pretty sure this won't be needed.  The relay needs
> significant current to activate and the transistor only has so much gain.
> 
> Just an idea to let you use this module with your rPi.  This circuit
> works for a lot of 5 volt circuits as long as a small trickle current
> won't trigger it.

And this drawing is beautiful. However it is over my head.
But I really appreciate the effort

--
Björn

[toc] | [prev] | [next] | [standalone]


#12701

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2016-07-12 09:20 +0100
Message-ID<nm298t$8mp$1@news.albasani.net>
In reply to#12699
On 12/07/16 09:06, Björn Lundin wrote:
> On 2016-07-10 18:43, rickman wrote:
>>
>> Info on this module is scant.  Is there a reason why you don't trace out
>> the circuit so you know for sure what the circuit is?  It shouldn't be
>> that hard to do.
>>
>> If you only have one transistor, the circuit you have is most likely the
>> one Gordon is thinking of.  But it is always possible not.  Trace it out
>> and we'll know for sure.
>
> Yes, there is a reason. I'm a software guy,
> and although I do understand Ohms law,
> when it comes to transistors, I'm lost.
>
> So I would not know where to start.
>
>
>>
>> It can be used with the rPi if you use something to limit the voltage on
>> the I/O pin.  A blue, white or UV LED would be perfect for this.  As
>> long as the circuit on the relay board has a resistor in the path from 5
>> volts to the input pin, the LED can safely clamp the voltage at that pin
>> to about 3.3 volts protecting the rPi I/O.  Use an IR LED in series
>> between the rPi and the relay board and it will drop the excess voltage
>> so the visible LED won't cause the relay circuit to activate.
>>
>>            |                     |    Relay          _____
>>            |                     |    Module        /     |
>>            |          IR LED     |                |_     ---
>>   rPi      |           | /|      |               |/      Gnd
>> Header  -->>----+-----|< |------<<----\/\/\-----|  PNP
>> Output    |     |     | \|      |               |\
>>            |    _|_              |                 \
>>            |    \ /              |                 |
>>            |     V   Blue, White |                 |
>>            |   ----- or UV LED   |                 C||
>>            |     |               |                 C|| Relay
>>                  |                                 C|| Coil
>>                  |                                 |
>>                 ---                               ---
>>                 Gnd                             5 volts
>>
>> If the circuit on the relay board doesn't have the resistor on the base
>> you need to add it to your circuit, but I find that unlikely.
>>
>> The base-emitter junction of the transistor will drop 0.7 volts when
>> forward biased.  The IR LED will drop about 1.2 volts and the blue LED
>> will drop around 3.4 volts.  This adds up to more than 5 volts which
>> means only a very small current will flow (your goal) when the rPi
>> output is not pulling low.  This should not be enough to pull in the
>> relay.  If the relay still activates without being pulled low by the rPi
>> output, use a red LED in place of the IR (or add some series
>> resistance), but I'm pretty sure this won't be needed.  The relay needs
>> significant current to activate and the transistor only has so much gain.
>>
>> Just an idea to let you use this module with your rPi.  This circuit
>> works for a lot of 5 volt circuits as long as a small trickle current
>> won't trigger it.
>
> And this drawing is beautiful. However it is over my head.

It is also wrong.


> But I really appreciate the effort
>
> --
> Björn
>


-- 
“it should be clear by now to everyone that activist environmentalism 
(or environmental activism) is becoming a general ideology about humans, 
about their freedom, about the relationship between the individual and 
the state, and about the manipulation of people under the guise of a 
'noble' idea. It is not an honest pursuit of 'sustainable development,' 
a matter of elementary environmental protection, or a search for 
rational mechanisms designed to achieve a healthy environment. Yet 
things do occur that make you shake your head and remind yourself that 
you live neither in Joseph Stalin’s Communist era, nor in the Orwellian 
utopia of 1984.”

Vaclav Klaus

[toc] | [prev] | [next] | [standalone]


#12702

Fromrickman <gnuarm@gmail.com>
Date2016-07-12 04:23 -0400
Message-ID<nm29ed$8f7$1@dont-email.me>
In reply to#12699
On 7/12/2016 4:06 AM, Björn Lundin wrote:
> On 2016-07-10 18:43, rickman wrote:
>>
>> Info on this module is scant.  Is there a reason why you don't trace out
>> the circuit so you know for sure what the circuit is?  It shouldn't be
>> that hard to do.
>>
>> If you only have one transistor, the circuit you have is most likely the
>> one Gordon is thinking of.  But it is always possible not.  Trace it out
>> and we'll know for sure.
>
> Yes, there is a reason. I'm a software guy,
> and although I do understand Ohms law,
> when it comes to transistors, I'm lost.
>
> So I would not know where to start.
>
>
>>
>> It can be used with the rPi if you use something to limit the voltage on
>> the I/O pin.  A blue, white or UV LED would be perfect for this.  As
>> long as the circuit on the relay board has a resistor in the path from 5
>> volts to the input pin, the LED can safely clamp the voltage at that pin
>> to about 3.3 volts protecting the rPi I/O.  Use an IR LED in series
>> between the rPi and the relay board and it will drop the excess voltage
>> so the visible LED won't cause the relay circuit to activate.
>>
>>           |                     |    Relay          _____
>>           |                     |    Module        /     |
>>           |          IR LED     |                |_     ---
>>  rPi      |           | /|      |               |/      Gnd
>> Header  -->>----+-----|< |------<<----\/\/\-----|  PNP
>> Output    |     |     | \|      |               |\
>>           |    _|_              |                 \
>>           |    \ /              |                 |
>>           |     V   Blue, White |                 |
>>           |   ----- or UV LED   |                 C||
>>           |     |               |                 C|| Relay
>>                 |                                 C|| Coil
>>                 |                                 |
>>                ---                               ---
>>                Gnd                             5 volts
>>
>> If the circuit on the relay board doesn't have the resistor on the base
>> you need to add it to your circuit, but I find that unlikely.
>>
>> The base-emitter junction of the transistor will drop 0.7 volts when
>> forward biased.  The IR LED will drop about 1.2 volts and the blue LED
>> will drop around 3.4 volts.  This adds up to more than 5 volts which
>> means only a very small current will flow (your goal) when the rPi
>> output is not pulling low.  This should not be enough to pull in the
>> relay.  If the relay still activates without being pulled low by the rPi
>> output, use a red LED in place of the IR (or add some series
>> resistance), but I'm pretty sure this won't be needed.  The relay needs
>> significant current to activate and the transistor only has so much gain.
>>
>> Just an idea to let you use this module with your rPi.  This circuit
>> works for a lot of 5 volt circuits as long as a small trickle current
>> won't trigger it.
>
> And this drawing is beautiful. However it is over my head.
> But I really appreciate the effort

Ok, sorry for making this complicated.  Transistors aren't hard to 
understand if you get to the point where you would like to learn.

-- 

Rick C

[toc] | [prev] | [next] | [standalone]


#12703

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2016-07-12 09:58 +0100
Message-ID<nm2bga$cd9$3@news.albasani.net>
In reply to#12702
On 12/07/16 09:23, rickman wrote:
> On 7/12/2016 4:06 AM, Björn Lundin wrote:
>> On 2016-07-10 18:43, rickman wrote:
>>>
>>> Info on this module is scant.  Is there a reason why you don't trace out
>>> the circuit so you know for sure what the circuit is?  It shouldn't be
>>> that hard to do.
>>>
>>> If you only have one transistor, the circuit you have is most likely the
>>> one Gordon is thinking of.  But it is always possible not.  Trace it out
>>> and we'll know for sure.
>>
>> Yes, there is a reason. I'm a software guy,
>> and although I do understand Ohms law,
>> when it comes to transistors, I'm lost.
>>
>> So I would not know where to start.
>>
>>
>>>
>>> It can be used with the rPi if you use something to limit the voltage on
>>> the I/O pin.  A blue, white or UV LED would be perfect for this.  As
>>> long as the circuit on the relay board has a resistor in the path from 5
>>> volts to the input pin, the LED can safely clamp the voltage at that pin
>>> to about 3.3 volts protecting the rPi I/O.  Use an IR LED in series
>>> between the rPi and the relay board and it will drop the excess voltage
>>> so the visible LED won't cause the relay circuit to activate.
>>>
>>>           |                     |    Relay          _____
>>>           |                     |    Module        /     |
>>>           |          IR LED     |                |_     ---
>>>  rPi      |           | /|      |               |/      Gnd
>>> Header  -->>----+-----|< |------<<----\/\/\-----|  PNP
>>> Output    |     |     | \|      |               |\
>>>           |    _|_              |                 \
>>>           |    \ /              |                 |
>>>           |     V   Blue, White |                 |
>>>           |   ----- or UV LED   |                 C||
>>>           |     |               |                 C|| Relay
>>>                 |                                 C|| Coil
>>>                 |                                 |
>>>                ---                               ---
>>>                Gnd                             5 volts
>>>
>>> If the circuit on the relay board doesn't have the resistor on the base
>>> you need to add it to your circuit, but I find that unlikely.
>>>
>>> The base-emitter junction of the transistor will drop 0.7 volts when
>>> forward biased.  The IR LED will drop about 1.2 volts and the blue LED
>>> will drop around 3.4 volts.  This adds up to more than 5 volts which
>>> means only a very small current will flow (your goal) when the rPi
>>> output is not pulling low.  This should not be enough to pull in the
>>> relay.  If the relay still activates without being pulled low by the rPi
>>> output, use a red LED in place of the IR (or add some series
>>> resistance), but I'm pretty sure this won't be needed.  The relay needs
>>> significant current to activate and the transistor only has so much
>>> gain.
>>>
>>> Just an idea to let you use this module with your rPi.  This circuit
>>> works for a lot of 5 volt circuits as long as a small trickle current
>>> won't trigger it.
>>
>> And this drawing is beautiful. However it is over my head.
>> But I really appreciate the effort
>
> Ok, sorry for making this complicated.  Transistors aren't hard to
> understand if you get to the point where you would like to learn.
>
but apparently too hard for you, as you have the power supply the wrong 
way round


-- 
If you tell a lie big enough and keep repeating it, people will 
eventually come to believe it. The lie can be maintained only for such 
time as the State can shield the people from the political, economic 
and/or military consequences of the lie. It thus becomes vitally 
important for the State to use all of its powers to repress dissent, for 
the truth is the mortal enemy of the lie, and thus by extension, the 
truth is the greatest enemy of the State.

Joseph Goebbels


[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.sys.raspberry-pi


csiph-web