Hi,
No, the problem is EMI and EMC.
Switching a relay and maybe the relay switching the load causes EMI.
EMI may be transmitted per wire (any electrical connection), but in many cases it is transmitted via air.
If transmitted via air, then separating the power supplies will not solve the problem.
Reducing EMI: use filters on the switched AC signal, use twisted pair wiring (at least wire the power and it's return path in close proximity). This starts with the traces on the PCB.
Reduce switching speed of the bjt driving the relay coil.
EMC.
If the system hangs, then the system is prone to noisy (EMI) signals.
Usually this is caused by a bad PCB layout, sometimes by a wrong schematic.
Learn how to generate a good PCB layout, this usually starts with a rock solid GND plane. No copper puor, no traces in the GND plane.
The next are fast ceramics capacitor at each power supply pin of each IC (and other fast switching parts of the curcuit).
Start thinking that the signals at the traces are HF, which means the traces are antennas for sending out noise as well as antennas receiving noise.
Start thinking that signals are not from "A" to "B", but always think as a loop. Each signal needs it's return path.
--> traces should be short. The area enclosed by a loop needs to be small.
Mind:
For sure you need to reduce sending out EMI noise...
But in your case it's more important to "stabilize" the function of your microcontroller.
Imagine: Maybe you find it more easy to reduce sent out EMI by installing a filter in the AC lines (switched by the relays) ... and this stops your system to hang. (And you think you are safe now)
But the (microcontroller) system still is sensitive to EMI, then any other source of EMI (cellular phone, remote car key, induction oven, microwave oven...) can make your system to hang.
Klaus