SANGER_A2
Posts: 59
Joined: Sun Mar 04, 2012 7:39 pm
Contact: Website

HELP! 5V Relays work with 12v, but not 240v

Wed Aug 09, 2017 7:55 pm

For over a year now, I have been using one of these with my Pi (2B and now 3) to switch a 12 volt supply on and off to control some fans in a server cabinet I made when none of my Network Attached Storage devices are on. It worked perfectly, so I thought I'd set up a similar one to switch the actual power on and off to the source of power for the NAS's (in total they draw less than 100W). I setup my circuit as attached and used this (I tried both high and low mode) and then this relay. Both worked a few times and turned the plug on and off a few times and then stopped working and the power was always on. The relay would click, but wouldn't turn the power off. What am I doing wrong? I even tried it using the second unused relay that was controlling my fans and that did the same thing. I've seen people use these things to control their heating so I don't see how it can be the power draw!

I can't see how it can be a software issue as it has worked fine with the 12v switching and also worked a few times with the 240v before stopping but I'll post a sample of the code I've tried:-

Code: Select all

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
#should be off now
GPIO.output(17, True)
raw_input()
GPIO.output(17, False)
#should be on now
And also switching between in and out mode:-

Code: Select all

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN)
#should be off now
raw_input()
GPIO.setup(17, GPIO.OUT)
#should be on now
I'm currently using one of these to control 240v in another room using a BBC micro:bit with exactly the same wiring on the mains side and that works fine. I'm considering buying another one, but I heard that the 3v source on the Pi can't provide enough to power a relay. As a last resort, I can control a micro:bit via serial to control one of those relays, but I'd rather use the GPIO as I'm already using it very successfully to switch 12v!

Any help would be very gratefully received. I've spent hours trying to get this working as I over-engineer everything when mains power is concerned and spend a lot of time checking and double-checking and enclosing everything in enclosures. Please don't reply just to tell me I'm being dangerous/could fry my Pi etc. I've been doing all sorts with electronics for years and everything is insulated very safely and the whole setup is connected via an RCD plug anyway. The relays all have opto-couplers - so there's no reason any voltage should get back into the Pi (and if it was going to happen it would have done by now anyway).

P.S. Sorry about the terrible quality of the diagram! :)
Attachments
asdf.png
asdf.png (21.3 KiB) Viewed 4816 times

pcmanbob
Posts: 10727
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: HELP! 5V Relays work with 12v, but not 240v

Wed Aug 09, 2017 9:26 pm

Hi.

2 possible causes of your problem.

1. relay contacts have welded shut due to load on them, to check this just disconnect the pi from the relay board completely and then turn the mains on if nas powers up then relay contact is welded shut.

2 . relay board requires 5v in put to control relay were as the pi gpio is only 3.3v a common problem with these cheap relay boards, to get round this you can use a simple transistor circuit or another opto-isolator to interface the pi to the relay board.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Moe
Posts: 230
Joined: Sun Jan 25, 2015 2:44 pm

Re: HELP! 5V Relays work with 12v, but not 240v

Wed Aug 09, 2017 10:04 pm

The relays are welding shut. The problem is not steady-state load but the surge current at start up. The capacitors in the PSU in the NAS will present a very low impedance load to the supply when uncharged, and will take many times the rated steady state current. 60 or 70A is normal, for a very brief period (i.e a few millseconds). This won't blow time-delay fuses or trip MCBs, but could easily melt the contacts of a relay rated at 10A.

You need to limit the surge current. You could put a high-power resistor in-line, but this would be dissipating power the whole time. A better, but more complex solution would be to use two relays, one feeding the NAS through a resistor and the other direct. Switch the loaded supply first to charge the capacitors, then the second one a second later to bypass the resistor.
Submarine communication systems engineer and amateur robot enthusiast.

pcmanbob
Posts: 10727
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: HELP! 5V Relays work with 12v, but not 240v

Wed Aug 09, 2017 10:27 pm

If the relay contacts are welding shut as we both seem to suspect the simple answer is to use a properly rated relay with mains rated contacts, octal relays are commonly used in industry for switch 240V AC and should be capable of handling even the start current for a nas psu.

Better still why not just use one of the modern solid state relays no moving contacts to weld shut.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

SANGER_A2
Posts: 59
Joined: Sun Mar 04, 2012 7:39 pm
Contact: Website

Re: HELP! 5V Relays work with 12v, but not 240v

Wed Aug 09, 2017 10:35 pm

