pyromagi
Posts: 9
Joined: Wed Dec 25, 2013 1:39 am

RaPI and relays?

Wed Dec 25, 2013 1:54 am

Hi,
I'm building a system based on Raspberry Pi, here is a video of my project: http://www.youtube.com/watch?v=8XDXqGEavTw
I have a Raspberry PI Rev2 card.
I have connected a 16ch relaycard to the Rasberry Pi's GPIO pins.
I have connected them by the following schema (the numbers to the right is BCM GPIO pin number):

Ch1 - 2
Ch2 - 3
Ch3 - 4
Ch4 - 17
Ch5 - 27
Ch6 - 22
Ch7 - 10
Ch8 - 9
Ch9 - 11
Ch10 - 7
Ch11 - 8
Ch12 - 25
Ch13 - 24
Ch14 - 23
Ch15 - 18
Ch16 - 15

I have installed wiringPi and that part works.
I have trouble with alot of the pins are only able to change a relay channel one time, lets say i open a relay channel, after that i can't close it again.

I'm opening a relay channel with gpio export 3 out, and that turns a light on. Then i would expect that gpio export 3 in would turn the light off. But it's only the led on the relayboard that is affected, the relay doent click.
I have this problem on 3, 4, 17, 27, 22, 11, 8, 25, 24, 23 and 18. On 2, 10, 9, 7 and 15 it works just fine.

I'd really love som help here. Any ideas?

southpaw
Posts: 52
Joined: Wed Nov 30, 2011 2:23 pm

Re: RaPI and relays?

Wed Dec 25, 2013 4:59 pm

think your using the wrong command, you can use 1 or high , for turn on,
for turn off use low or 0 (zero),
out and in are for establishing output or input (ie an led or a sensor of some type )
I could be totally wrong as I am no expert but worth a try I suppose :?

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: RaPI and relays?

Wed Dec 25, 2013 5:09 pm

Hi,
pyromagi wrote:Any ideas?
Voltmeter comes to mind... then schematics.

Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

pyromagi
Posts: 9
Joined: Wed Dec 25, 2013 1:39 am

Re: RaPI and relays?

Thu Dec 26, 2013 9:24 pm

Hi,
I would like to apologize, it seems to be a hardware related problem.
When i swaped bcm gpio2 (which works fine) with bcm gpio3 to one relay channel that didn't worked, I got the same result.
Which led me to believe that perhaps there was something wrong with the relay itself.
It works when i add current (3.3v) to the relay, it then closes. When i remove the current nothing happens, until i tap on the relay. Then it opens.

So i have ordered a new relay card.

Thank you for your inputs.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: RaPI and relays?

Thu Dec 26, 2013 11:10 pm

pyromagi wrote:Hi,
But it's only the led on the relayboard that is affected, the relay doent click.
I have this problem on 3, 4, 17, 27, 22, 11, 8, 25, 24, 23 and 18. On 2, 10, 9, 7 and 15 it works just fine.

I'd really love som help here. Any ideas?
Sounds like you are using a Sainsmart relay board. If so, take a piece of wire and jumper out the LEDs on the relay board. That should solve your problem.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

pyromagi
Posts: 9
Joined: Wed Dec 25, 2013 1:39 am

Re: RaPI and relays?

Thu Dec 26, 2013 11:21 pm

Actually not, I'm using http://www.ebay.com/itm/16-Channel-5V-1 ... 4607663d8c

But tonight i ordered a http://www.ebay.com/itm/12V-General-pur ... 3f2017024d

Think that will work better for me.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: RaPI and relays?

Fri Dec 27, 2013 6:31 am

There is a problem with some of the relay boards on the market. Due to the design, they need a hard path to ground, not a TTL low.

I have asked for a schematic of the board that you have. The seller is going to send me one. I will post it when I get it.

Richard
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip


User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: RaPI and relays?

Sat Dec 28, 2013 12:44 pm

After studying the schematics I see the problem.

The opto input is tied to VCC (+5 volts) . The opto input supply should be separate and selectable for use with the Rpi. Actually to do it right,the attached diagram is how it should be. Even it the opto input were tied to +3 volts, the logic is reversed. RPI gpio pin off=relay energized. There are other ways to make it non-inverting logic.

It really is a crap design as the default is the relays energized unless told otherwise.

So, unless you make some mods to the board, you cannot use it with the Rpi and it will need a +5 volt supply that is isolated from the opto input.

One day these board makers will consult with someone so that their product is useable with a wide variety of devices, not just an Arduino,
Attachments
new-relay.JPG
new-relay.JPG (33.4 KiB) Viewed 2038 times
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: RaPI and relays?

Sat Dec 28, 2013 1:09 pm

I don't understand why they would not use the other contacts on the relay either. What a mess.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

Return to “Automation, sensing and robotics”