I'm building environment control box. One of the functions of this box is to control humidity and temperature using exhaust fan. I'm using ESP32-WROOM-32D devkit and 5v 6-way opto-isolated relay module:
Schematics are relatively simple:
i2c bus is used for RTC and sensors, which are powered by 3.3V voltage regulator. All circuit is powered by 5V meanwell PSU. ESP32 gets it's 3.3V from devkit's voltage regulator (later i'm going to use standalone ESP32 module and power it from voltage reg.).
The problem is that when controller switches on fan, it occasionally resets or even stucks. Watchdog can not handle that. Output on serial monitor is unreadable. If i make it turnining on and off every 5-10 secods, it happens very soon. If it's once in few minutes, it happens once a day or two or even week. When i disconnect fan from relay, problem goes away.
So it's definetely fan. And it seems that it's sort of interference going to MCU.
So my question is how to protect my circuit from that? I've already seen recomendation to use separate PSU, but relay module uses common ground for optocouplers and relay so it seems that cirucuit won't be 100% isolated.
I would highly appreciate any advise on this issue. I'm relatively new to electronics, so probably, the answer is somewhere nearby