Problem using GPIO as interrupt [Solved]

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Problem using GPIO as interrupt [Solved]

Post by davef » Mon Jan 17, 2022 10:08 pm

In trying to debug a watering timer app I found that when the motor turned ON it generated interrupts before the the shaft switch even actuated. Then I found that either touching the GPIO pin or turning a transformer type power supply on and off, about 1 metre away, would also generate interrupts!

Tried a 10K pull-up in case the internal pull-up was not enough, to no avail.

Is a GPIO configured as an interrupt pin supposed to be that sensitive? I have used interrupts on the ATmega88 and never noticed this behaviour.
Last edited by davef on Wed Jan 19, 2022 12:44 am, edited 1 time in total.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Problem using GPIO as interrupt

Post by dhylands » Mon Jan 17, 2022 11:19 pm

It sounds like you might be using the wrong GPIO? Or perhaps you have a long wire?

I worked with a TI microcontroller board that had a reset line. I connected a 6 inch wire and a push button, and generating static spark from six feet away (by walking across the carpeted floor and touching a filing cabinet) was enough to reset the board. The wire was essentially acting like an antenna.

Unfortunately, motors can generate quite a bit of EMF and that can effect nearby circuitry.

I generally twist the 2 wires going to each motor together (this reduces the inductance) and put a 0.1 uF cap between each wire and the case of the motor, and another between the 2 motor terminals. Physically seperate the motor from the MCU.

If possible, run 2 ground lines from the battery. One to the MCU and its circuitry and second one to the motor and motor controller circuitry. This will help to reduce "ground bounce" on the MCU ground.

Pololu has a good set of recommendations here: https://www.pololu.com/docs/0J15/9

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Problem using GPIO as interrupt

Post by davef » Mon Jan 17, 2022 11:29 pm

All I have on pin14 is a header pin and a 10K resistor to 3V3.

I read that GPIO14 can be used as a touch GPIO so tried one of the non-touch GPIO and got same behaviour.

Unfortunately, the wires to the motor/switch are in a 4 wire cable and the switch wires are well-wrapped around the motor power wires :(

Thanks for the hint ... I will separate them ... after I have managed to debounce the switch (I have read some of your previous posts on this issue).

Thanks for the link.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Problem using GPIO as interrupt

Post by davef » Wed Jan 19, 2022 12:44 am

I put a 100nF to ground on the GPIO used as an interrupt pin and that got rid of the "touching with a finger problem". Bypassing the motor terminals as suggested in the link improved "the response to motor noise problem" significantly. I am happy.

Post Reply