pranavgangani
Posts: 31
Joined: Sun Nov 23, 2014 2:39 pm
Location: India

Relay not sending current to NO port

Tue Sep 22, 2015 6:04 am

I am having RasPi Model B+. I have connected a christmas light to my relay. The live wire passes through the Relay's COM port and the wire to the light is connected to the NO port.
I am using Pi4J to connect to the Relay with the below java code but the current does not flow from COM port to the NO port. The red led on the Relay port does turn on.
I even tried to check if the device_tree exists in /boot/config.txt but it doesn't exist. (As specified in one of the forum topic viewtopic.php?f=28&t=104076). I am banging my head on this since a week now.

Am I missing something? Could it be that my relay is faulty?

Code: Select all

pin = gpioController.provisionDigitalOutputPin(RaspiPin.GPIO_00, "light", PinState.LOW);	
pin.toggle();
The output of the

Code: Select all

gpio readall 
is as below. GPIO Pin 0 turns 1 from 0 but the lights do not blink.
+-----+-----+---------+------+---+--B Plus--+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| 17 | 0 | GPIO. 0 | OUT | 0 | 11 || 12 | 0 | IN | GPIO. 1 | 1 | 18 |

| 17 | 0 | GPIO. 0 | OUT | 1 | 11 || 12 | 0 | IN | GPIO. 1 | 1 | 18 |
unnamed.jpg
ChristmasLightRaspiRelay
unnamed.jpg (25.72 KiB) Viewed 3823 times

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: Relay not sending current to NO port

Tue Sep 22, 2015 7:17 am

Are you providing power to the relay coil?

Can you provide a schematic for the relay board?

What connections have you made to the relay board?

pranavgangani
Posts: 31
Joined: Sun Nov 23, 2014 2:39 pm
Location: India

Re: Relay not sending current to NO port

Tue Sep 22, 2015 8:00 am

ame wrote:Are you providing power to the relay coil?

Can you provide a schematic for the relay board?

What connections have you made to the relay board?
Yes I am providing a 5v power through the Raspberry Pi. The Relay board is this one http://www.ebay.in/itm/16-Channel-12V-R ... 2a57fa62d6
I know its a 12v Relay but I read somewhere that even 5v from the Pi board is fine when you have nothing else connected to the Pi like usb externals harddisk, usb wifi dongle, etc.

The light on the Relay board even turns on as soon as I execute any of the below 2 commands

Code: Select all

pin = gpioController.provisionDigitalOutputPin(RaspiPin.GPIO_00, "light", PinState.LOW);

or

Code: Select all

pin = gpioController.provisionDigitalOutputPin(RaspiPin.GPIO_00, "light", PinState.HIGH);
Here is what it looks like.
connections.png
connections.png (10.06 KiB) Viewed 3791 times
I am no electronics guy, I am a programmer by profession, so my diagram may not be a perfect one.

Pi 5v (Pin 2) -> Relay VCC
Pi GND (Pin 6) -> Relay GND
Pi (Pin 11) -> Relay In

Thanks.

Massi
Posts: 1690
Joined: Fri May 02, 2014 1:52 pm
Location: Italy

Re: Relay not sending current to NO port

Tue Sep 22, 2015 9:17 am

do you hear a "click" when toggling the relay? i don't think so.. but i think it's a matter of Vcc and not of signal. Try powering the board from a different power source (12V should be quite easy to get..). Remember that you have to common ground between the 12V power supply and the raspberry.

pranavgangani
Posts: 31
Joined: Sun Nov 23, 2014 2:39 pm
Location: India

Re: Relay not sending current to NO port

Tue Sep 22, 2015 9:22 am

Massi wrote:do you hear a "click" when toggling the relay? i don't think so.. but i think it's a matter of Vcc and not of signal. Try powering the board from a different power source (12V should be quite easy to get..). Remember that you have to common ground between the 12V power supply and the raspberry.
No I don't hear a click. I will try powering it with 12V power supply and then come back. I didn't get your last point. Could you explain a bit more?

Massi
Posts: 1690
Joined: Fri May 02, 2014 1:52 pm
Location: Italy

Re: Relay not sending current to NO port

Tue Sep 22, 2015 9:24 am

