I have the following :

  1. Output Pin 17 (wiringPi pin number 0) to a relay module -> a LOW means the relay will let current pass.
  2. 5V pin to power the relay module
  3. Input Pin 22 (wiringPi pin number 3) pull-up and waiting for interrupt on failling edge connected to a push button which is also connected to GND (using WiringPiISR function).

The problem:

Some times (1 in 3 tries), when I put the output pin 17 to LOW (echo 0 > /sys/class/gpio/gpio17/value) my interrupt function is called and I never touched the button...

Is this normal ? It would seems that when the pin 17 goes LOW, it also puts the pin 22 to LOW for a brief moment, thus triggering the interrupt...

NOTE: I'm connected with a power supply 5V-2A, I also have a USB Wifi and a usb jack 3.5 adapter for mic and speaker.

EDIT: To clarify, I'm using the internal pull-up for input pin 22.

Since, I'm new to all this, would you guys need more info to help me ?

  • 1
    To clarify, are you using an internal resistor for the pull-up? It has been suggested elsewhere this is "susceptible to interference"; see also this Q&A.
    – goldilocks
    Commented Sep 15, 2015 at 12:49
  • 1
    The internal pull-ups are quite weak. I'd try a 5-10k resistor to pull pin 22 to 3V3. As an experiment see if you get the same problem when the relay is not wired up. It might be interference from the relay coils closing/opening.
    – joan
    Commented Sep 15, 2015 at 12:55
  • @joan, good idea I'll try this and see what happens. But how to know the value I should used for the resistor ? You suggest 5-10K but why those values ?
    – Boby2000
    Commented Sep 15, 2015 at 14:05
  • 1
    @Boby2000 Anything in that range should be fine. Lower values draw more current so the higher the better from that point of view. But lower values will give better immunity from interference. I only gave a range as the actual value isn't that important. They will all be orders of magnitude better than the internal 50k resistors.
    – joan
    Commented Sep 15, 2015 at 14:11
  • If you find a solution that works Bobby2000, please feel free to post your own answer.
    – goldilocks
    Commented Sep 15, 2015 at 19:24

2 Answers 2


Turn out that the relay was creating the interference as some answers pointed out.

Disconnecting the relay, did not trigger any interrupt.

To solve the problem, I added at the top of my interrupt function a 10 milliseconds delay and a digitalRead on the pin. If the pin was still high after that, it meant that is was triggered by interference since a human pressing the button would hold it for more than 10 ms.

void MyInterrupt()
  if(digitalRead(3) == HIGH) return;

  //do the button thing


You state "5V pin to power the relay module". I assume this means the 5v from the Pi is driving the relay. What current does it draw? It is not a good idea to power any inductive load from the same power as the CPU.

You should take measures to reduce interference. Decoupling and shielding or twisted pair and good layout helps. You will find other posts discussing this.

As others have suggested a pullup should be used to reduce susceptibility to interference. The lower the better. Even 1kΩ will only draw 3 mA.

The Pi's inputs are incredibly sensitive to interference, more so if used as interrupts.

  • Actually, the relay module is driven an external 5V. The Pi 5V pin is connected to the relay module to run an octocupler so that the Pi is safely protected from my 120V.
    – Boby2000
    Commented Sep 16, 2015 at 0:36
  • Just tried twisting the wires and a 1k no success
    – Boby2000
    Commented Sep 16, 2015 at 0:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.