I think I have a problem with voltage noise passing between supposedly isolated parts of a relay & don't know how to get rid of it.

I have recently bought a standard 5V relay module board (8-channel)* and can control it without issue using an mcp23017 connected to the pi (3).
However, when I connect the output of the relay to a mains connected appliance (light bulb for example) the relay no longer works.

I have determined that whenever the mains AC line is connected to the output, there is approximately 2V across the GND-In(any) of the relay inputs - this is present even if there are no other connections to the relay board.
Therefore the voltage signal coming from the controller can never drop the signal to 0V and the relay doesn't fire.

I also have a variable power supply up to 15V & that also causes noise on the input but only up to about 100mV & the relay will still energise.

Can anyone suggest a solution to this?
I want to be able to power several mains operated components (a smoke machine, fan & lights) for my current project.

If connecting AC mains to the relay output terminals causes 2 volts to appear on the ground of the 5v circuit, it suggests the is some thing wrong with either,

how you have the mains connected to the board,

there is a fault on the board which is shorting the relay contacts to the 5v circuit,

or possibly you have the relay board on a conductive surface which is causing a short.

Working with these relay boards and mains is not some thing I would recommend unless you have training and qualifications to work on mains electricity as the mains voltage is present on the back side of the pcb.

Mains AC voltages can and will kill your or burn down your house given the chance.

We want information… information… information........................no information no helpThe use of crystal balls & mind reading are not supported

....I do realise the danger involved even though I have no "official" training on electrical wiring...but I am a very experienced physics teacher (& therefore a degree in physics too) & very much understand what not to do.

I have been trying to research this problem for 2 days & I am 100% confident I have it wired correctly - I must assume from what you say that I have a short on the board...irritating.

....I do realise the danger involved even though I have no "official" training on electrical wiring...but I am a very experienced physics teacher (& therefore a degree in physics too) & very much understand what not to do.

I have been trying to research this problem for 2 days & I am 100% confident I have it wired correctly - I must assume from what you say that I have a short on the board...irritating.

Regards,
Dan.

What country are you in? (You can add location to your profile)
Is there a common ground connection between RPi and relay board and all DC power supplies?

I am not sure the following will help but somethings to check:

Are all DC power supplies connected with 3 prong grounded plugs?
Are all the load devices and RPi power supplies on the same AC circuit?
Are you sure you are switching the line and not the neutral? To be sure you would need to test the AC outlet to be sure it's wired correctly.

Also, how did you connect the mcp23017 and the relay board to each other. And how did you configure the relay board.
Because, the Rpi is operates at 3.3V and your relay board is 5v. What could mean that your are not able to enable the relay.

And did you measure the voltage between the gnd - inx when the power supply for the relay was still present? If this is the case, depending on the jumper selection. You could simply measure the vcc minus the forward voltage of the led plus the forward voltage of the led inside the optocoupler. And this is nothing to worry about.

Hopefully you can see the attached picture - when there is NOTHING else connected to the relay other than the 240V line out (UK mains)..on ANY of the channels, there is a voltage between GND-In(all) of line in ...when taking this picture it was 1.25V.

If you really need to switch mains voltages then I suggest you look at octal relays, they mount on individual bases with screw terminals.

I would look to use ones with 12v DC coils, then use a separate 12v PSU to power them and a uln2803A to interface the pi gpio to the 12v switching the ground side of the coil.
The uln2803A has built-in back emf diodes to protect the electronics from the back emf generated by the relay coil.

The uln2803A is also designed to be driven directly by the 3.3v of the pi gpio.

If you need a diagram for connecting up I can draw one up for you.

We want information… information… information........................no information no helpThe use of crystal balls & mind reading are not supported

But ... can you measure any resistance between any of the output connections and any of the inputs?
There should be infinite resistance. Anything less is a fault.

Tried to find a short this way, not found anything that links the 2 sides.

Regards,
Dan.

To do insulation testing you really need a proper insulation tester that generates mains voltages but a very very low current, and ordenary digital meter will only be using low voltage < 12v DC so won't cause any bad insulation to break down.

We want information… information… information........................no information no helpThe use of crystal balls & mind reading are not supported

