I'm using DOIT ESP32 DEVKIT V1 with an ESP32 microcontroller, but the behavior is similar to other ESP32 boards.

When a pin is configured as an input with pull-up or pull-down and left floating, its state is not stable. The datasheet lists internal pull-up and pull-down resistance as 45 kΩ. Shouldn't that be enough to keep the input stable?

Here is my test code:

#include <Arduino.h>
#include "esp_sleep.h"

constexpr auto SW1 = GPIO_NUM_34;

void setup() {
  pinMode(SW1, INPUT_PULLUP);
  // pinMode(SW1, INPUT_PULLDOWN);

  gpio_wakeup_enable(SW1, GPIO_INTR_HIGH_LEVEL);

void loop() {
  digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));              
  • 1
    \$\begingroup\$ Do you have access to an oscilloscope to see what's happening with the SW1 pin ? Also, does the unstable behaviour start before or after you kick off the light sleep mode ? \$\endgroup\$
    – Rahmany
    Commented Sep 2, 2022 at 7:57
  • \$\begingroup\$ Could it be similar to this? reddit.com/r/esp32/comments/qn1z8j/… \$\endgroup\$
    – RemyHx
    Commented Sep 2, 2022 at 9:02
  • \$\begingroup\$ And maybe try with an external 10k Ω pull up or down. \$\endgroup\$
    – RemyHx
    Commented Sep 2, 2022 at 9:04
  • \$\begingroup\$ @Rahmany It starts when in sleep mode waiting for rising edge to wake up. I will test with a scope next week. \$\endgroup\$ Commented Sep 3, 2022 at 3:19

1 Answer 1


After checking the Esp32 datasheet, it seems that SW1 (GPIO34) doesn't have internal pull-up/down.

GPIO pins 34-39 are input-only. These pins do not feature an output driver or internal pull- up/pull-down circuitry

The SW1 is, then, floating and will be inherently unstable. So when you enter light sleep the SW1 pin might go High and it will break the sleep

You might not encounter the problem during scope measurements since the probe will generally have a 10 Meg Ohm path to the ground :

enter image description here

It is a weak pulldown, but it might fix it.


You need to add a hardware pulldown or use another Gpio with internal pulldown.

PS : If you put your finger on the pin the problem might go away. It's a quick way to see if an input pin is floating or not. As long as the signal amplitudes are safe of course ;) (5v/3v3 in your case)

  • \$\begingroup\$ Very nice find. To be honest, I didn't know. But I also never use the internal pull up/down, always external. \$\endgroup\$
    – RemyHx
    Commented Sep 3, 2022 at 17:42
  • \$\begingroup\$ Thank you. I observed several times that placing my hand in close proximity of the board, without touching it, was enough to trigger the state change. \$\endgroup\$ Commented Sep 5, 2022 at 4:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.