Introduction: Programming ESP8266 ESP-12E NodeMCU Using Arduino IDE - a Tutorial
NodeMCU Dev Board is based on widely explored esp8266 System on Chip from Expressif. It combined features of WIFI accesspoint and station + microcontroller and uses simple LUA based programming language. ESP8266 NodeMCU offers-
--Arduino-like hardware IO
--Event-driven API for network applicaitons
--10 GPIOs D0-D10, PWM functionality, IIC and SPI communicaiton, 1-Wire and ADC A0 etc. all in one board
--Wifi networking (can be uses as access point and/or station, host a webserver), connect to internet to fetch or upload data.
--excellent few $ system on board for Internet of Things (IoT) projects.
Recently, there has been interest in programming ESP8266 systems using Arduino IDE. Programming, of ESP8266 using Arduino IDE is not very straight forward, until it is properly configured. Especially because, the Input and output pins have different mapping on NodeMCU than those on actual ESP8266 chip.
I had request about showing how to program ESP-12E NodeMCU using Arduino IDE. I struggled myself earlier in the beginning, so thought of making this Instructable for beginners. This is quick guide/tutorial for getting started with Arduino and ESP8266 NodeMCU V2 ESP-12Ewifi module. (I think, this method can be used for other NodeMCU boards too. (or only ESP8266 boards, but with necessary hardware modifications and using FTDI modules for programming- not covered in this tutorial because, this is only for NodeMCU dev boards).
This Instructable gives quick intro to-
1) Installing Arduino core for ESP8266 WiFi chip in Arduino IDE and Getting started with sketches written using Latest stable Arduino IDE 1.6.7
NOTE- To use NodeMCU V1 or V2 or V3 dev boards using Arduino IDE, we do not need to flash it with firmware using nodemcu flasher. It is required only if we intend to program NodeMCU using Lua script with esplorer etc.
I have other video published on getting started with NodeMCU and flashing NodeMCU firmware on following link https://www.youtube.com/watch?v=x7GzK7zHKOk
**Arduino logo and NodeMCU logo are their respective trademarks- logos shown in above image were taken from -https://github.com/nodemcu and https://www.arduino.cc/en/Main/Software
Step 1: NodeMCU ESP-12E Pin Mapping
First and foremost word of - CAUTION !
* The ESP8266 chip requires 3.3V power supply voltage. It should not be powered with 5 volts like other arduino boards.
* NodeMCU ESP-12E dev board can be connected to 5Vusing micro USB connector or Vin pin available on board.
* The I/O pins of ESP8266 communicate or input/output max 3.3V only. i.e. the pins are NOT 5V tolerant inputs.
In case you have to interface with 5V I/O pins, you need to use level conversion system (either built yourself using resistor voltage divider or using ready to use level converters (e.g. these ones adafruit or aliexpress etc.).
The pin mapping of NodeMCU dev board are different from those of ESP8266 GPIOs. Attached images gives mapping of pins, source of images.
More information about pins is available on following links:
* Github - NodeMCU
Step 2: Installing Arduino Core for NodeMCU ESP-12E Using Arduino Boards Manager
As shown in the image, Copy the .json link with latest stable release of NodeMCU package from Github page here.
The link should look something like this-
Step 3: Insert Link for .json NodeMCU Package Files Into Arduino IDE
Paste the copied 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.
Step 4: Tools - Boards Manager
Tools - Boards managerand search for ESP8266 and install the libraries/files given under heading ESP8266 by ESP community.
Restart the Arduino IDE once again.
Step 5: Selecting NodeMCU Board in Arduino IDE
Go to Tools - Boards (scroll down the list of boards) - Select NodeMCU 1.0 ( ESP-12EModule).
Select the Port number at which you have connected nodeMCU. Rest of the settings can be left to default values.
Step 6: LED Blink - Connections for External LED
We will be connecting external LED directly to GPIO16 or D0 pin of NodeMCU (no need of external current limiting resistor). This is the pin number for onboard LED or BUILTIN_LED (in my case it is blue LED - some boards might have green or red LED).
Step 7: LED Blink - Example Sketch
Go to File - Examples - ESP8266 - Blink
In my video, I have modified the sketch to blink LED faster, but you can leave as it is and just upload the sketch to ESP and there you go... the On-board LED blue and external LED red starts blinking alternately at every second.
Congratulations for successful configuration of Arduino IDE for ESP8266 NodeMCU dev boards.
Note- In case, if Arduino IDE version 1.6.7 fails to work for you, try to go back to arduino 1.6.5 or backwards. (I have heard, some NodeMCU boards have issues with latest versions of Arduino IDEs and going to earlier versions of Arduino IDE solves the problems).
Good luck for fun with this amazing system on board.....
My Doit NodeMcu Lua ESP8266 ESP-12E WIFI Development Board was from Banggood.com
10 People Made This Project!
We have a be nice policy.
Please be positive and constructive.