antonbruhn
Posts: 14
Joined: Wed Feb 11, 2015 2:42 pm

GPIO pin doesnt deliver power

Mon Dec 05, 2016 12:58 pm

Hello!

Im up to a project with a relay. But the relay doesnt click when im running the script, there is a small led that blinks when im running the script so its coded right but it doesnt click.

When i take the signal wire and connect it directly to the 3,3v gipo pin the relay clicks. so its just like the gpio pin 26 doesnt deliver my power. any ideas what this can be ?

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13099
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: GPIO pin doesnt deliver power

Mon Dec 05, 2016 1:02 pm

GPIO pins are not designed to provide power!
They only can deliver a few mA, and only either a 0V or a 3.3V signal.
They are designed as control signals.
To drive a relay you will need a relay driver.
Beware that commercial relay driver boards are normally designed to be driven with 5V logical signals, NOT with 3.3V signals.
Be doubly careful to not under any circumstance get more than 4Volt on a GPIO, as that will destroy the GPIO, and thus the PI!
This can happen with badly designed relay boards, so be careful with them. Best if the board has a schematic you can post here to ask for advice.

antonbruhn
Posts: 14
Joined: Wed Feb 11, 2015 2:42 pm

Re: GPIO pin doesnt deliver power

Mon Dec 05, 2016 1:04 pm

mahjongg wrote:GPIO pins are not designed to provide power!
They only can deliver a few mA, and only either a 0V or a 3.3V signal.
Its only a signal that i need.
like 20 mAh

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13099
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: GPIO pin doesnt deliver power

Mon Dec 05, 2016 1:10 pm

That's too much, a GPIO cannot drive a relay directly!

Also you MUST add a reverse diode across the winding's of the relay, because if you break the current to the relay coil, a large negative voltage will appear across the winding's, which will destroy the relay driver, if you do not short that voltage with a diode.

Google for a relay driver, there are plenty to be found.

antonbruhn
Posts: 14
Joined: Wed Feb 11, 2015 2:42 pm

Re: GPIO pin doesnt deliver power

Mon Dec 05, 2016 1:13 pm

mahjongg wrote:GPIO pins are not designed to provide power!
They only can deliver a few mA, and only either a 0V or a 3.3V signal.
They are designed as control signals.
To drive a relay you will need a relay driver.
Beware that commercial relay driver boards are normally designed to be driven with 5V logical signals, NOT with 3.3V signals.
Be doubly careful to not under any circumstance get more than 4Volt on a GPIO, as that will destroy the GPIO, and thus the PI!
This can happen with badly designed relay boards, so be careful with them. Best if the board has a schematic you can post here to ask for advice.
i bought this. i think it is a relayboard.
http://www.electrokit.com/relakort-x2-5v.49419

User avatar
joan
Posts: 14936
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO pin doesnt deliver power

Mon Dec 05, 2016 1:14 pm

antonbruhn wrote:
mahjongg wrote:GPIO pins are not designed to provide power!
They only can deliver a few mA, and only either a 0V or a 3.3V signal.
Its only a signal that i need.
like 20 mAh
A GPIO may be able to deliver 20mA. It won't be able to drive much more.

Do you realise that the back EMF from a collapsing relay coil could destroy the GPIO and the Pi?

If you know what you are doing you could use two or more GPIO in parallel to supply the current.

If you destroy your Pi please don't come back here and complain.

antonbruhn
Posts: 14
Joined: Wed Feb 11, 2015 2:42 pm

Re: GPIO pin doesnt deliver power

Mon Dec 05, 2016 1:54 pm

so how do i use a relay board?

gordon77
Posts: 5036
Joined: Sun Aug 05, 2012 3:12 pm

Re: GPIO pin doesnt deliver power

Mon Dec 05, 2016 2:01 pm

You add an interface, eg transistor, opto isolator etc.

What relay are you using ?

