Before diving into the NodeMCU with MicroPython we should know some key concepts of embedded programming such as flashing , firmware etc.
Development platforms for NodeMCU_ESP8266:
- ESPlorer
- LuaIDE
- Arduino IDE etc
Programming languages for NodeMCU_ESP8266:
- MicroPython
- Circuit python
- Lua scripting
- Arduino
- Mongoose
As we see NodeMCU uses different languages we need different firmware installed into it for different languages. Each language has its own firmware to be installed which acts as language translator.
What is Firmware ?
It is the generally lightweight machine-level translation of the code, permanently stored in the device’s memory and acts as an OS analogous setup for the embedded system. It starts execution as soon as you turn on the device.
How to install Firmware ?
You install firmware by flashing the specific firmware file. Note that Lua Default Firmware which Supports Arduino IDE.
Download the MicroPython file to flash in MicroPython visit here
Some steps to be followed to Run MicroPython on NodeMCU :
We will use ESPlorer IDE for coding NodeMCU
Download the ESPlorer Zip file and extract it from here
You need to install latest java on your Windows machine
Once you click on the above executable file you will see IDE like below:
Follow these steps to Open IDE :
- Port must be automatically detected there (If port is not detected then you have to install drivers from here )
- Click on Open to Check the firmware version of NodeMCU
- Click RST button on NodeMCU
Follow these steps flash the MicroPython firmware on NodeMCU ESP8266 :
- Unzip the Already downloaded MicroPython firmware
- Goto : NodeMCU-flasher-master > “Win32” or “Win64” > Release > Double Click on EPS8266Flasher
- New NODEMCU FIRMWARE PROGRAMMER window will open
- Now go to Config Tab Check that It should have 1st entry as “INTERNAL://NODEMCU” (You may have to search for binary files upload)
- GO TO: Operation Tab > Click on “FLASH(F)”
Blink an LED connected to the NodeMCU using MicroPython :
- Make a connection as shown below
- Connect the NodeMCU to the computer using USB
- Open ESPlorer
- Set the Baud_rate = 115200 ( The baud rate is the rate at which information is transferred in a communication channel)
- Go to settings >Firmware>MicroPython>Script
- Click on “Open” to Check the firmware version of nodemcu.
- Then click “RST” button on NodeMCU
- Write the following code and write it in the left black window of ESPlorer and save it with .py extension
import time
import machine
pin = machine.Pin(4, machine.Pin.OUT) #D4 pin
while True:
pin.on()
time.sleep(1)
pin.off()
time.sleep(1)
- Click on Send to ESP
You have successfully Blinked NodeMCU !