I tried to install NodeMCU on an ESP8266 with the help of my article from January 2015 but I had some problems to do so. So I write a new article with a new approach, which works today.
For the connection, we need a serial interface. I use an FTDI UM232R module for this. To define the numbers on the ESP-01 module I use this drawing I created:
You need at least three signals from your serial interface to the ESP-01 module. The signals are ground, RxD and TxD. The 3.3 V supply voltage comes from my programmable power supply. The updated connection list is shown above.
VCC -> 3V3 GND -> GND RST -> 3V3 CH_PD -> 3V3 URXD -> DB0 (UM232R) UTXD -> DB1 (UM232R) GPIO0 -> GND GPIO2 -> floating
The jumper JP1 on my UM232R module is set between Pins 1 and 2 which defines 3.3 V for the IOs.
Preparations for flashing NodeMCU on an ESP8266
First, we need the NodeMCU firmware. In the previous article, you could download a pre-built binary from the GIT repository. I didn’t found a pre-built firmware on the repository today, so we have to build our own. Luckily there is an easy online firmware builder: nodemcu-build.com.
You have to enter a real email address because you get your firmware download link via mail. I choose the master branch for my build and leave the default modules checked for a quick test. Then you have to click the “Start your build” button on the bottom of the page and wait until you got mail. I got two versions in the mail. One is labeled as an integer version and one as a float version. For this article, I’m using the integer one.
Flashing NodeMCU on an ESP8266
To flash the actual firmware I used a tool called nodemcu-flasher. I downloaded the 64bit version.
Use the following procedure:
- Connect your ESP-01 module to your serial interface
- Connect your module to a 3.3 V supply
- Set your GPIO0 to GND on power-up
- Set CH_PD to VCC for enabling the module
- Check that your serial interface is recognized by your OS
Now you can start the nodemcu-flasher. The tool will flash an integrated NodeMCU firmware by default, which can be outdated. Go to the “Config”-tab to select the new firmware you just created in the step before.
Go to the “Operation”-tab and press the “Flash (F)” button to start the flash operation. The AP MAC and STA MAC should display correct values. If not and the progress bar doesn’t move, turn your module off and on again to enable flash mode. You should wait until the progress bar is fully filled during the flash operation.
Check your firmware
After flashing we need to check if the firmware is working. First of all, turn off your ESP-01 module. Furthermore, remove GPIO0 from the ground so we can start the normal operational mode. Finally, power the module on again. Connect with your terminal software to the serial interface which connects to your module. The baud rate has to be 9600.
For testing purposes, I connected a red LED and a 470Ohm resistor in series to ground on GPIO2. In your terminal software, you set GPIO2 to an output. The GPIO2 has the IO pin defined to 4! Your terminal should show something like this:
NodeMCU custom build by frightanic.com branch: master commit: c8037568571edb5c568c2f8231e4f8ce0683b883 SSL: false modules: node,file,gpio,wifi,net,tmr,uart build built on: 2016-01-24 10:52 powered by Lua 5.1.4 on SDK 1.4.0 lua: cannot open init.lua >
So, now enter the following line to set the IO pin to an output:
The following command will write a 1 to our GPIO, as a result, we get a HIGH level on the GPIO:
If you write a 0 to the write function, you get a LOW level on the GPIO:
If you can control the LED with this commands, congratulations, your NodeMCU firmware works.
Here you can find other NodeMCU related posts.