pranavgangani wrote:No I don't hear a click. I will try powering it with 12V power supply and then come back. I didn't get your last point. Could you explain a bit more?
Sure. In the same circuit you need a common point for voltages. So you can't connect + and - of the 12V power source AND the GPIO signal from the raspberry.
You need to connect + and - from the power source AND GPIO and ground from the raspberry.
So - and ground have to be connected.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: Relay not sending current to NO port

Tue Sep 22, 2015 9:33 am

Not necessarily. Some of these boards have optoisolators, so there is no common ground from the relay circuit to the Pi.

This is why a schematic is terribly useful.

Massi
Posts: 1690
Joined: Fri May 02, 2014 1:52 pm
Location: Italy

Re: Relay not sending current to NO port

Tue Sep 22, 2015 9:38 am

ame wrote:Not necessarily. Some of these boards have optoisolators, so there is no common ground from the relay circuit to the Pi.

This is why a schematic is terribly useful.
optoisolator, afaik, is to separate the "control" from the "load"
i'm talking about common ground in the control circuit (so 3,3V of the GPIO - that is over the rpi ground - is also 3,3v over the power source ground).
Am i wrong?

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: Relay not sending current to NO port

Tue Sep 22, 2015 9:47 am

Massi wrote:
ame wrote:Not necessarily. Some of these boards have optoisolators, so there is no common ground from the relay circuit to the Pi.

This is why a schematic is terribly useful.
optoisolator, afaik, is to separate the "control" from the "load"
i'm talking about common ground in the control circuit (so 3,3V of the GPIO - that is over the rpi ground - is also 3,3v over the power source ground).
Am i wrong?
I have seen several designs for these relay boards. They all suck.

It is possible that the relay power (12V and GND) is separate from the optoisolator signal and GND.

We can't tell without a schematic, and OP is not experienced enough to draw one.

The photos on eBay are pretty clear if someone wants to have a go.

Massi
Posts: 1690
Joined: Fri May 02, 2014 1:52 pm
Location: Italy

Re: Relay not sending current to NO port

Tue Sep 22, 2015 10:03 am

