Having problems with AttachInterrupt and Relay

My project switches on various outputs, including a 5V relay switching mains power. It has an override reset interrupt (on rising) on pin 3 which changes the value of a [global] variable which is polled throughout the program, when the variable is high it resets all outputs. The pin is pulled to ground through a small resistor.

I'm having issues with the interrupt being triggered the instant the relay is switched, which is wrong. When I take out the AttachInterrupt code, the components all work as they should. Unfortunately the reset is the vital part. I could just use the on-board reset (which I use when the interrupt is removed) but I really need an external interrupt generated by a sensor.

The relay is set up according to Arduino Playground - HomePage, with a P2N2222A transistor and 10kOhm resistor. It is connected with twisted pair wires to reduce inductance in surrounding components/pins but still seems to generate a signal at pin 3 which is interpreted as an 'interrupt'.

I am at my wits end as I've tried all sorts, including moving all the other I/Os as far away from pin3 as possible, separating the circuits onto different breadboards, even using coaxial cables.

What am I doing wrong? :astonished:

Have you fitted the diode across the relay?

Yes there is a diode fitted across the relay

If you're already polling a variable, couldn't you simply read the input pin instead?

the input on the interrupt pin is a spike, so unfortunately that won't give the desired results

What is on pin 3 at the moment?

Grumpy_Mike:
What is on pin 3 at the moment?

Exactly my question (a sensor?). I'm guessing that the glitch is coming from the mains side, not the DC side.

Jim

currently just a push-to-make button

Any pull up resistor? If so what value?