Analog button issues

Hey all,

Having a nightmare trying to get four analog buttons working consistently.

Have done this plenty of times before, but never with more than one button.

ESP32 all wired up with latest firmware. Four analog arcade buttons (https://www.amazon.de/dp/B07GBSJX2H?psc=1&ref=ppx_yo2ov_dt_b_product_details) wired to a bunch of GPIO pins (all in the acceptable 32-39) range.
Each button has a 4.7K ohm pull-up resistor. The button grounds are all tied together.

The LED strip works just fine controlled from the UI.

But testing the buttons leads to all sorts of squirrely behavior: Only testing single and double clicks, sometimes they work correctly, other times a double click on one button will fire off the single click command of another button, other times it won’t respond. Sometimes a single click will register, start the color change, only to ultimately suddenly behave as if another button were pressed.

Does anyone with electronics experience have a hunch as to what this could be? My ground/GPIO connections all seem solid, but no matter how I rewire nothing seems to improve.

Best,
Justin

How have you configured the 4 buttons in WLED?
You describe these as “analog arcade buttons”, but your description leads me to believe, they’re just standard push button switches?

If they are, there is no need for pull-up resistors at all, that’s handled internal to the GPIO you select.
At minimum, remove the pull-up(s) and simplify your setup to 1 button at a time until you verify that works.
Then try to add a 2nd and move forward.

Just my $0.02.

I’ll strip it back and try your suggestion. Thanks.

I am getting terribly confused about the need for pull-up resistors though. The WLED macro docs indicate:

“On ESP32, only ADC1 pins will work for analog input while WiFi is active (pins 32-39). ADC2 pins will not work.”

ADC1 pins are 32-39… and this ESP pinout reference (ESP32 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials) notes:

“GPIOs 34 to 39 are GPIs – input only pins. These pins don’t have internal pull-up or pull-down resistors. They can’t be used as outputs, so use these pins only as inputs”

So based on that I thought I’d need pullups at least on GPIOs 34-39.

At any rate… will mess about and report back.

-J

Ok - did some digging through the ESP docs and you are (mostly) absolutely correct - GPIOs 34-39 do not have internal pullup (or pulldown) circuitry. This makes sense as they are allowed to be used as ADC inputs and pullup/down would affect them. So GPIOs 32-33 don’t need pullups, GPI’s 34-39 do.

Having said that, I still believe your switches are digital not analog inputs.
They way you’ve described their connection to GPIO inputs, they will either produce 3.3V via pullup (internal or external) when the button isn’t pressed or 0V when you pressthe button and it shorts the contacts to ground.

That’s the definition of a digital signal, so those switches would be called “pushbuttons” in WLED and treated as digital inputs. Luckily, GPIs 34-39 can be used for digital as well as ADC inputs, so they should still work (???)

If they do give you any grief, there’s no reason you can’t use any of the other (available) GPIOs as inputs, since you just want a standard digital input.

1 Like

Cleaning things up and taking a break – its driving me mad I say.

(for reference, theses are the switches:
2PCS KW3A Micro Switch 125V/250V 16A Normally Open Switch 2 Pin Silver Contact | eBay)

Rewired just two switches (GPIOs 34 and 35) trying to see if bad connections / grounding was the issue. WLED is configured correctly (as PushButton) and I played around with both using/disabling internal pull-up.

The buttons just misbehave – random triggers, generally inconsistent behavior, and sometimes doing things not even called for in the macro setting (had one of the two buttons set to default on/off, but it instead would scroll through FX presets!)

Will come back to it when the urge to hurl it all across the room subsides.

When you do come back, I’d suggest 2 changes:

  1. Try starting with only 1 switch to test
  2. Try using completely different GPIOs (not 34 - 39)

The ESP32 has a great number of other possible inputs, something else has got to be available.

1 Like

Quick update – not 100% there, but VERY good headway. Genuine thanks for your advice.

Stripped the electronics back to the ESP32 on a breadboard. Added one button at a time and currently have a pair of push buttons configured on new pins (25 and 26 I think) with no pull-up resistors as per our discussion. For the first time, they seem to be behaving normally!

Best I can tell, maybe the perfboard I was using before had some bad cross connections.

I also realized my sloppy terminology was confusing me. I remembered reading a note about only ADC2 pins (34-39) being usable when WiFi is active. At the time I thought this meant push buttons, but I now realize its likely only referring to the use of a potentiometer for brightness control, etc.

So basically, all your advice was correct and thanks for the shove.

Will update again once I wrap this thing up…