Interrupts unstable

I have found the use of interrupts to be very unreliable because they seem very sensitive to minute changes in voltage, even static. What I really want is the functionality available with Arduino to trigger on a hard LOW or HIGH.
Looking through the docs though. It seems like this is not possible. I only am aware of falling, rising, and change modes. Is there some other way to accomplish this?

If you have issues with edge triggers, it’s most likely the wiring and not the trigger type.
IIRC AVRs used on Arduino do also have Schmitt Trigger inputs which do respond well before the actual HIGH or LOW level, irrespective of trigger mode.
So I doubt level triggers would actually solve your issue, rather check these questions

  • What is your signal source?
  • Have you got pull-resistors to prevent the pins from floating?
  • How long are your wires?
2 Likes

We suspect wiring as well, but thought there may some way to mitigate premature triggering.
We have a Mean Well power supply powering an NCD relay board with a Photon plugged in.
The relays are triggered by a rain sensor plugged into the Photon on an interrupt pin with 22ga wire about 20ft long. We are experiencing premature triggering. Regarding pullup resistors. I am using pinMode(pin, INPUT_PULLUP) it was my understanding that pullup resistors were there internally in this pinMode. Should I add another?

INPUT_PULLUP only applies the internal (weak - ~40k) pull-up resistor, with 20ft of cable you have a strong “antenna” which will definelty need a stronger external pull-up.

3 Likes

Thank you!!

Also to add to @ScruffR’s post, you may also want to add a small capacitor to GND creating an RC filter. This will help reduce noise on the input. I suggest a 0.01uF to 0.1uF capacitor with a 2.2K pull-up.

3 Likes

Yes, thanks I was looking into that in a post in the Arduino forums.
2.2k? Scruff seemed to suggest the internal 40k resistors were not big enough.
image

Higher resistance means weaker pull - lower resitance means stronger pull.
So 2.2k is stronger than 40k.

5 Likes