Moe wrote:
Wed Aug 09, 2017 10:04 pm
The relays are welding shut. The problem is not steady-state load but the surge current at start up. The capacitors in the PSU in the NAS will present a very low impedance load to the supply when uncharged, and will take many times the rated steady state current. 60 or 70A is normal, for a very brief period (i.e a few millseconds). This won't blow time-delay fuses or trip MCBs, but could easily melt the contacts of a relay rated at 10A.

You need to limit the surge current. You could put a high-power resistor in-line, but this would be dissipating power the whole time. A better, but more complex solution would be to use two relays, one feeding the NAS through a resistor and the other direct. Switch the loaded supply first to charge the capacitors, then the second one a second later to bypass the resistor.
Thanks for your replies guys. That sucks. The micro:bit one is powering a media PC with an i5 and a 32" TV so I'm surprised that hasn't gone too! I'd rather not have to create an advanced circuit that uses a timer to switch from one relay to another, also, when it's given power, one of the NAS's turns on immediately and I don't want to risk it coming on for a second and losing it's power in the middle of writing to the HDD!

Here is a crazy idea: could I use the small raspberry Pi relay to trigger a 12v supply to a more beefy relay that will turn on the power to the NAS's like this one?

I'd like to do it myself as cheaply as possible, but if this can't be done, I'll just buy an RF plug and do something like this as a last resort, but it won't be anywhere near as satisfying as solving this problem! I even 3D-printed a case for the relay to sit in when I was at work! :)
Last edited by SANGER_A2 on Wed Aug 09, 2017 11:16 pm, edited 1 time in total.

SANGER_A2
Posts: 59
Joined: Sun Mar 04, 2012 7:39 pm
Contact: Website

Re: HELP! 5V Relays work with 12v, but not 240v

Wed Aug 09, 2017 10:44 pm

pcmanbob wrote:
Wed Aug 09, 2017 10:27 pm
If the relay contacts are welding shut as we both seem to suspect the simple answer is to use a properly rated relay with mains rated contacts, octal relays are commonly used in industry for switch 240V AC and should be capable of handling even the start current for a nas psu.

Better still why not just use one of the modern solid state relays no moving contacts to weld shut.
I considered SSRs after reading about the welding! :) But when I had a quick look on Ebay, they were either expensive or only 2A. Would 2A be enough? Plugging 100W at 240V into an ohms law calculator only gave me 0.2A and 2A at 240V 480W so it should be okay right?

So could I used my idea from above and trigger a 5V supply to one of these to power the NAS's?

Thanks for your help.

pcmanbob
Posts: 10727
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: HELP! 5V Relays work with 12v, but not 240v

Wed Aug 09, 2017 10:57 pm

The first thing to do is prove the contacts are welded shut.

Do as I said in my post or disconnect the relay completely and use a meter to see if the contact is welded shut.

then you can consider your solution once you are sure of the problem.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

SANGER_A2
Posts: 59
Joined: Sun Mar 04, 2012 7:39 pm
Contact: Website

Re: HELP! 5V Relays work with 12v, but not 240v

Wed Aug 09, 2017 11:00 pm

pcmanbob wrote:
Wed Aug 09, 2017 10:57 pm
The first thing to do is prove the contacts are welded shut.

Do as I said in my post or disconnect the relay completely and use a meter to see if the contact is welded shut.

then you can consider your solution once you are sure of the problem.
Sorry, I was just coming back to confirm that I've disconnected the relay from the Pi and the contacts are welded shut as the NAS's have power going to them. It took a while to do. I've managed to convert three relays into an over-priced way of joining up two wires! :(

I can grab my multimeter out of the garage and check tomorrow if you think that's necessary.

pcmanbob
Posts: 10727
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: HELP! 5V Relays work with 12v, but not 240v

Wed Aug 09, 2017 11:07 pm

SANGER_A2 wrote:
Wed Aug 09, 2017 11:00 pm
pcmanbob wrote:
Wed Aug 09, 2017 10:57 pm
The first thing to do is prove the contacts are welded shut.

Do as I said in my post or disconnect the relay completely and use a meter to see if the contact is welded shut.

then you can consider your solution once you are sure of the problem.
Sorry, I was just coming back to confirm that I've disconnected the relay from the Pi and the contacts are welded shut as the NAS's have power going to them. It took a while to do. I've managed to convert three relays into an over-priced way of joining up two wires! :(

I can grab my multimeter out of the garage and check tomorrow if you think that's necessary.
OK so you have proved the contact is welded shut then if the NAS's are still powered with the pi dis-connected. no need to test with a meter.

one thing I did notice you said NAS's more than one ? so you have more than one power supply on this one contact. so you need to consider the total load, that's going to be more than the 100w you mentioned.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

