I am new to xiao ESP32-c3 and experimenting with it for some specific use case that will involve ability to connect 9 push buttons. I have experimented with ESP32-c3 super mini board using a simple program that allows me to use almost all GPIO pins on ESP32-c3 super mini where I can see that I can connect a push button and have its press / release event detected successfully in the program. with Arduino ide environment.
If I use the Arduino sketch that runs successfully on Super mini board and detects almost all pins and buttons connections, on seeed xio esp32-c3 board however, only pin 8,9,and 10 works for the button-pin connection.
Hence, after going through the forum posts here, I understood interrupt related functionality addition in some older posts. Hence, I used the below test program to see if I can get the button-pin mapping working.
Using this technique I could get the buttons to pins connection work, for all gpio pins So that’s a great feeling that the problem got solved. However, few questions remain as a puzzle.
Why super mini board can detect all buttons-pin mapping correctly without requiring any interrupt routines added as extra piece of code, unlike xiao esp32-c3 board?
There is too much noise / sensitivity in xiao board, where a single press results into some times multiple stream of events getting generated than a single distinct push event. I thought the mention of pinMode(D0, INPUT_PULLUP); takes care of this sensitivity on the pins but it does not appear so.
So how can the noise resulting into multiple events in the interrupt routine above during a single button press be avoided, so a single press, results into a single event generation?
So it’s a common question about the ESP32C3 it is not like the others
If you have a Link to the super mini Board you tried I could look at the specs and perhaps share some thoughts on its IO.
I can offer this ,
1).The GPIO pin numbers may give better results , the Dx,Ax Pin macros differ in some BSP’s and boards.
2). The Xiao is so fast it see’s many INTERRUPTS, Debounce the switch in Software or add it to the hardware or disable the interrupt for a short time period…use a counter?
You can POLL for the Digital inputs or latch them and read them, but the Interrupt is better, your code can do other things than just read the IO.
Some notes on Interrupt, You should set a flag or just increment the counter and let the LOOP function do the printing… Bad things can happen when you print in the Interrupt Handler routine, FYI.
Check the search out there is a demo and how it uses the button and Tap interrupts too.
Thanks much for your quick detailed reply. Highly appreciated PJ_Glasso.
This is the link to the super mini board I got from aliexpress. Super mini
I would really like to solve the issue of super sensitivity of xiao in some way. I do not exactly understand the possible solutions you mention “Debounce the switch in Software or add it to the hardware or disable the interrupt for a short time period…use a counter?” Would you please give me some more elaborations for these, so I can learn more about what / how to do these approaches please? Any references or practical examples or other hints to get a bit more idea of the approaches will be super helpful as its critical I generate a single event on a single press as this single event will be captured by another ESP32-S3 board on BLE to take some resulting action.
The final aim is to pair the server running on xiao c3 with a client running on ESP32-S3 board and communicate over BLE the button presses to do different actions on ESP32-S3, so being able to capture the events distinctly first in the server mode on xiao and then communicate it over BLE to be captured in client running on ESP32-S3, to take resulting action on S3 is critical without any failures.
Polling could be a possibility as well, but not sure if it will lead to higher power consumption as this will be hooked to a battery and so optimal energy usage is highly critical for long usage further.
So a final solution that can use optimal battery and generate single events per button press is sought after.
Thanks for the heads up for avoiding the prints or any other time consuming work in ISR routine.
Ok, So it is slightly different as we suspected. for example the LED is connected to GPIO8 , that is different than the Xiao.
Yes, you are correct. The polling will use more Power over all, its always on and running, Done with interrupts you can use SLEEP to save a ton of power and get great battery life.
There is FORsure some examples of this configuration and Tech.
There is actually a BLE demo (albeit Nrf based , Kitchen Sink) on here , with Wakeup and Sleep and tap detection to increment a counter.
Just scan the code to see where you go on certain logic’s
The BASIC’s… Switch Debouncing – Quick Explanation:
When a mechanical switch (like a button) is pressed or released, the contacts don’t close cleanly — they bounce, causing multiple rapid on/off signals within a few milliseconds. This can cause a microcontroller to detect multiple presses from a single tap.
Debouncing is the process of ignoring those rapid false transitions by:
Waiting a short time (e.g. 20–50 ms) after a change is detected
Only accepting new input if the state remains stable
Software Example:
if (digitalRead(BUTTON_PIN) != lastButtonState) {
lastDebounceTime = millis(); // Reset timer on change
}
if ((millis() - lastDebounceTime) > debounceDelay) {
if (digitalRead(BUTTON_PIN) == LOW) {
// Button is stable and pressed
}
}
lastButtonState = digitalRead(BUTTON_PIN);
the software debounce is really all that is needed , However there is a hardware version using a Capacitor + resistor.
Have you looked at the WiKi for the C3 it’s good to look those over for the MCU lots of very good info there to get You started.
Your end goal description is good and is doable and AFAIK there is a example of it here somewhere I look a little more when I get home later…
Thanks much for the debouncing explanation and software debouncing sample code. Will try that.
I had visited the Getting Started Wiki Page here to get familiar with Battery connection to ensure battery connection works with LED blinking and switch, as I had some issues with that earlier, since the charging light does not show up when battery is connected to test (which I did not know until reading battery connection section).
I browsed through some posts on this forum to get some insights into issues I thought I might need exposure to such as deep sleep, power, and some more and its on my mind to read more to get more familiarity. If you could give any link that I should be checking for general info that will be useful, please share as well for direct exposure. I would appreciate that.
Thanks a lot for all your quick help and time. Deeply appreciated.
No problem , We are all here to help. SO the BEST thing I recommend on the reading part is the "SYSTEM on Sleep " thread… Start there and just be mindful of the BSP (board Support Package) the post, user or thread talks about. Those are provided by the manufacture, so stuff changes and gets fixed, & brokken
any other Q’s just post it up now, you credz should allow you too.
Lot’s of smart folks on here to help and some 's too but way better than a reddit thread