GPIO Input INPUT_PULLDOWN on ESP32

Has anyone verified that INPUT_PULLDOWN works on the ESP32 (ESP32 Devkit C)?

as in:
pinMode(A3,INPUT_PULLDOWN)

I just see the input floating down to 0, no pull down is evident.

Hi @NBT

How are you reading the signal? through digitalRead() method ?

No, they are being used as interrupts - rising edge.

pinMode(A0,INPUT_PULLDOWN)
pinMode(A1,INPUT_PULLDOWN)
pinMode(A2,INPUT_PULLDOWN)
pinMode(A3,INPUT_PULLDOWN)
pinMode(A4,INPUT_PULLDOWN)
pinMode(A7,INPUT_PULLDOWN)

def pressedLow():
pass

def pressedHi():
buf=bytearray(1)
buf[0] = 0x00
if digitalRead(UP_Key)==1:
buf[0] = 0x01
if digitalRead(DOWN_Key)==1:
buf[0] = 0x02
if digitalRead(MODE_Key)==1:
buf[0] = 0x04
if digitalRead(SPEED_Key)==1:
buf[0] = 0x08
if digitalRead(DIR_Key)==1:
buf[0] = 0x10
if digitalRead(OFF_Key)==1:
buf[0] = 0xFF
Key_Buf[0]=buf[0]
print(“int”, buf[0])
return buf[0]

try:
onPinFall(UP_Key,pressedLow,debounce=200)
onPinRise(UP_Key,pressedHi,debounce=100)
onPinFall(DOWN_Key,pressedLow,debounce=200)
onPinRise(DOWN_Key,pressedHi,debounce=100)
onPinFall(MODE_Key,pressedLow,debounce=200)
onPinRise(MODE_Key,pressedHi,debounce=100)
onPinFall(SPEED_Key,pressedLow,debounce=200)
onPinRise(SPEED_Key,pressedHi,debounce=100)
onPinFall(DIR_Key,pressedLow,debounce=200)
onPinRise(DIR_Key,pressedHi,debounce=100)
onPinFall(OFF_Key,pressedLow,debounce=200)
onPinRise(OFF_Key,pressedHi,debounce=100)
except Exception as e:
print(e)

When I look at the pins with a scope, there is a long decay on the falling edge. That is indicative of a pin that is not pulled low, but rather discharging through a very high resistance. Add a 47K resistor to ground cuts the decay time by about 30%.

Since these are floating, any stray induced noise can cause false triggers (even with the long debounce times).

Just like to know what I’m doing wrong.

Hi @NBT
I checked the code execution flow, the pulldown parameter INPUT_PULLDOWN executes the gpio pulldown method in ESP-IDF.
So this needs further investigation from us.

Since you are using analog pins, I am wondering does this behavior occur also on the other pins?

In the ESP32 forums, They say that the pull down value is between 10k-100k.
As you said it is discharging through very high resistance.
https://esp32.com/viewtopic.php?t=5111
Let me know your thoughts

That would be consistent with my tests. I estimate somewhere around ~50K Ohms.

Thanks for your help!