Flash NodeMCU dev board with Arduino Sketch

  1. Download official Arduino IDE 1.6.5, and install it on your laptop.
  2. Open Arduino IDE, choose File->Preference->Additional Boards Manager URLs. Then add the url: http://arduino.esp8266.com/versions/2.1.0-rc2/package_esp8266com_index.json
  3. Open Tools->Board->Boards Manager, wait a minute, select ESP8266 items, Install.
  4. Waiting until the installation finishes, and select the NodeMCU board you use from board list (I’m using NodeMCU v0.9, so I selected that). Select the serial port you use to flash the board (I’m using the USB serial port).

5. Write some code, upload the sketch and test!

Wiring

Conclusion

The process worked for me. But I also saw other people mentioning press the flash and user buttons to flash. I didn’t need to do that, and it worked.

Remaining issue

the pin numbers I use do not seem match the ones on the dev board. I’m still trying to figure out why. For example, when I set output pin to 0, nothing happens. When I set to 1, the tiny blue LED on board is on. When I set to 2, my LED will light up after I move the wire to pin 4 on the board.

Update 1/31/2016

I found this github page mentioning the pin remapping. Actually, the ESP8266 library we installed actually has this remapping defined in the header file, e.g.

/Users/ghuang/Library/Arduino15/packages/esp8266/hardware/esp8266/2.0.0/variants/nodemcu/pins_arduino.h

static const uint8_t D0 = 16;
static const uint8_t D1 = 5;
static const uint8_t D2 = 4;
static const uint8_t D3 = 0;
static const uint8_t D4 = 2;
static const uint8_t D5 = 14;
static const uint8_t D6 = 12;
static const uint8_t D7 = 13;
static const uint8_t D8 = 15;
static const uint8_t D9 = 3;
static const uint8_t D10 = 1;

So I changed my code to the following, and the pins are matched.

int outputPin = D1;

void setup() {
 pinMode(outputPin, OUTPUT);
}
 
void loop() {
 digitalWrite(outputPin, HIGH);
 delay(500);
 digitalWrite(outputPin, LOW);
 delay(500);
}

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.