ame wrote:It is possible that the relay power (12V and GND) is separate from the optoisolator signal and GND.
Ok, now i got your point :)
you are right (quite usual for you LOL), but in this case the board would have 2 different ground pin (and commonly there's a jumper connecting them..)

well, if the board is this (you can zoom) http://www.dhgate.com/product/16-channe ... 86628.html i'm not sure what's the case :)
is there a datasheet of this.. "thing"?

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: Relay not sending current to NO port

Tue Sep 22, 2015 10:40 am

It looks like it's been around for a while.

Here's another seller, but this one does not have the voltage regulator on it (which is probably not needed anyway):
http://www.dx.com/p/smkj-fc-16-channel- ... lue-347232

And there's this one:
http://www.sainsmart.com/16-channel-12v ... logic.html

Go down the page and there's a link to a manual...
http://www.selloutsoon.com/albums/docum ... -relay.rar

Unpack the file and there's a schematic and PCB artwork in PDF form.

It might not be exactly the same, but it probably is.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: Relay not sending current to NO port

Tue Sep 22, 2015 11:10 am

I think that this is only any good without the regulator.

I think 12V must be applied for the relay coils, but it must not be regulated to 5V because we don't want the 5V to be applied back to the Pi.

There doesn't seem to be a jumper to disconnect the common 5V line on the input from the 5V line on the output, therefore the opto-isolation is useless.

Ideally we'd connect 3.3V from the Pi to PR1 PR2 PR4 and PR7 (which I assume are resistor packs). Then connect GPIOs to IN1-IN16. To turn on the optoisolator (and the relay), set the GPIO to GND. To turn off the optoisolator, set the GPIO high, i.e. the logic is inverted, which is fine.

Next, we'd have 5V from the Pi (or the regulator) connected to the optoisolator outputs. This drives the ULN2803 buffer, which is powered from 12V, and then the relay coils.

It doesn't look like it would be easy to cut some traces on the board to make it work properly, but here's my suggestion:

Remove, or otherwise disable the 5V regulator. It might be possible to cut the trace next to L1, between it and U5.
Connect Pi 3.3V to the 5V pin on the "Low Level Input" pins.
Connect Pi GND to the GND pin on the "Low Level Input" pins.
Connect 12V (from somewhere) to the 12V input socket (positive and negative wires, polarity is important!)
Connect some Pi GPIO pins to the numbered pins 1-16.

I am assuming the 3.3V levels are enough to trigger the ULN2803 buffers (didn't check).

Write a program to set the GPIO low for relay "on" and high for relay "off".

This is yet another lame design with opto-isolators.
Last edited by ame on Tue Sep 22, 2015 11:49 pm, edited 1 time in total.

pranavgangani
Posts: 31
Joined: Sun Nov 23, 2014 2:39 pm
Location: India

Re: Relay not sending current to NO port

Tue Sep 22, 2015 1:44 pm

Thanks for all the efforts that you both have put in to explain in such a detailed way. Pardon me, but due to my limited knowledge in electronics I am not able to grasp all the things that you have explained but I will try to re-read everything to get what you are saying.
But what is confusing to me is the description in the ebay link of my relay. It says Onboard power supply module does not need an external power supply and we are talking of having an external 12v supply?
It also says Supply voltage: 5V 12V (DC) . Now what does that mean?
Can anybody sense what I am doing wrong just by the details mentioned in the description of my relay? :?
12V relay contact capacity 10A 250V, with optocoupler protection. Onboard power supply module does not need an external power supply. I / O port driver is active low.

Used as a microcontroller development board module can be used as appliance control, can be used as PLC extended output.

Module features:

Control signal voltage range: trigger signal is low 0-2V; high voltage must not exceed 5V.
Using the industry's top-quality isolation optocouplers, anti-interference ability, stable performance; trigger current is only 3mA.
1-16 can be any full on / off, or any road.
Output Type: AC 220V 10A or directly connected to DC30V 10A load.
Each relay common terminal COM are independent, user-friendly access to different signals, each relay are normally closed and normally open with the port.
Each relay is equipped with motion lights, pull off, off off.
Interface design humane, all interfaces are available through the terminal directly connected leads, very convenient.
Has four mounting bolts holes for easy installation.
PCB board size: 180MM (L) * 90MM (W) * 20MM (H)

Electrical parameters:

Supply voltage: 5V 12V (DC)
Supply Current: more than 200mA
Each relay can load: 250V 10A (AC) or 30V 10A (DC)

Note:

Power supply to meet the range DC 12V;
Power requirements according to wiring diagram, is not reversed;
Product LM2596S slight chip buck fever is a normal phenomenon, relays, long working hours have a normal fever phenomenon, are normal;
Load power to give leave a margin relay load should avoid high-power (about 2000W) and long working environment, there will be some impact on the life of the product.

pranavgangani
Posts: 31
Joined: Sun Nov 23, 2014 2:39 pm
Location: India

Re: Relay not sending current to NO port

Tue Sep 22, 2015 3:57 pm

I think I am getting more clearer after reading the reviews here http://www.amazon.com/SainSmart-16-CH-1 ... X6MKZKTM63.

So it looks like I will definitely have to power the relay with an external 12v power supply and remove the 5v jumper wires connecting the Pi to the Relay. But still not sure... :roll:

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: Relay not sending current to NO port

Tue Sep 22, 2015 11:48 pm

Yes, my post was a bit technical, but there is no other way. This board was not designed for the Pi, and in fact the design is rather poor.

You must be very careful not to feed 5V from anywhere back into the Pi's 3.3V pin or any of the GPIOs. The 5V regulator on the relay board is probably intended to power an Arduino so that you don't need an additional power supply. You could probably use it to power the Pi, but the fact remains that the 5V from the regulator is also connected to the relay driving circuit and could find its way back into the Pi's GPIOs.

I will think about it some more (and maybe someone else will post with some ideas) but I stick with my original suggestion, which is to provide a 12V supply to the board but disconnect or disable the 5V output, then use the Pi's 3.3V output to power the relay drivers.

Edit: I checked and changed the buffer chip part number. It's ULN2803. It looks like an input of more than 2.0V will trigger the output, so it will probably work with 3.3V from the Pi.

pranavgangani
Posts: 31
Joined: Sun Nov 23, 2014 2:39 pm
Location: India

Re: Relay not sending current to NO port

Wed Sep 23, 2015 5:15 am

ame wrote:Yes, my post was a bit technical, but there is no other way. This board was not designed for the Pi, and in fact the design is rather poor.

You must be very careful not to feed 5V from anywhere back into the Pi's 3.3V pin or any of the GPIOs. The 5V regulator on the relay board is probably intended to power an Arduino so that you don't need an additional power supply. You could probably use it to power the Pi, but the fact remains that the 5V from the regulator is also connected to the relay driving circuit and could find its way back into the Pi's GPIOs.

I will think about it some more (and maybe someone else will post with some ideas) but I stick with my original suggestion, which is to provide a 12V supply to the board but disconnect or disable the 5V output, then use the Pi's 3.3V output to power the relay drivers.

Edit: I checked and changed the buffer chip part number. It's ULN2803. It looks like an input of more than 2.0V will trigger the output, so it will probably work with 3.3V from the Pi.
Great, many thanks. So i will power my pi with a 5v adapter and power the relay with a 12v adapter. Will remove the 5v jumper wire connections from the pi gpio section to the relay board. The only thing then remains is the ground wire. I believe i should still have the ground of the pi's gpio section connected to the relay board's gnd(not the power supply)?

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: Relay not sending current to NO port

Wed Sep 23, 2015 5:23 am

pranavgangani wrote: Great, many thanks. So i will power my pi with a 5v adapter and power the relay with a 12v adapter. Will remove the 5v jumper wire connections from the pi gpio section to the relay board. The only thing then remains is the ground wire. I believe i should still have the ground of the pi's gpio section connected to the relay board's gnd(not the power supply)?
You also have to cut the PCB trace which links the 5V regulator on the relay board to the rest of the circuitry on the board. If you have never done this is there someone nearby who's into electronics who could help you out?

The Pi GND (from the GPIO header) must be connected to the relay board GND (on the 20-pin header). You will find that the GND pin on the header is connected to 12V GND too. You can see this from the schematic.

pranavgangani
Posts: 31
Joined: Sun Nov 23, 2014 2:39 pm
Location: India

Re: Relay not sending current to NO port

Wed Sep 23, 2015 8:06 am

ame wrote:
pranavgangani wrote: Great, many thanks. So i will power my pi with a 5v adapter and power the relay with a 12v adapter. Will remove the 5v jumper wire connections from the pi gpio section to the relay board. The only thing then remains is the ground wire. I believe i should still have the ground of the pi's gpio section connected to the relay board's gnd(not the power supply)?
You also have to cut the PCB trace which links the 5V regulator on the relay board to the rest of the circuitry on the board. If you have never done this is there someone nearby who's into electronics who could help you out?

The Pi GND (from the GPIO header) must be connected to the relay board GND (on the 20-pin header). You will find that the GND pin on the header is connected to 12V GND too. You can see this from the schematic.
I saw the schematic from the link that you provided and yes you are right, the GND is indeed connected to the 12v GND. Everything makes sense to me now.
Now I am just curious to know what if I do not cut the trace? What can be the consequence?

I have ordered a schematic for my relay from the supplier though. This weekend I will buy a 12v power adapter and try it and let you know the outcome.

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Relay not sending current to NO port

Wed Sep 23, 2015 8:11 am

pranavgangani wrote: Now I am just curious to know what if I do not cut the trace? What can be the consequence?
Pi go ByeBye.

If you (accidently) feed 5V into the 3v3 rail the SoC of the Pi will be destroyed.
Doug.
Building Management Systems Engineer.

pranavgangani
Posts: 31
Joined: Sun Nov 23, 2014 2:39 pm
Location: India

Re: Relay not sending current to NO port

Wed Sep 23, 2015 10:42 am

BMS Doug wrote:
pranavgangani wrote: Now I am just curious to know what if I do not cut the trace? What can be the consequence?
Pi go ByeBye.

If you (accidently) feed 5V into the 3v3 rail the SoC of the Pi will be destroyed.
I get it. So what can be the possible scenarios where the Relay Board pins sends 5v to the GPIO pins of 3.3v?

The possibilities that I can think of are,

1) If using Pi4J (java library) I use a listener for any changes to the voltages (by manually switching off the christmas light using the regular wall mounted switch) which sends a signal back to Pi.

2) A sudden surge in voltage from the mains due to external factors (lightning or anything else)?

