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

2) Run/modify basic LED blink sketch to blink onboard LED and/or externally connected LED at pin D0 or GPIO-16 as per the pin configuration mentioned here and here.

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

* Github-esp8266/Arduino

<p>Hello. <br>I didn't have any error, but nothing happened! I mean that the external LED didn't blink.......<br>What can I do?</p>
<p>Hello Jessteleco,</p><p>I have the same problem with both two boards which I have. Please, have you solved it finally? If yes, please, can you share the solution with me/us? Thanks</p>
just check if right pin no is selected in sketch and led is connected properly
<p>Try installing the driver listed on this page that matches your operating system.</p><p>https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx#mac</p>
<p>Can the esp8266 only upload and download from websites or can I give it an IP address and port number to get info from a C++ app I wrote?</p>
<p>Of course. You can start from Examples -&gt; ESP8266WiFi -&gt; WiFiClient. That's simple base for TCP client/server. You might want to change the httpPort and printed string to something else.</p><p>Currently I have managed to build couple of LoLin temperature/CO measuring clients and RPi as a server.</p>
sounds interesting. ..i haven't tried hooking up to internet. if you manage to do that please share...
<p>is it IoT? </p>
<p>Great Tutorial. Thanks a lot. </p><p>As an additional comment, in my case the &quot;Blink example&quot; did not appear inside esp8266 library. But as tip for others, where the same happen, the sketch is the same as included in &quot;Examples/Basics/Blink&quot;. Only change the pin 13 for D0 or 16:</p><p>/**********************************************</p><p> Blink</p><p> Connected to pin D0 (GPIO16) ESP8266 NODEMCU</p><p> **********************************************/</p><p>void setup() </p><p>{</p><p> pinMode(D0, OUTPUT);</p><p>}</p><p>void loop() </p><p>{</p><p> digitalWrite(D0, HIGH); </p><p> delay(1000); </p><p> digitalWrite(D0, LOW); </p><p> delay(1000); </p><p>}</p>
thanks for sharing
the only way I can upload Arduino sketches with these boards is to press the reset and flash let simultaneously for a second and then let go of the reset key first, then it is able to upload the sketch.
that is weird because if you are using nodemcu it should work without any additional steps.
<p>good i'ble.Now after passing through everything ,</p><p>during uploading, i get this</p><p>warning: espcomm_sync failed</p><p>error: espcomm_open failed</p><p>error: espcomm_upload_mem failed.</p><p>what might be the reason , i am sure with the correctness of the serial port .</p>
<p>Hello dude i had the same problem, I solved by connecting gp0 and gp15 to ground, the before uploading the sketch disconnect and connect the usb thing</p><p>Tell me your results</p>
<p>I have the same exact problem and changing the baud rate didn't work.</p><p>Moreover, when I try to connect to the flasher program it doesn'find the board!<br>Anyone solved this?</p>
MatteoG2! Hello.!!<br>Install CH340G driver.Installing the driver solves ur prob.
<p>Hi Manoj! Thank you for answering! I just followed your suggest but still didn't worked. Actually because the chip mounted on my node MCU is the CP2102, and my PC actually recognize it on the serial port! <br>When compiling a sketch in the Arduino IDE, the antenna led blinks three times then the IDE tells me:</p><p>warning: espcomm_sync failed</p><p>error: espcomm_open failed</p><p>error: espcomm_upload_mem failed</p><p>error: espcomm_upload_mem failed</p>
<p>Hi Manoj. </p><p>I had the same error and the only way that my NODEMCU worked was setting up the speed to 115.200 and not 9.600 as specified at back of the board. Worked fine since after. </p>
<p>HI,</p><p>Very likely you have two (or more) Arduino-IDE/Serial monitor windows open.</p><p>Dave</p>
I remember having this error at some point but cannot recall correctly what I did to resolve it..<br>do you have anything connected to io pins of ur esp? especially D0 , if so just remove it for a while during programming. secondly, esp are power hungry devices... my esp shows errors when several sensors/peripherals are powered directly through nodemcu. just as a test, first try upload sketch on a bare board.<br>I hope this helps a bit. good luck
check your com port number and settings.
<p>if someone in the community could solve this,i would be grateful to them</p>
<p>I need code for esp nodemcu to connect it with arduino on internet</p><p>plzzzzzz</p>
<p>hi im using nodemcu v3(lolin) i installed ch340G driver but the device is connecting and disconnecting continuously plz help to solve this issue and what baud rate i need to use 9600 or 115200 , in board they mention 9600</p>
<p>Hi,</p><p> I have already setup and tested a weather iot using NodeMCU but now i need an external battery supply. My electronics knowledge is rudimentary at best but can i use a 9v snap jack cable connected to a jack to micro usb cable that is connected to the NodeMCU as a power supply? Will the ams1117 take care of the step down for the 3.3v or will that like totally fry my nodeMCU board? <br></p>
I believe it should work by applying 9v through usb socket..but not sure. you also need to be very careful that you do not apply 9v to usb data pins.<br>other way is to apply 9v via Vin pin of nodemcu. to the best of my knowledge the voltage regulator should take care of stepping down voltage to 3.3v.<br>just a word of caution. ..I have confusion whether max voltage can be 5 v or 12v at Vin pin..because I read in some forums that we can apply max 5 v only to Vin pin. but my guess is 9v at Vin pin should work.<br>good luck.
<p>Please, take caution with input voltages depending on your exact development board!</p><p>I have an ESP12E DEVKIT that has an CP2102 USB to serial TTL and voltage regulator that only accepts input voltages between 4 and 5.25v, so you will need (in that case) an 4.7 or (better) 5.1v zener diode, but remember that the difference will be dissipated by the limiting resistor.</p><p>Good luck!</p>
<p>Thanks Electromania! *Keeping fingers crossed *</p>
<p>I have the same error until I found some videos like this: <iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/XwHfKsz1xW4" width="500"></iframe></p><p>Some boards need flashing first with the tool presented on this video (my case with a no-name board), some don't (my case with an Amica board). After you've done the flashing procedure you'll be able to use Arduino IDE, putty, esp tools etc. Otherwise not. I use only Arduino IDE because I'm familiar with.</p>
<p>Hi i have error</p><p>esptool v0.4.9 - (c) 2014 Ch. Klippel &lt;ck@atelier-klippel.de&gt;</p><p>setting board to nodemcu</p><p>setting baudrate from 115200 to 115200</p><p>setting port from /dev/tty.usbserial to /dev/cu.wchusbserial1420</p><p>setting address from 0x00000000 to 0x00000000</p><p>espcomm_upload_file</p><p>espcomm_upload_mem</p><p>opening port /dev/cu.wchusbserial1420 at 115200</p><p>tcgetattr</p><p>tcsetattr</p><p>serial open</p><p>opening bootloader</p><p>resetting board</p><p>trying to connect</p><p>espcomm_send_command: sending command header</p><p>espcomm_send_command: sending command payload</p><p>trying to connect</p><p>espcomm_send_command: sending command header</p><p>espcomm_send_command: sending command payload</p><p>serialport_receive_C0: C4 instead of C0</p><p>trying to connect</p><p>espcomm_send_command: sending command header</p><p>espcomm_send_command: sending command payload</p><p>serialport_receive_C0: C4 instead of C0</p><p>resetting board</p><p>trying to connect</p><p>espcomm_send_command: sending command header</p><p>espcomm_send_command: sending command payload</p><p>trying to connect</p><p>espcomm_send_command: sending command header</p><p>espcomm_send_command: sending command payload</p><p>serialport_receive_C0: C4 instead of C0</p><p>trying to connect</p><p>espcomm_send_command: sending command header</p><p>espcomm_send_command: sending command payload</p><p>serialport_receive_C0: C4 instead of C0</p><p>resetting board</p><p>trying to connect</p><p>espcomm_send_command: sending command header</p><p>espcomm_send_command: sending command payload</p><p>trying to connect</p><p>espcomm_send_command: sending command header</p><p>espcomm_send_command: sending command payload</p><p>serialport_receive_C0: C4 instead of C0</p><p>trying to connect</p><p>espcomm_send_command: sending command header</p><p>espcomm_send_command: sending command payload</p><p>serialport_receive_C0: C4 instead of C0</p><p>warning: espcomm_sync failed</p><p>error: espcomm_open failed</p><p>error: espcomm_upload_mem failed</p>
never heard or experienced such errors. not sure what might be causing this. but just quick guess is...have you selected correct nodemcu board in boards manager?<br>have you installed esp8266 arduino core libraries properly?<br>is your usb cable good?<br>lastly do not connect it to usb hub.<br>good luck.
HI <br>have you installed esp8266 arduino core libraries properly? yes i installed libraries.<br>is your usb cable good?- good<br>thanks
esp communication error is mostly encountered by me when usb cable is not good, esp is connected to usb hub, improper driver, wrong board selected while selecting board in arduino ide. <br>check if you can see usb device in Windows device manager, try to change baud rate of your usb port, use short usb cable , do not connect via usb hub.<br>last option would be, try first to program usin esptool or lua loader, if it doesn't work even there then probably something is wrong in your hardware or in communication port. <br>I have a video on my youtube channel about getting started with nodemcu using esptool.<br>good luck
<p>Why is a current-limiting resistor not needed for the LED? The GPIOs are rated for 12mA and typical LEDs draw 20mA.</p>
<p>Looking at the schematic, you NEED a resistor, tho one onboard is only connected to the onboard LED.</p>
no, you do not need to do anything with Rst or Flash buttons, to program.
it is not required for D0 pin since there is an onboard resistor, as far as I know.<br>for other pins we will need a resistor.
<p>Sir when i press compile bottom on Arduino ID it showing following <br>error--- Error Compiling for board Node MCU 1.0(ESP-12E Modul).<br> Board nodemcuv2 (platform esp8266,package esp8266) is unknown<br>Error compiling for board ModeMCU 1.0 (ESP- 12E Module)</p><p>please help me</p>
do u see Nodemcu board in Boards Manager as shown in step 5. <br>If not, then seems you have not installed esp8266 core repositories as mentioned in previous steps.<br>secondly please remember to restart your Arduino IDE after installing esp8266 core libraries.
<p>I have the same problem (I think).</p><p>I do everything listed in the instructable, however when I plug the esp into a usb port, the IDE doesn't list it (no ports available). Am I missing a driver or something? I tried linux and windows.</p><p>If I randomly push the reset and flash buttons, both sometimes list a port, and I am able to upload a sketch, however when trying to open the serial monitor later, the port is no longer listed.</p><p>Someone please help :(</p>
esp is power hungry device. if ur pc detects esp for some period and dissappears later then- i noticed this issue if the usb cable lenght is too long or not good quality like those Blue colored usb cables commonly supplied with most of the Chinese web suppliers. when I used my samsung or nokia phone cable such issues were solved. <br>if you cannot detect the nodemcu at all..evenin device manger in windows system then probably you will need appropriate drivers. I have given links to drivers used by me on my github page. I have tested those on win xp..win7 and win 8.1 pc...all work perfectly. please follow my videos on youtube about installation procedure. it is probably given in video of getting started with arduino nano... chip is same in both cases.. ch340 I guess.<br>
Hello, I have tried and tried to load my NodeMCU to the board manager according to your direction but the ESP COMM option does not appear in Board Manager section upon restart. Any suggestion? Let me know if you need any other info to help you understand my issue. Thanks.
<p>Are you stuck at Step 4 ? </p><p>if so, make sure you are putting correct link http://arduino.esp8266.com/stable/package_esp8266com_index.json in the arduino preferences. Which version of arduino IDE are you using ? Try first exactly 1.6.7 version like i have used. once it works on this, then you can upgrade your Arduino IDE to latest version. or try to go to 1.6.5 version. i have followed the steps given in my instructable on 3 different PCs and they have worked perfectly for WinXP, Win 8.1 and Win 7. </p>
Thanks a lot for your rapid reply. Pardon my ignorance but how can I roll back my IDE version from 1.6.11 to 1.6.7? The only way I can figure is to uninstall the IDE entirely but won't doing so lose my sketchbook?
I generally take a copy of my Arduino folder libraries n sketchbook folder. then install arduino. later you can put back libraries n sketchbook folders.
<p>Hi,</p><p>I'd like to connect NodeMcu to my wifi and then when someone presses the button connected to NodeMCU that it triggers Raspberry Pi's script which runs Pushbullet notification that someone rang the doorbell and then takes the screenshot of the camera.</p><p>Second part with RPi I've done in Python and it's working fine, but only when pressing the button which is connected to RPi, now I'd like to get it wirelessly via NodeMCU which would somehow trigger over the wifi the RPi.</p><p>Is that possible, and how would you do it?</p><p>Thank you! :)</p>
<p>I believe it should be possible to do what you said. I have not yet explored this further. You can try to send UDP data to rpi or use a web server on nodemcu and let rpi read it... these are just suggestions.</p><p>i have been able to connect rpi to nodemcu via udp..but still to be explored. In few weeks i will upload instructable on this. may be that might somehow help you.</p>
I also have a D1 that is having the same issue. Thanks again.<br>
<p><a href="http://arduino.esp8266.com/stable/package_esp8266com_index.json">http://arduino.esp8266.com/stable/package_esp8266c...</a></p><p>i cant install this...i am getting error downloading message !</p>

About This Instructable




Bio: A Researcher, an Engineer and an electronics enthusiast
More by TheElectromania:Quick Digital thermometer using cheap USB to TTL converter and  DS18B20 - WITHOUT Arduino or Raspberry Pi Digital thermometer on OLED display using ESP8266 ESP-12E NodeMCU and DS18B20 temperature sensor PIR Motion Detector With Arduino: Operated at Lowest Power Consumption Mode 
Add instructable to: