Mkr Zero + relays

First time on this Forum,

Tried to search for different solutions, but found none.

So I tried to hook up my Arduino mkr Zero to a relays board.

Project is gonna be a vivarium automation.

The relays board switches 2 HID ballasts, 1 normal lamp and 1 pump.

Lamp is working fine.
Pump also.

With the HID BALLASTS it spasm out randomly (still powered, but not working anymore)

Power supply is not the problem. (Tried it also with powering the Arduino with a lithium battery, same result.)

Otherwise relays is powered via jd-vcc pin.
PSU's are two meanwell 5W

Is there any way to really isolate the relay from the Arduino?

Unfortunately I do not have an oscilloscope for precise measurements.

And why would the HID ballasts cause such mayhem?

Thanks in advance,
Johannes

It's not uncommon for relays to cause problems for an Arduino if they're not properly isolated from it. Similarly, anything that pulls a lot of current (like your HID devices I suspect) can cause brownouts and subsequent resets.

Please provide more detail of the components you're using (including power supplies) and how they are wired up.

Hi thanks for the reply,
the ballasts are connected to mains via relay,
The Arduino is powered by an meanwell RS 25-5 (5V 5A Switching psu),
The relays are powered by a separate RS25-5,
It's all plugged in to a single outlet (16A breaker)

(Also tried different outlets, same result)

Powerdraw from ballasts is 0.2 Amps each. On power on its almost Double (source is osram website)

On power up no more than 2 amps should be drawn from mains.

Relays are connected to the Arduino with gnd, vcc and digital pins.

There is also an oled and rtc connected via i2c.

Relays should do 10A 230v.
Is it possible, that somehow the relay "backfires" into the Arduino?

Are these relays standalone? Optoisolated? A circuit diagram would be helpful. Basically though, it sounds like something is noisy or pulling enough current to reset the Arduino.

A diagram and picture, according to the posting guidelines, could avoid more questions.

Do not connect relay ground to Arduino ground. That defeats opto isolation.
The JD-VCC jumper must also be removed.
I assume you have kept mains wiring away from Arduino<>relay wiring.

Complex loads, like a pump and HID ballast must have a snubber circuit across the relay contacts.
Leo..

Thanks for all the replies,
I will do the diagram tomorrow.
(I just tried disconnecting gnd, that is the same result.)

Must do both.
No ground between the relay module and Arduino and snubber circuits across the contacts.
Leo..

Sorry for the delay, here it is. It's the problematic circuit only (just one relay with ballast)
The ballast has an inrush current of 30A (operational in between 0.2 and 0.4 A)
Osram has no data on internal resistance, capacitance or inductance)

The dotted lines are the proposed snubber.
Osram technical service proposed to use a Electronic ballast rated relay, to keep up with the inrush current, but I guess that won't solve the EMI problem. (I guess)

Next thing I will try is to switch the relay with a switch connected to the Arduino only and no i2c devices. The program relies on a working rtc (as it switches the loads depending on the time from the rtc)
Maybe haywire i2c rtc is the reason for it bugging out?

The relay: 8-Relais Modul 5V mit Optokoppler Low-Level-Trigger kompatibel mit Ard – AZ-Delivery

Psus: Mean Well RS-25-5

Oled: 0,96 Zoll OLED Display I2C SSD1306 Chip 128 x 64 Pixel I2C Bildschirm – AZ-Delivery

Sensor:

Rtc: Real Time Clock RTC DS3231 I2C Echtzeituhr kompatibel mit Arduino und – AZ-Delivery (with lithium rechargable battery)

Some tips here for reducing EMI.
Installing ferrite core(s) can be quite effective. One on the AC Line to the relay (try at least 4-turns through the hole) and could add a snap-on core to the power entry to the Arduino supply.

Thank you all!
I think it might be a bit... sketchy, but:

The way to success was to eliminate the Clock... unfortunately.

First I tried it with a simple switch, which worked, that led me to believe, that something is wrong with the bus itself.

Then I just used the external RTC to setHours() etc. to the internal RTC of the SAMD21. That worked as well.

Is there a simple way to restart the I2C connection? (Like checking if something is there and then beginning anew?

I will nevertheless get some Ballast rated Relays (there are some available at my local electronics dealer which are rated 800W for traditional ballasts) as I wont want my flat to burn out. Also Iam going to shield the I2C as good as possible.
I do want it to work not only get "patched".

The RC Snubber - I Am confident in handling simple AC wirework, but if its not necessary with a rated Relay, I wont go there, if you say it is necessary, ill talk to an electrician for that

I suspect that the RTC issue is a symptom, not the cause. The obvious culprit is the relay and I note that your circuit diagram indicates that you do have a shared ground. I'd put the clock back and run your code with the relay disconnected as a test.

The standalone circuit works just fine.

I don't really understand where they share ground.
The only wires from Arduino to relay are vcc and the data line.

Or does the mains side of things also count as shared?

johetan90:
Or does the mains side of things also count as shared?

I suspect so, although I don't see what you can do about it. Hopefully one of the electronics gurus will know.

Wawa:
Must do both.
No ground between the relay module and Arduino and snubber circuits across the contacts.
Leo..

Circuit was working fine, but then I thought, lets give it a shot.
Plugged in a Hairdryer in one of the Relay connected sockets.

That has the Arduino going loco again.

Okay, I'll go for the RC Snubber, get some bypassing and decoupling capacitors and throw in the suggested ferrite cores for good measure...

Those pesky ballasts :smiley: ...
Anyway, here is a picture of the project, without the arduino. :slight_smile:
(Stand is welded and build by me, in the bottom is all the "AC Stuff" ... well and the Relays. On top well be a small Box with the Arduino and a Display)

Further testing.
With RC snubbers (100 Ohms 0.1uF as a starting point)

With snubbers it works at a distance.
Before not even at 2m away. But 15cm away from the Lamp line was way to close.

It now starts to reliably work at a distance of about 25cm.
So I'll keep my distance an make it 50 and/or shield it.

Putting the Arduino in steel bowl at a distance of about 5cm also solves the problem.

Nevertheless, the RC snubbers clearly helped.
I did 10 testruns @50cm which works regardless of shielding, and 10 runs on top of the assembly with a steel bowl.
Working reliably.

I will be putting in 0.1uF capacitors on VIN for high frequency AC noise.
The case of the Arduino is now gonna be 3D printed and will be inlaid with aluminium foil.

I think that should do the trick.

Interesting though is, one ballast is clearly worse than the other.
(Might be a different batch, as they are the same)

If I learned one thing in this endeavour, I will be paying much attention to electronics in my third semester :smiley:

Thank you all.

EDIT:
It still does it sometimes. I also posted it in the german forum, as my technical english is not as good.
Thank you all anyways.
Ill let you know if it worked out at some point.