Am I right in any sense? Is there anything else that can do the damage to the Pi?

User avatar
DougieLawson
Posts: 35054
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Relay not sending current to NO port

Wed Sep 23, 2015 5:17 pm

The safest way to drive a relay that needs 5V0 is to use a MCP23017 I2C chip as a buffer between the RPi @3V3 and the relay @5V0.

The MCP23017 gives you 16 extra GPIOs that are all 5V0 tolerant.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

pranavgangani
Posts: 31
Joined: Sun Nov 23, 2014 2:39 pm
Location: India

Re: Relay not sending current to NO port

Thu Sep 24, 2015 7:06 am

DougieLawson wrote:The safest way to drive a relay that needs 5V0 is to use a MCP23017 I2C chip as a buffer between the RPi @3V3 and the relay @5V0.

The MCP23017 gives you 16 extra GPIOs that are all 5V0 tolerant.
Thanks for the suggestion. But I am not an electronics guy so I do not want to do something that I am not aware of.

So I have this 12v 1.25Amp Power supply with me. It was an abandoned charger of an old printer. I believe this should drive the relay board. I just chopped off the end of the chord and now I have two bare wires coming out of it. Now I am concerned about the polarity.

http://www.ebay.com/itm/Delta-Electroni ... 7675.l2557

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: Relay not sending current to NO port

