Arduino resets when relay turns on/of

Hey, its me again, from a pc.. I reconnected relay to external power but it still resets when relay turns on or off, when that happens lcd freeze or it doesent show anything. It is annoying because motor should turn just once an hour and now it is working every 20 minutes. Thank you for help and I hope we can find an answers to my problems!

Opto-isolate the trigger pin of the relay
Power it from its own supply
Connect the ground to the relay and the Arduino

1 Like

Also have another look at the wiring requirements on that relay as your fritzing wiring doesn't add up with required connections.

Active and Neutral on the 230V are also incorrect (should be swapped) from a wiring rules point of view. Standard arrangement is never switch the Neutral.

1 Like

If you disconnect the wire between the relay and light bulb, do you still get resets?
My guess is noise from the dimmer is resetting the UNO.

1 Like

Looks like the OP didn't read: schematics

lziga55 - please read how to make a schematic. Fritzing pictures are practically useless and most people here won't take the time to trace the connections in a Fritzing picture.

1 Like

show proper circuit diagram, there is no magic

1 Like

Your code as copied above is quite messy.
Could you autoformat the code and paste it in code tags (as described in the forum guidelines on top of this page)?
This:

if(sec==59)

May be missed if some part of your program takes more than 1 sec to return.
Better is:

if (sec>58) {
}
1 Like

@lziga55
Your other account suspended. You are allowed 1 account. If you continue to create multiple accounts they will all be suspended, including this one.

Thank you

1 Like

I am so sorry, I am new to this forum. I autoformated code now and I am trying to make a schematics but i have some problems because i don't know how to "draw" uln 2003 and relay. So i reconected relay to external 5v and GND, i connected external GND to arduino, I chececked all connections and they look good. After an hour and a half of operation, the arduino started to reset every time the relay was turned on or off. And that. A few days ago I tried to disconnect the 230 V (light bulb and dimmer power supply) from the mains. The Arduino didn't reset then (at least not while I was around checking it.)

So google the data sheets for these parts, they will have the manufacturer's version on the part. Or search for "schematic symbol for ..."

Yes, this is a common problem that someone asks in one form or the other almost once a day. What you need is a Snubber circuit on the mains side.

Note you are best buying these because the components that can take the required voltage (600V) are expensive and specialised. You can't just use any old parts.

So I tryed again, but i disconnected dimmer and light bulb (230V was still in cable, L was still connected to relay, but circuit was not closed) after few relay on-off turns arduino reseted again. Is it sure that I must buy snubber or is problem in arduino or the code? Thanks for help!

If you want to satisfy yourself then try removing the mains from the relay contacts altogether and increasing the frequency you turn the relay on and off. Then off put a message in the setup function so you can see a reset even without you being there. Remove other messages so it is easy to see when the code enters the setup function, and leave it running.
If you get no resets then you need a snubber.

If you get a reset, then remove the connection to the relay coil. If you still get resets then it is your code of faulty intermittent wiring.

1 Like

Thanks I will do that!

If the problem realy is in the 230v what snubber should i buy?

One that says it is suitable for x amount of current where x is what your bulb draws when full on.

Sorry, it is in another language. Will something like that be ok? https://www.ic-elect.si/dusilka-100-uh-1a.html

Seeing that a snubber consists of a capacitor and a resistor, what makes you think an inductor would be OK?
It is not.

Sorry, didn't know, they said its a snubber. I will look for another!

Could you please send me a link of one? Thanks!

https://www.aliexpress.com/item/1005001505519722.html