drgeoff
Posts: 10765
Joined: Wed Jan 25, 2012 6:39 pm

Re: GPIO pin doesnt deliver power

Mon Dec 05, 2016 2:27 pm

antonbruhn wrote: Its only a signal that i need.
like 20 mAh
Learn to get your units right. mAh is current multiplied by time. Often used to specify battery capacity.

User avatar
joan
Posts: 14936
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO pin doesnt deliver power

Mon Dec 05, 2016 3:01 pm

antonbruhn wrote:so how do i use a relay board?
The relay module you have linked to will be safe. It isolates the relay itself from the Pi with suitable electronics.

If it operates from the 3V3 pin (pin 1) then the voltage isn't a problem, it's just the current. I would try connecting two GPIO to the relay module input rather than 1. Switching them both on should work to switch the relay module on.

User avatar
davidcoton
Posts: 5027
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: GPIO pin doesnt deliver power

Mon Dec 05, 2016 5:55 pm

joan wrote: I would try connecting two GPIO to the relay module input rather than 1. Switching them both on should work to switch the relay module on.
But as you said earlier,
If you destroy your Pi please don't come back here and complain.
@antonbruhn Unless your program always switches the two GPIOs together, without any possibility of interruption, sometime you will end up with a GPIO LOW connected to a GPIO HIGH. Potentially that is "Bye bye Miss Raspberry Pi".

I suggest using a single transistor (with a base resistor of 10K) to drive the relay, and supply the relay with 5V. I can't see if your board has a suppression diode for back EMF (inverse parallel across the relay coil), if not you should add one.
Signature retired

User avatar
joan
Posts: 14936
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO pin doesnt deliver power

Mon Dec 05, 2016 6:04 pm

davidcoton wrote: ...
But as you said earlier,
If you destroy your Pi please don't come back here and complain.
@antonbruhn Unless your program always switches the two GPIOs together, without any possibility of interruption, sometime you will end up with a GPIO LOW connected to a GPIO HIGH. Potentially that is "Bye bye Miss Raspberry Pi".
...
Potentially, yes.

However it is trivial to ensure that GPIO are switched as a group, e.g. http://abyz.co.uk/rpi/pigpio/python.html#set_bank_1

User avatar
Burngate
Posts: 6302
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: GPIO pin doesnt deliver power

Mon Dec 05, 2016 6:27 pm

That electrokit.com relay board has on its signal input a 1k resistor to the transistor base (emitter to ground), a 1k resistor into a LED to ground, and a 10k resistor to ground.
My calculation says the current can't be more than 5mA - I can't see that overloading the GPIO.

What I do see is that the relay itself could take 20mA, through the VCC terminal.

Are you by any chance connecting both the CH1 and VCC terminals to the GPIO? Quite possibly the relay would click if you connected both to 3v3, but a GPIO couldn't handle that.
VCC should be connected to 5v
Last edited by Burngate on Tue Dec 06, 2016 11:12 am, edited 1 time in total.

User avatar
davidcoton
Posts: 5027
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: GPIO pin doesnt deliver power

Mon Dec 05, 2016 10:57 pm

Burngate wrote:That electrokit.com relay board has on its signal input a 1k resistor to the transistor base (emitter to ground), a 1k resistor into a LED to ground, and a 10k resistor to ground.
My calculation says the current can't be more than 2mA - I can't see that overloading the GPIO.

What I do see is that the relay itself could take 20mA, through the VCC terminal.

Are you by any chance connecting both the CH1 and VCC terminals to the GPIO? Quite possibly the relay would click if you connected both to 3v3, but a GPIO couldn't handle that.
VCC should be connected to 5v
It's amazing what you can find out when you click on the schematic link! Burngate is correct, the drive circuit (and suppression diode) is onboard and should "just work", but Vcc needs to be connected to 5V (from the Pi or elsewhere).
Signature retired

Return to “Troubleshooting”