Micropython ESP8266 implemented on nodemcu module step-by-step explanation. Micropython is an extension of python with libraries suited for ESP8266 module. It took us quite some time to understand the intricacies of ESP module. As soon as we kick started, we got fascinated with the fact that, we can program the ESP module with a python code. Henceforth, we have documented all the procedure to program micropython ESP8266. Hope this helps viewers to learn about the nuances of micropython ESP8266. This setup does not need or run on arduino IDE.
The setup explained here is quite simple and does not mandate arduino IDE. This procedure is assists python programmers to control and operate nodeMCU. Usually implemented for IoT based solutions. Micropython, inherently loaded with gamut of readily usable functions and procedures. This assists designers to focus more on the solution, rather than on the nuances of the hardware.
Micropython ESP8266 nodemcu:
You need 1 unit of nodemcu module
1 USB cable connector
A computer / laptop to run the program (with python installed)
- The procedure is done on a git environment (install git)
We received the nodeMCU modules from online shopping. It comes packed in an electrostatic pouch.
It is advisable to use electrostatic strap belts while handling these devices. But in case you want to avoid investing time and effort on electrostatic devices, you can ignore for now.
The connection of ESP8266 nodeMCU module is quite simple. All it needs is just an USB connector.
As soon as the USB wire is plugs in, a visible BLUE color light blink flickers on the PCB. This is an indication that the module you received should be working fine.
ESP8266 module comparison. The nodeMCU modules comes in 2 flavors of USB driver. One with a CP2102 driver and the other with CH340 driver.
The driver ICs are the interface chip for the USB(master) and UART protocol. However, ESP-8266 main core module is same in both the parts.
Micropython ESP8266 nodemcu programming steps:
Step 1: Download the ESP bin file and extract to a directory location
Step 2: Download software tool to flash esp8266-20191220-v1.12.bin file to nodeMCU
2a) $ pip install esptools (this installs the necessary tool to flash the binary to nodeMCU)
2b) $ esptool.py.exe –port com3 erase_flash (this erases the internal flash memory)
2c) $ esptool.py.exe -p com3 -b 115200 write_flash –flash_size=detect 0 /e/TOOLS/ESP-Node-MCU/esp8266-20191220-v1.12.bin
- Flashes the binary to nodeMCU
- Via COM3 port
- @ baud 115200 bps
- The bin file path /e/TOOLS/ESP-Node-MCU/esp8266-20191220-v1.12.bin
Step 3: Microython code to blink on board LED
Step 4: Python method to access the nodeMCU unit from computer
4a) $ pip install adafruit-ampy
4b) ampy essential commands:
- $ ampy -p com3 -b 115200 ls (directory listing of root)
- $ ampy -p com3 -b 115200 put example_led_blink.py (loads the file on ESP8266 module)
- $ ampy -p com3 -b 115200 run example_led_blink.py (runs the file on the module)
We will be publishing more advanced and implementable micropython codes.