I am having an issue with raspberryio/wiringpi interrupts. A lot of extra interrupts are generated. My configuration is as follows:

Physical pin 16:

  • Set as input
  • Pulldown resistor
  • Interrupt triggered on rising and falling edge

I am Coding using raspberryio which in turn is using wiringpi

When the input supplying the pin is set to 0 I get a lot of falling edge interrupts without positive interrupts in between e.g. 0,0,0,0,0,0,0,0,0,1,0,0,0,0,0. When the input is high I get a lot of rising edge interrupts without negative transitions. Following some research it seems that the value I read in the ISR does not necessarily match the pin value that generated the interrupt due to delays in wiringpi/linux etc.

The code for the "button":

public QButton(IGpioPin gpioPin, ulong interruptTimeMS)
        _gpioPin = gpioPin;
        InterruptTime = interruptTimeMS;
        _gpioPin.InputPullMode = GpioPinResistorPullMode.PullDown;
        _gpioPin.PinMode = GpioPinDriveMode.Input;
        _gpioPin.RegisterInterruptCallback(EdgeDetection.FallingAndRisingEdge,  HandleInterrupt);


private void HandleInterrupt()
        // HandleButtonPressed();
        if (_gpioPin.Read())

Pigio and more specifically piscope: http://abyz.me.uk/rpi/pigpio/piscope.html shows the pin as high without any negative transitions when the input is set to high. Debugging my code indicates the signal is always high.

What I really need to do is perform 1 action on negative to positive transitions, and a separate action on positive to negative transitions but at this point I am at a bit of a loss what to do. The application is written in C# (.net Core) so it will be a fair bit of work to transition to another framework.

  • pigpio only uses Broadcom GPIO numbers. What you call physical pin 16 is GPIO 23. – joan Jun 25 at 20:53
  • Ah thanks for the clarification. When I monitor GPIO 23/Physical pin 16 it is staying high on both points. I am still seeing the interrupts on wiringpi but not on pigpio. – Fuzzytrooper Jun 25 at 22:02
  • By default pigpio samples at 200ksps. So a level change of less than 5µs can be missed. – joan Jun 25 at 22:07
  • That would make sense with what we've observed. The signal is coming from a relay that seems to be consistently on but it is in a noisy environment. The same code is running on multiple other devices in other locations without the same issue. – Fuzzytrooper Jun 26 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.