Monday, February 8, 2016

How to program ESP8266 ESP-12E NodeMCU using Arduino IDE


This is quick guide/tutorial to get started with Arduino IDE and ESP8266-ESP12E NodeMCU wifi module.
(I believe, this tutorials can be used for other NodeMCU versions too. (or only ESP8266 boards, but with necessary hardware modifications and using FTDI modules) Please note the pin mappings as given at the end of this post.


 

We will be connecting external LED directly to D0 pin (or GPIO16) of NodeMCU (no need of external current limiting resistor). 
         
If you do not have external LED, it can be skipped because there is already one on-board (blue) LED at this pin. I have connected external red LED just as fun.

Boards manager link
http://arduino.esp8266.com/stable/package_esp8266com_index.json

or it can be found on following link-
https://github.com/esp8266/Arduino


Copy the above link and insert it in Arduino IDE using following sequence-
File menu - Preferences-

Paste copied link into the area shown in black box in above image. Close and restart the Arduino IDE.

Now go to Tools Boards manager and search for ESP8266 and install the board libraries. Restart the Arduino IDE once again.


Go to Tools - Boards (scroll down the list of boards) - Select NodeMCU 1.0 ( ESP-12EModule)


Select the Port to which your ESP is connected and upload the examples blink sketch.
I have modified a bit the sketch to blink LED faster, but you can leave it and just upload the sketch to ESP and there you go... the Onboard LED blue and external LED red starts blinking alternately.

Congratulations for successful configuration of Arduino IDE for ESP8266 NodeMCU dev boards.  

Pin mapping between actual GPIO of ESP8266 and NodeMCU board (it might vary if you are using other boards).

NodeMCU ESP8266 GPIO Functions
D0 GPIO16 LED_BUILTIN or BUILTIN_LED
D1 GPIO5 I2C-SCL or CLK
D2 GPIO4 I2C-SDA
D3 GPIO0 SPI-RES or RST
D4 GPIO2 SPI-DC
D5 GPIO14 SPI-SCL or CLK
D6 GPIO12 SPI-MISO
D7 GPIO13 SPI-SDA or MOSI
D8 GPIO15 SPI-CS or SS
D9 GPIO3 Serial RX0
D10 GPIO1 Serial TX0
D11 GPIO9
D12 GPIO10


Note- In case if Arduino IDE version 1.6.7 dosent work for you, try to go back to arduino 1.6.5 or backwards. (I have read that some NodeMCU boards have issues with latest versions of Arduino IDEs).

Helpful links-
https://github.com/esp8266/Arduino/blob/master/variants/nodemcu/pins_arduino.h#L37-L59

http://nodemcu.readthedocs.io/en/dev/en/modules/gpio/ 


Current NodeMCU i am using was from Banggood.com and it says 
DOIT ESP12E DEVKIT V2    www.doit.am