I2C RTC & OLED loop breaks

Output to relays is connected to 240v, they control sockets.

Once I have connected relays with a separate power input, as per the diagram from my second last message, and the problem is back.

It appears that when relays are disengaged the problem occurs.

I understand what you have done on the coil side of the relay. Can we focus on the output for a moment.

Are the relays controlling AC or DC? If there is nothing plugged into the socket, does the program fail?

What is plugged in to the socket to be switched? Is it inductive or resistive load?

If you have AC you may be better off with an SSR and zero crossing switching.