I am detecting 240 V AC mains using optocoupler. Here is my circuit.
When I am doing this my microcontroller resets every time I on/off the 230V AC circuit. I've seen response of the on & off switch in oscilloscope. It is looking like below image
Can anyone help with how to reduce this transient. I've tried low pass filter at output side by adding 330Ohm resistor with 10uF capacitor. Did not worked.
I've tried same thing with Arduino ATmega328P which does not reset with same transient.
Any help would be appreciated