SANGER_A2
Posts: 59
Joined: Sun Mar 04, 2012 7:39 pm
Contact: Website

Re: HELP! 5V Relays work with 12v, but not 240v

Wed Aug 09, 2017 11:15 pm

pcmanbob wrote:
Wed Aug 09, 2017 11:07 pm
OK so you have proved the contact is welded shut then if the NAS's are still powered with the pi dis-connected. no need to test with a meter.

one thing I did notice you said NAS's more than one ? so you have more than one power supply on this one contact. so you need to consider the total load, that's going to be more than the 100w you mentioned.
The 100W is total, well 105W. There are three NAS's. They draw 48W, 27W and 24W max according to the specs. Plus a 12v plug powering 8 fans at about 6w total. They aren't especially powerful devices. Two of them just use laptop-style power bricks and the other just uses a plug in 12v adapter. Only one NAS (the lowest power with just 1 HDD) comes on when the power is turned on, the others don't turn on until I send them a WOL signal.

Moe
Posts: 230
Joined: Sun Jan 25, 2015 2:44 pm

Re: HELP! 5V Relays work with 12v, but not 240v

Thu Aug 10, 2017 12:00 am

Here is a crazy idea: could I use the small raspberry Pi relay to trigger a 12v supply to a more beefy relay that will turn on the power to the NAS's like this one?
Absolutely. I use a one of these 5V relay modules to trigger a 60A automotive relay to provide 24V supply to the motors on my robot. Automotive relays aren't rated for mains voltage but I don't really see why they woudn't work (they probably just fail the tests for insulation resistance).
Submarine communication systems engineer and amateur robot enthusiast.

pcmanbob
Posts: 10727
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: HELP! 5V Relays work with 12v, but not 240v

Thu Aug 10, 2017 12:03 am

So its the start up current that's destroying your relays, the load is not purely resistive, but a mixture of capacitive, inductive reactance and resistance.

I am not sure your suggested SSR would be suitable with a rating of only 2A.

I would look at some thing like this http://www.ebay.co.uk/itm/Solid-State-R ... SwzaJX4aDI
with this you could also possibly control it direct from the gpio as its 3-32v dc input for control. you can get them cheaper from china same make and all, http://www.ebay.co.uk/itm/25A-40A-100A- ... 0005.m1851 but its up to you were you buy from..
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

pcmanbob
Posts: 10727
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: HELP! 5V Relays work with 12v, but not 240v

Thu Aug 10, 2017 12:09 am

Moe wrote:
Thu Aug 10, 2017 12:00 am
Here is a crazy idea: could I use the small raspberry Pi relay to trigger a 12v supply to a more beefy relay that will turn on the power to the NAS's like this one?
Absolutely. I use a one of these 5V relay modules to trigger a 60A automotive relay to provide 24V supply to the motors on my robot. Automotive relays aren't rated for mains voltage but I don't really see why they woudn't work (they probably just fail the tests for insulation resistance).
You should never use an automotive relay to switch mains they are not designed or rated to switch mains.
We are talking about switch 240V AC SAFETY FIRST 240V AC KILLS.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
rpdom
Posts: 18162
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: HELP! 5V Relays work with 12v, but not 240v

Thu Aug 10, 2017 5:20 am

pcmanbob wrote:
Thu Aug 10, 2017 12:09 am
Moe wrote:
Thu Aug 10, 2017 12:00 am
Here is a crazy idea: could I use the small raspberry Pi relay to trigger a 12v supply to a more beefy relay that will turn on the power to the NAS's like this one?
Absolutely. I use a one of these 5V relay modules to trigger a 60A automotive relay to provide 24V supply to the motors on my robot. Automotive relays aren't rated for mains voltage but I don't really see why they woudn't work (they probably just fail the tests for insulation resistance).
You should never use an automotive relay to switch mains they are not designed or rated to switch mains.
We are talking about switch 240V AC SAFETY FIRST 240V AC KILLS.
I think that was just supposed to be an example of using a low voltage relay to switch a higher rated one. In this case a 24V (not 240V) high current relay. No one was suggesting using a 24V relay f=to switch mains voltage.

SANGER_A2
Posts: 59
Joined: Sun Mar 04, 2012 7:39 pm
Contact: Website

Re: HELP! 5V Relays work with 12v, but not 240v

Thu Aug 10, 2017 7:38 am

pcmanbob wrote:
Thu Aug 10, 2017 12:03 am
So its the start up current that's destroying your relays, the load is not purely resistive, but a mixture of capacitive, inductive reactance and resistance.

I am not sure your suggested SSR would be suitable with a rating of only 2A.

