ESP : Using GPIO2 to light external LED

Hello everyone,

I can't believe I'm saying this but I can't get an LED on GPIO2 to light on my ESP32. I measured 3.3v on my pin when pulled high. The wiring is simple resistor (I tried 220ohm and 330ohm), green LED, then to ground.

Any ideas? I don't have any other pins available so please do not tell me to use a different pin. Onboard LED is working.

Thanks

If you are using the following 30-pin ESP32 Dev Module (Fig-1), then FPIO2 is connected with the onboard Blue LED. Without connecting anything with the GPIO2-pin, upload the following sketch and check that the onboard Blue LED is blinking.

Figure-1:

#define BLED 2//onboard BlueLED

void setup()
{
  Serial.begin(115200);
  pinMode(BLED, OUTPUT);
}

void loop()
{
  digitalWrite(BLED, HIGH);
  delay(1000);
  digitalWrite(BLED, LOW);
  delay(1000);
}
``

It is.

Here is my current code

I tried switching to GPIO4 which should be 100% clean to use and it still didn't work. I also switched to a white LED.

Pic @ Imgur: The magic of the Internet


const byte LED_GPIO = 4;

void setup() {
  Serial.begin(115200);
  delay(1000);

  pinMode(LED_GPIO, OUTPUT);

}

void loop() {  
  digitalWrite(LED_GPIO, HIGH);
}

That means that the onboard Blue LED is not blinking for your ESP32 Dev Board! In my case, it is blinking.

I have uploaded your sketch of post #3 for GPIO4; the LED has correctly turned ON.

Your code (and mine when changed to pin 2 causes the onboard LED to blink.

Why isn't my LED working?

HAHAHA...it was polarity!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.