If you really need to switch mains voltages then I suggest you look at octal relays, they mount on individual bases with screw terminals.

I would look to use ones with 12v DC coils, then use a separate 12v PSU to power them and a uln2803A to interface the pi gpio to the 12v switching the ground side of the coil.
The uln2803A has built-in back emf diodes to protect the electronics from the back emf generated by the relay coil.

The uln2803A is also designed to be driven directly by the 3.3v of the pi gpio.

If you need a diagram for connecting up I can draw one up for you.

I actually want to drive the relays for these from i2c using MCP23017 (nearly all the GPIO will be tied up already), but I assume the rest of what you describe will be the same.

I would really appreciate a diagram for this - although my training is in physics, I've never been taught any electronics & I've always gone along the lines of ...well this works so far, so that's the route I'll follow ...so if someone who knows what they're talking about suggests a better route, I'll gladly follow

Fair enough about binning the board - what would you suggest in its place? For my project I need to be able to turn on/off mains operated smoke machine, fan & lights.

I also won't use that kind of relay board to switch the mains on and off. Because, the layout ect will probebly not be 100% ok and the relay are also questionable. And depending on what you need to switch, the relay his contact need to be suitable for that. So, not all relay can switch the same. Some are special design to switch motors and others are designed to switch lights.

I think I have a problem with voltage noise passing between supposedly isolated parts of a relay & don't know how to get rid of it.

I have recently bought a standard 5V relay module board (8-channel)* and can control it without issue using an mcp23017 connected to the pi (3).
However, when I connect the output of the relay to a mains connected appliance (light bulb for example) the relay no longer works.

I have determined that whenever the mains AC line is connected to the output, there is approximately 2V across the GND-In(any) of the relay inputs - this is present even if there are no other connections to the relay board.
Therefore the voltage signal coming from the controller can never drop the signal to 0V and the relay doesn't fire.

I also have a variable power supply up to 15V & that also causes noise on the input but only up to about 100mV & the relay will still energise.

Can anyone suggest a solution to this?
I want to be able to power several mains operated components (a smoke machine, fan & lights) for my current project.

Were the input points where you're measuring the voltage high impedance? If so, it takes very little coupling to get some sort of reading. Try measuring the voltage with a resistor connected first to VCC, then to GND. Value will depend on the exact drive circuit.
Any idea what the circuit driving the relays is? Those 4-pin ICs are often optocouplers, and I have had odd readings across them in some situations.
As far as driving your bits and pieces from those relays is concerned, if they are reasonably low current the actual relay contacts should do. However you've also got the very important issue of maintaining high voltage isolation between mains and low voltage sides; this is firstly down to the spec on the relays themselves, then to how the PCB is laid out, and how you mount it in an enclosure. The spec on the relay itself looks reasonable.

Well, it depents on how you look at it. If you use a resistive load it can switch 10A @240VAC. However, the load that the op want to switch are not resistive load. And if you take a look how much the can switch a inductive load at 230VAC. Well, that is not specified! And the maximum power that they can switch is only 240-300W (depending on the type) and that is only 1A. And not the 10A that is written on the relay itself.

srd-05vdc-slc.PNG (159.93 KiB) Viewed 1255 times

.
As a comparison the relay that I wrote earlier about. Depanding on what type of lamp your are using, you can connect a higher power or less power to the relay itself. So the relay is rated at "20A" but it can only switch 200W LED. Thats why it is very imported to chose the right relay for the task you want!:

What is happening is that you are getting coupling from the mains back to the input from within the relay, and this is largely the result of the high voltage AC connection. Bear in mind that the input impedance on your multimeter is very high, and that any coupling will show up because there is no loading on the pin. Some of this coupling may also be due to the board layout. You probably wouldn't have this problem if you were switching a lower voltage AC line or DC.

The addition of minor loading on the pin you're measuring should knock the 1.25v down considerably. Experiment with a resistor (say >4.7k or so) between the relay board input signal pin and ground while you have your multimeter connected and see what happens. Connect the resistor as close to the board input pins as you can.