Thu Sep 24, 2015 7:16 am

Do you have a multimeter? Even a cheap one will start becoming very useful to you if you are starting to build electronic things.

If you don't have a multimeter can you make a continuity tester? It's basically a light and battery and a couple of wires. When the wires touch the light lights up. You can use it to test if something is connected to something else or not.

The connector you chopped off is a coaxial dc connector. It has an inner conductor and an outer conductor. In general the inner one is positive and the outer one is negative. On the PSU label I can see a diagram confirming that. Hopefully you left a short piece of cable on the connector when you chopped it off.

If you don't have a multimeter to tell you the polarity (red lead is positive (+ve), black lead is negative (-ve)) you could use a continuity tester to figure out whether the wire with the white stripe was connected to the inner or outer conductor of the connector. This will tell you which is the positive wire.

Alternatively, if you have an LED and a resistor (1k or greater) you can use that to figure out which is positive, because LEDs only light up one way.

Don't connect the relay board to the Pi until you have figured out what voltage appears where. A multimeter would be very useful for this.

pranavgangani
Posts: 31
Joined: Sun Nov 23, 2014 2:39 pm
Location: India

Re: Relay not sending current to NO port

Thu Sep 24, 2015 8:08 am

ame wrote:Do you have a multimeter? Even a cheap one will start becoming very useful to you if you are starting to build electronic things.
Yes, I will have to buy one it seems since I am planning to do home automation.
ame wrote:Hopefully you left a short piece of cable on the connector when you chopped it off.
Yes I have it.
ame wrote:you could use a continuity tester to figure out whether the wire with the white stripe was connected to the inner or outer conductor of the connector. This will tell you which is the positive wire.
Yes, I will try this method.
ame wrote:Don't connect the relay board to the Pi until you have figured out what voltage appears where. A multimeter would be very useful for this.
Absolutely.

Thanks a ton. This was good conversation and I learned a lot of things. I feel more confident now that I have much of the required information to begin with. I might do it this weekend and will give my feedback.

Massi
Posts: 1690
Joined: Fri May 02, 2014 1:52 pm
Location: Italy

Re: Relay not sending current to NO port

Thu Sep 24, 2015 8:22 am

pranavgangani wrote:
DougieLawson wrote:The safest way to drive a relay that needs 5V0 is to use a MCP23017 I2C chip as a buffer between the RPi @3V3 and the relay @5V0.

The MCP23017 gives you 16 extra GPIOs that are all 5V0 tolerant.
Thanks for the suggestion. But I am not an electronics guy so I do not want to do something that I am not aware of.
i understand your point, but you have to consider a couple of things:
- dougie is not someone you can contraddict. Just because he is right. always :)
- i understand that "use a MCP23017 I2C chip as a buffer" sounds bad and difficult. but it is indeed the easiest chip ever used. And, as dougie says, it's better to burn up it (a couple of dollars, on ebay) than a raspberry. Just for reference, please do a little google search for mcp23017.

Finally, you'll be able to controll ol the relays with that chip, so you'll have a lot of free gpio on the raspberry :)

Return to “Troubleshooting”