Improve consistency for reading momentary buttons presses #15735
Replies: 4 comments 6 replies
-
It would help if you could describe the exact nature of the problem you're experiencing. Note that internal pullup resistors tend to be of quite a high value, increasing the risk of EMI. I always add an external resistor (typically 1KΩ) to 3.3V. If the switch is connected by a very long lead, other recommendations may apply. |
Beta Was this translation helpful? Give feedback.
-
I don't think the series 1KΩ resistors are helping. In general the best way to wire pushbuttons is between the input pin and ground, with a 1KΩ resistor between the pin and 3.3V. This resistor aids the internal pullup, ensuring that the circuit has a low impedance when the button is open. The reason for preferring a button connection to ground when there is external wiring is that typical fault conditions are a short circuit to ground. Sending out 3.3V on the external wiring exposes a risk of a short between 3.3V and gnd. While this wouldn't break anything, it would crash the processor. The other possibility is a software problem. Please check whether a sustained press (> 1s) on the buttons is reliably detected. If this is the case you may have a task which is hogging the processor. The ESwitch module uses polling to detect the button state. This is reliable providing that all tasks yield regularly to the scheduler (by calling Regular yielding is a basic part of good |
Beta Was this translation helpful? Give feedback.
-
You can try adding external pull-up or pull-down resistors with lower values, such as 10kΩ, to provide a stronger pull on the GPIO pin. |
Beta Was this translation helpful? Give feedback.
-
Aside from the electrical issues another possibility is the To put this into context, micro-gui uses pushbuttons (or an encoder) for control. It has been developed and extensively tested on various platforms. Button presses are not missed unless you very deliberately give an extremely brief press. If running with a large screen, the transfer of the frame buffer to the screen would block for a period sufficient to affect the reliability and speed of response to pushbuttons. Various measures are taken to ensure this does not occur, including splitting the update into several segments and allowing the scheduler to run between each. |
Beta Was this translation helpful? Give feedback.
-
I am using ESwitch with uasyncio to detect button presses on my PICOs (i'm using cheap mini monetary buttons from ebay/ali-express)
what can i do to make button presses more consistent aside from adding a MLC between the button and the GPIO pin's safety resistor
note that EMI getting into the wire and giving a false positive would be worse than a missed press
Beta Was this translation helpful? Give feedback.
All reactions