Also consider buffering the MCP23017 output pins with a transistor follower (such as an NPN 2N2222 or 2N3904), and have the transistor do the switching rather than the chip. This is what I would do. The logic will probably have to be inverted if this is done. The transistor will probably switch the inputs harder than the IC will, and will also give you flexibility to tweak the circuit that drives the input to the board to give you reliable operation.

The MCP23017 data sheet indicates that the current sink/sourcing capability of the output pins is pretty good (25ma), and is more than adequate to drive the LED within the optocoupler and activate the relay. This output also appears strong enough to still drive the opto adequately with a resistor across the input at the board, so long as that resistance value isn't too small.

Another option, although it may seem redundant, would be to have the relays on the board do the switching for another bank of much heavier relays that actually do the mains switching/heavy lifting. Doing so would protect your relay board at the least, and provide a much more difficult path for inductive coupling to take place. If the magic smoke escapes for some reason, you probably will only have to replace a 'secondary' relay rather than the whole 8 channel board.

I used the same relay board in an alarm system interface. I'm switching 12v and lower circuits but as far as driving all 8 of the relays directly from the pi goes I opted to use a separate power supply and 2n3904's to activate the relay coils.

Although I used the primary pins on the pi to drive the transistors I could just as well used the mcp23017 pins to drive the transistors. Regardless of how you set things up, I think having a separate power supply drive the board is essential due to the current draw of the Songle Relays. I did not consider this board mains worthy from things I read about it on the eev blog forum.

Any sort of mains application for me will be as described in the post above where I will use a mains rated relay driven by the songle relays on the sainsmart board which appears to be the same as yours.

Here is how I wired things to the relay board. It runs cool even with all 8 relays on full time.

Diagram showing how to connect ULN2803A to gpio and relays be it octal or anther type of relay with a 12v DC coil.

Only shown 3 relays but you can drive 8 from the chip ,integral clamp diodes for switching inductive loads, so no need for them to be added externally, ULN2803A can be driven from 3.3v of pi gpio or up to voltage on common pin so driving it from your mcp23017 should be fine.

We want information… information… information........................no information no helpThe use of crystal balls & mind reading are not supported

I've bought some ULN2803A chips - just need to decide on what relays to get now.

Why do you suggest the "octal" ones?...seems like a much reduced/limited choice

...would appreciate suggestions from anyone as to what specific relays to actually use - there seems to be a huge choice & I'm not sure why to choose one over another.
=> want to be able to control a 400W smoke machine (so assume ~2A), light bulb & extractor fan (~20W)...all on separate switches.

Why do you suggest the "octal" ones?...seems like a much reduced/limited choice

He used one of the relay of his drawing package as a example.

Wizards Hat wrote:
...would appreciate suggestions from anyone as to what specific relays to actually use - there seems to be a huge choice & I'm not sure why to choose one over another.
=> want to be able to control a 400W smoke machine (so assume ~2A), light bulb & extractor fan (~20W)...all on separate switches.

Did you read my posts about the relay. I suggested one for the light bulb in a previous post And why it is important to choose the right one.

Wizards Hat wrote:
...would appreciate suggestions from anyone as to what specific relays to actually use - there seems to be a huge choice & I'm not sure why to choose one over another.
=> want to be able to control a 400W smoke machine (so assume ~2A), light bulb & extractor fan (~20W)...all on separate switches.

Did you read my posts about the relay. I suggested one for the light bulb in a previous post And why it is important to choose the right one.

Yeah, I read your post & that's why I need more help/suggestions
- if the one you suggested is ok for a light bulb, but not ok for a 400W smoke machine & I look on the Farnell website you linked to & go up one level & filter to 12Vdc coil, there are nearly 1000 relays listed but no filter for power, only filters for current.

How do I find what I need without having to read 1000 datasheets (even then, I'm not sure what I'm trying to find in them...it's unlikely to list "smoke machine" in there )

Personally, I would not add the relay contacts parallel to each other. Because there is always one contact that make contact first before the other ones. This means that the unlucky contact will carry all the current first. Before sharing it with the others. Then you can better use the version with less contacts: https://uk.farnell.com/finder/55-32-9-0 ... dp/2787151