I even replace T12 with an optoisolator and used an external power supply to drive the relay so the power supplies on both sides of the optoisolator are isolated in addition to the control signal (digitalout0). I still get noise when I turn the fan on/off with the manual switch or by turning the relay on/off. I cannot figure out how the noise is getting in. I ran the power supply for the microcontroller through a battery UPS backup and I ran the power supply for the relay side to a separate wall outlet so that noise couldn't get getting through the power lines.