In this tutorial we gona make the NodeMCU devboard to work and create a simple led blinking example.
Let’s see what components do we need:
1 x NodeMCU V3 Lua devboard ~3-4 USD (ebay link)
1 x Breadboard ~2 USD (ebay link)
2 x breadboard jumper wires (f-m) ~2-4 USD 3 x 40pcs (ebay link)
1 x micro USB cabel (most phone data cabel is ok for it) ~1 USD (ebay link)
1 x 10K resistor ~1 USD 50 pcs (ebay link)
1 x LED ~1 USD 100 pcs (ebay link)
I only bought 3 pcs NodeMCU V3 because I already own the other components from other arduino projects.
Before we start, you need to install the proper CH340 driver for your system.
Windows 8, 8.1, 10 link
Windows 7 link
At the first time when I connected to my PC nothing happened, because the USB cable what I used was an only charger cable, and can’t be used as a data sync cable… spent some time till I found the problem. Switched the cable to another one and after that everything was ok.
Flash firmware and connecting IDE
I needed to flash firmware for all three device because they wasn’t boot properly.
Flashing the firmware is really simple just start the NodeMCUFlasher. select the proper COM port and click on flash. If the progress bar reach the end a green symbol will show up on the left-bottom corner of the window, indicating it’s done.
It’s worked fine for me with the default settings, but many people suggest to reduce the baudrate to 9600 it will be a bit slower but more secure. I think if there were no error during the flash and the board boot up no need to reduce it.
Start ESPlorer and select the proper COM port, then click open. Sometimes the connection is hang with this screen and nothing happen:Just hit the reset button on the NodeMCU and it will connect nicely.
Put the things together
Connect D2 to the breadboard + and the ground to the -, put the resistor between the + and any inside line then put the LED longer pin to the same line as the resistor and the shorter pin to the -.
Create the program
Here is our code:
pin=2 gpio.mode(pin,gpio.OUTPUT) aux=0 function blink () if aux==0 then gpio.write(pin,gpio.HIGH) aux=1 else gpio.write(pin,gpio.LOW) aux=0 end end tmr.alarm(0, 500, 1, blink)
Save it as init.lua and then click on the save to ESP button, if it’s finished the program start to run immediately, if not you need to reset.
I hope it’s helped you to getting started with NodeMCU, I will create additional posts with more stuff as I have time.