16

Trying a simple led blinking program I could not get the builtin led on a LoLin Node MCU v3 working. The LED_BUILTIN constant is set to pin 16 / GPIO16 / D0.

Reading several articles and QA I think that the Node MCU boards are supposed to have a the on-board led on pin 16. However, if I address this port nothing happens.

With the same code I can blink the data led which is on a RX pin, pin 2.

Is the builtin led missing on the LoLin Node MCU v3, or could it be that the led on my board is broken?

0

3 Answers 3

32

the ESP8266 has a builtin led that is attached to D4 as labeled on LoLin boards which maps to GPIO2. One thing to Note is that the led is active low. In other words ... setting PIN 2 to '0' will turn the LED ON and setting PIN 2 to '1' will turn the LED OFF

Lolin Builtin_Led Picture

This is the only LED on the LoLin boards and differs from other devkits that have an LED on GPIO16.

4
  • 1
    I have been banging my head against this for a half hour. Lot's of conflicting information due to different manufacturers. The reverse logic is a bit strange but at least it works. Nov 18, 2017 at 12:42
  • I have put up a blink example demonstrating pin 2 on gist.github.com/jhorsman/6a93191ba31a48cf0cea75acd4c20cea
    – Jan H
    Jan 26, 2018 at 18:12
  • Great it saved my time. I was clueless.Do you know what are the other differences in LoLin board? Any links Apr 4, 2018 at 3:33
  • @JoyGeorgeKunjikkuru This was helpful to me: frightanic.com/iot/…
    – nicocesar
    Apr 4, 2018 at 15:38
7

I have nodeMCU v3 and Pin 2 worked for me.

#define LED_BUILTIN 2

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
                                    // but actually the LED is on; this is because 
                                    // it is acive low on the ESP-01)
  delay(1000);                      // Wait for a second
  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  delay(2000);                      // Wait for two seconds (to demonstrate the active low LED)
}
3

The NodeMCU with the CP2102 serial and a slightly narrower pin footprint does have 2 LEDs.

$led1 = BUILTIN_LED;  //D0, 16, BUILTIN_LED: OnBoard LED
$led2 = 2;    //Pin 5 D4/2 Internal LED for LoLin V3

The $led1 = BUILTIN_LED (on GPIO 16) is **not* on the LoLin NodeMCU v3.

Your Answer

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

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