I would look at some thing like this http://www.ebay.co.uk/itm/Solid-State-R ... SwzaJX4aDI
with this you could also possibly control it direct from the gpio as its 3-32v dc input for control. you can get them cheaper from china same make and all, http://www.ebay.co.uk/itm/25A-40A-100A- ... 0005.m1851 but its up to you were you buy from..
Brilliant. Thanks very much. I would buy the cheaper China one! Would the 25A one be okay? In fact, I found it even cheaper on aliexpress! I've already got loads of heatsinks I can attach so this would be a nice cheap solution. I think I'll use a 5v charger to power it triggered by a relay rather than connect directly to the GPIO to be safe.

Sound good?

pcmanbob
Posts: 10727
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: HELP! 5V Relays work with 12v, but not 240v

Thu Aug 10, 2017 12:20 pm

rpdom wrote:
Thu Aug 10, 2017 5:20 am
pcmanbob wrote:
Thu Aug 10, 2017 12:09 am
Moe wrote:
Thu Aug 10, 2017 12:00 am


Absolutely. I use a one of these 5V relay modules to trigger a 60A automotive relay to provide 24V supply to the motors on my robot. Automotive relays aren't rated for mains voltage but I don't really see why they woudn't work (they probably just fail the tests for insulation resistance).
You should never use an automotive relay to switch mains they are not designed or rated to switch mains.
We are talking about switch 240V AC SAFETY FIRST 240V AC KILLS.
I think that was just supposed to be an example of using a low voltage relay to switch a higher rated one. In this case a 24V (not 240V) high current relay. No one was suggesting using a 24V relay f=to switch mains voltage.
I took this as a suggestion that they might work but I don't really see why they woudn't work (they probably just fail the tests for insulation resistance)

just wanted to stop the suggestion before it took hold.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

pcmanbob
Posts: 10727
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: HELP! 5V Relays work with 12v, but not 240v

Thu Aug 10, 2017 12:30 pm

SANGER_A2 wrote:
Thu Aug 10, 2017 7:38 am

Brilliant. Thanks very much. I would buy the cheaper China one! Would the 25A one be okay? In fact, I found it even cheaper on aliexpress! I've already got loads of heatsinks I can attach so this would be a nice cheap solution. I think I'll use a 5v charger to power it triggered by a relay rather than connect directly to the GPIO to be safe.

Sound good?
You may find you don't need a heat sink as you said standing load is only 105w about 0.5A suggested 25A one so that it will be way over rated to handle the inrush current for the few milliseconds at start up. for the price better over rated than under rated as you have already discovered.

triggering it via a relay will work , you could also use an opto-isolater and your 5v supply to trigger it using the gpio no moving parts at all then.
Attachments
i0 ssr.jpg
i0 ssr.jpg (12.41 KiB) Viewed 4593 times
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

SANGER_A2
Posts: 59
Joined: Sun Mar 04, 2012 7:39 pm
Contact: Website

Re: HELP! 5V Relays work with 12v, but not 240v

Thu Aug 10, 2017 1:42 pm

pcmanbob wrote:
Thu Aug 10, 2017 12:30 pm
You may find you don't need a heat sink as you said standing load is only 105w about 0.5A suggested 25A one so that it will be way over rated to handle the inrush current for the few milliseconds at start up. for the price better over rated than under rated as you have already discovered.

triggering it via a relay will work , you could also use an opto-isolater and your 5v supply to trigger it using the gpio no moving parts at all then.
Cheers. I won't bother with a separate opto isolator as I already ordered another 2 channel relay to replace my original relay, so I'll use one channel for the fans and 1 triggering the 5v supply to the ssr. I'd like to stick with technology I know! :-)

User avatar
scruss
Posts: 3854
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: HELP! 5V Relays work with 12v, but not 240v

Thu Aug 10, 2017 3:04 pm

These are unfortunately only available as kits for 240 V, but PowerSwitch Tails are solid. I've had 'em switch kettles without complaint. Dunno if there's a UK importer, as the manufacturer is a small company based in Hawaiʻi.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

SANGER_A2
Posts: 59
Joined: Sun Mar 04, 2012 7:39 pm
Contact: Website

Re: HELP! 5V Relays work with 12v, but not 240v

Sun Aug 27, 2017 10:35 pm

Thanks for all your help guys. I used the GPIO to switch a 5v relay, that enabled a 5v supply to the 25A SSR and that is working brilliantly to switch on and off my NAS's. The great thing is, because I'm running fauxmo, I can use Alexa to do it or a button I connect to the Pi's GPIO or an app to run SSH commands on my phone or PC! :)

Return to “Automation, sensing and robotics”