Do you like this post? Writing posts, developing libraries and programming online font creators is actually hard work. I order most of my electronics from a Chinese website called Banggood. It is save and the items usually arrive in good quality. With every order you do there by following this link you are supporting the blog. Thank you!
You will be programming the ESP8266 from the Arduino IDE. Since Version 1.6.4 the IDE can be easily extended to program other boards the “normal” Atmel chips found in the Arduino boards. And that is exactly what we are going to do in order to program the NodeMCU V1.0. Before we start I would like to point out that an improved version of this guide is also available as eBook for Kindle. Buy now!
1. Download and Install the Serial Diver
To program the NodeMCU V1.0 your development platform (PC, Mac, Linux) needs to detect the CP2102 Serial-To-USB adapter. If your platform does not come with this driver you can download and install it from here: https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspxUPDATE: it seems that there are different versions of the NodeMCU produced. Some of them use the CH340 chip for serial-to-usb conversion. If you got one of those you can find the driver here:
Go to https://www.arduino.cc/en/Main/Software and download the latest version. Now pick the version matching your operating system. For Mac OS X for instance you download a ZIP file which you then have to extract. Take the extracted application “Arduino” and move it to your Applications folder.
For Windows you have the option between an executable installer and a ZIP file. The ZIP file might be the better option if you do not have administrator permissions on your system. The installer on the other hand can put the libraries in the proper places.
3. Install the ESP8266 tool chain
A tool chain is the set of tools that lets you compile and create binaries for a certain platform. Since we want to create binaries for the ESP8266 we need a different tool chain than the one that comes with the plain vanilla Arduino IDE.
Now go to Tools > Board: … > Boards Manager…, search the ESP8266 board and click install
Get a coffee and wait until it finishes
4. Selecting the Correct Board
Now that you installed the tool chain for the ESP8266 you have to tell the IDE to use it. Go to Tools > Board: * > NodeMCU 1.0 (ESP-12E Module)
5. Setting the Correct Port
You will program the NodeMCU through the USB connection. For your PC or Mac this interface looks like a serial connection (see paragraph about the driver). If everything worked well and your operating system could detect the NodeMCU V1.0 as serial device, it should show up in the Menu under Tools > Port. On my Mac the device is called /dev/cu.SLAB_USBtoUART
If you cannot see a device that looks like the NodeMCU, try to unplug the ESP module and re-plug it after a few seconds. If that doesn’t help consider restarting your computer… Make sure that you installed the driver as mentioned in paragraph 1.
6. Testing the Setup: Wifi Scanner
Thanks for bearing with me until we come to the really cool part. We are going to run our first program on the NodeMCU! In the Menu go to File > Examples > ESP8266Wifi and select WiFiScan
A new window will open up. This window is your current project and is also called a “Sketch”. To transfer this sketch to the NodeMCU V1.0 click on the green circle that contains an arrow. If everything went well this will compile the sketch and upload the binary to the ESP. If everything worked well it will look like this:
If everything worked well, click on the magnifying glass on the top right of the window. This is the serial console that you can use to see output from the NodeMCU module or also to send commands to the device. Make sure that the baud rate is set to 115200. This rate is also set in the example code and if you have a different setting the ESP will talk with a different speed than your PC listens. This will result in strange characters… My output looks like this:
If you see something similar: congratulations! You have just set all the preconditions to run the WeatherStation code.