Microcontroller freezes randomly when switching on a relay (snubber inside)

Hi, @mendicm
I strongly suggest you read @Paul_B post #22.

You need to dress your wiring into some sort of order.
Making sure that mains wiring does not run sideby side with low voltage and signal wiring.

The chocolate block terminal on the right hanging in mid-air needs to be a proper terminal strip to accommodate all your DC power distribution.

Using the same colour and wire type for DC and AC should also be addressed.

You also have more than enough room to move the controller DIN rail further away from the mains DIN rail assembly.

Thanks.. Tom... :smiley: :+1: :coffee: :australia: