Arduino resets from relay, some sort of interference?

Hello, I need some help.
I’m currently working on a wireless lamp controlling project.

In my electric switchboard I have some latching relays which I would like to control wirelessly (type: Hager EPN524). They turn on or off with short signal of 24 VAC.

I don’t have so much experience with arduino and electronics but I used what I had available and this is what I came up with:

  • I have a Raspberry PI as a server running openhab and mosquitto.
  • I have an arduino uno with a W5100 ethernet shield which is connected to a sainsamart relay board. The uno is using mosquitto to receive the commands from the server (rasp PI). The uno will then turn on and then off on of the relays which will trigger the other relay in my switchboard.

I have 24VAC connected to the relays output which then goes to the other relays in my switchboard. I got everything working as I want but now to the problem. The problem is that sometimes when I turn on the relay with my phone my arduino will stop working, I think it resets because if I wait 20-30 seconds it will start to work again.

I searched about the problem and people said something about some sort of interference and using a RC snubber could solve this. I don’t know what kind of values the snubber should have or is a snubber the solution for my problem?

I would greatly appreciate if someone could help me out.

Don't forget that relays contain coils, and when you suddenly shut off a coil, it generates a big back emf (voltage). Have you put bypass diodes across your relay coils?

This one?
You're using an industrial style relay with a nominal 25VA AC consumption and driving directly with an Arduino output(40mA)?

I don't like the idea of driving relays directly with Arduino output pins as they are an inductive load. You can often get around problems by having the Arduino drive a a mosfet switch which then controls your relay.

Arduino can not drive many relay coils directly, takes too much current and blows the IO pin.
Better to use a transistor to sink the coil current.
Here's an example with NPN, N-channel MOSFET will work also, as suggested, with the relay controlling a motor on/off.

What is the model number of the Sainsmart board.
Some have problems.

How are you supplying the Arduino.

How are you supplying the relay board.

How did you connect the Arduino to the relay board.
+5volt and relay inputs only, or also shared grounds.
Leo..

Thanks for the replies!

jrdoner:
Don't forget that relays contain coils, and when you suddenly shut off a coil, it generates a big back emf (voltage). Have you put bypass diodes across your relay coils?

There is a bypass diode across the coils on the sainsmart relay board.

ApexM0Eng:
This one?
You're using an industrial style relay with a nominal 25VA AC consumption and driving directly with an Arduino output(40mA)?

I don't like the idea of driving relays directly with Arduino output pins as they are an inductive load. You can often get around problems by having the Arduino drive a a mosfet switch which then controls your relay.

I have a Hager ST313 powering the 24VAC relays. See the link below how i have got it wired.
Imgur

CrossRoads:
Arduino can not drive many relay coils directly, takes too much current and blows the IO pin.
Better to use a transistor to sink the coil current.
Here's an example with NPN, N-channel MOSFET will work also, as suggested, with the relay controlling a motor on/off.

This is how i got currently wired Imgur: The magic of the Internet.

Wawa:
What is the model number of the Sainsmart board.
Some have problems.

How are you supplying the Arduino.

How are you supplying the relay board.

How did you connect the Arduino to the relay board.
+5volt and relay inputs only, or also shared grounds.
Leo..

My sainsmart board:SainSmart 4-Channel 5V Relay Module for Arduino Raspberry Pi – SainSmart.com

I have tried both with 12 VDC supply and also with only 5VDC. I have also tried to use a external supply for the 5v relay board for powering the coils but still got resets.

When i used a external power supply i used shared grounds.


This the 230vac to 24vac transformer i have in my switchboard: http://www.hager.de/produktkatalog-neuheiten/energieverteilung-und-zaehlerplatzsysteme/schalt-und-meldegeraete/trafos-und-steckdosen/st313/24499.htm

I have also tried to wire 230VAC directly to the sainsmart board where the 24VAC is connected in the picture and it worked, no resets. The load here was a 60W lamp.

The problem started when i connected the 24VAC relay to the 5v relay output. I don't have 230VAC connected to the 24VAC relay at the moment.

HelmerX:
I have also tried to use a external supply for the 5v relay board for powering the coils but still got resets.

Did you remove the VCC jumper, and connect 5volt relay power to VCC-relay and relay-ground.

And did you REMOVE the ground to the Arduino.
Leo..

Wawa:
Did you remove the VCC jumper, and connect 5volt relay power to VCC-relay and relay-ground.

And did you REMOVE the ground to the Arduino.
Leo..

When I used external supply I removed the jumper and connected external to jd-vcc and board ground. From arduino I only connect 5v and no ground but still got resets.

I read then that you should have a common ground so I have tried that alternative as well but still get resets.

The common Gnd applies to all modules that connect signal lines to the Arduino board. When the relay inputs are opto-isolated (as with your card) the relay power connectors should be attached only to the relay power supply.

External devices, which are controlled by the relay board, should only be connected to the relay contacts.

Relay contacts switching inductive loads (motors, relays...) should be protected against reverse currents. For DC loads typically diodes (in reverse polarity) are connected to the contacts, for AC loads a resistor-capacitor or VDR solution is recommended.

HelmerX:
When I used external supply I removed the jumper and connected external to jd-vcc and board ground. From arduino I only connect 5v and no ground but still got resets.

I read then that you should have a common ground so I have tried that alternative as well but still get resets.

So when the Arduino is ONLY connected to +5 relay and a relay in pin, you still have resets.
So this is happening with FULL opto isolation.
Are you sure the Arduino supply is good?
Maybe you could try an electrolytic cap (100-1000uF) from Vin to ground (DC jack supply!).

What else is connected to the Arduino. Grounded sensors?
Leo..

Wawa:
So when the Arduino is ONLY connected to +5 relay and a relay in pin, you still have resets.
So this is happening with FULL opto isolation.
Are you sure the Arduino supply is good?
Maybe you could try an electrolytic cap (100-1000uF) from Vin to ground (DC jack supply!).

What else is connected to the Arduino. Grounded sensors?
Leo..

I feel stupid...

I should have tried to use another power supply for the arduino. I tested with another 12v supply and bam no resets. I guess the problem was that when my other supply's dc signal was too noisy and if i would have put a cap over vin to gnd it would prob worked too. But i'm going to use my other supply.

Thanks everyone for helping out!