Hi, guys!
I am having some curious things happening with my Arduino UNO int0 pin(D2) . Let me basically explain how is my circuit :
On pin D13 I have the output of a half wave rectifier (to rectify and adequate the signal within the Arduino pin limitations) connected to it. Through this pin(D3) I detect the presence or not of a signal(from mains - 60Hz and 127 Vrms) that is connected to the half wave input rectifier .
In order to put Arduino on power down mode I connect the D2 pin to ground through a push button(I am using pull up resistor on it) . In that moment I activate the arduino interruption( on D2 pin as well - int0) and put it to enter the power down mode . After the system is sleeping, when I connect again the D2 to ground by the same push button the microcontroller wakes up. Ok, until here all of it is working fine, without any problem.
Now the problem description:
When the system is already sleeping and I suddenly connect(this is the nature of my system, there is no way to change it) the cable to the half wave input (mains cable - in fact I use a button for this purpose) rectifier the interruption is triggered without apparently reason or connection of the D2 pin to ground. Therefore the system wakes up without connect the D2 pin to ground.
The tests I made to try solve it:
1 - Disconnect cable from D2(int0) input
Result: The problem goes away. When I connect and disconnect the mains from the rectifier input the problem do not come back. The interruption is not triggered.
2 - Connect only one side of the wire jumper on D2 input leaving the other side disconnected from the push button.
Result: The same thing happens , the problem persists.
3 - Disconnect the half wave rectifier output from the D13 pin.
Result: The same thing happens. Problem persists.
Before someone can question me: I already know about the particularities when connecting gnd Arduino directly to mains electrical system.
Pin D13 can be a problem for input. It has an LED and resister connected to it which can cause problems. I would try using a different pin for input. This may not be your problem but it would be one less possibility if you use a different input pin.
Your photo does not show any "sudden connection". If you are "suddenly connecting" the arduino to a mains ac voltage it may well cause transients that could be picked up by the D2 cable. Hence why with that removed the interrupt does not occur.
You may need to look at your grounding arrangement and perhaps screen the d2 cable.
I already disconnected the built in led present on the Arduino board. Therefore I opened the circuit without change the pin. In fact all the tests were made with that configuration suggested. Thank you the same way.
Really my photo does not show the switch on half wave rectifier Input, my bad. I think the problem has really to do with the ground. But why does not It happen without connection on D2? My question is: If the ground were the real motivation the problem would still continuing to happen with cable or not connected to D2 pin?