MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimized to run on microcontrollers and in constrained environments.
esptool is a command line utility to communicate with the ROM bootloader in Espressif ESP8266 & ESP32 microcontrollers.
Picocom is a minimal terminal emulation program that is great for accessing a serial port based Linux console.
REPL stands for Read Evaluate Print Loop, and is the name given to the interactive MicroPython prompt that you can access on the ESP8266. Using it is the easiest way to test out code and run commands.
Step 1: Install esptool.
pip3 install esptool
We are installing the python3 version of esptool.
Step 2: Identify the USB port number on which the NodeMCU is running.
watch -d "ls /dev/ttyU*"
Disconnect the NodeMCU, then reconnect it. The port number on which the NodeMCU is connected to is highlighted.
Step 3: Change permission for the port on which NodeMCU is connected.
sudo chmod 777 /dev/ttyUSB0
USB0 is the USB port number identified in last step.
Note: You will need to perform this action every time you connect the NodeMCU to your computer.
Step 4: To erase the flash memory of the NodeMCU.
esptool.py --port /dev/ttyUSB0 erase_flash
Step 5: To download and save the latest firmware for NodeMCU.
Step 6: Change to the downloaded folder of firmware, and run the following command to burn it on to NodeMCU.
esptool.py --port /dev/ttyUSB0 --baud 115200 write_flash --flash_size=detect 0 esp8266-20190529-v1.11.bin
NodeMCU blinks indicating that the firmware is being installed successfully.
Note: The version for the firmware may vary.
Step 7: Get a MicroPython REPL prompt (REPL over serial port).
picocom /dev/ttyUSB0 -b115200
The baudrate of REPL is 115200.
Once you have made the connection over the serial port you can test if it is working by hitting enter a few times. You should see the Python REPL prompt, indicated by >>>.
Step 8: TEST!
The command should give the output: "hello esp8266!"
Note: To exit picocom press CTRL+a followed by CTRL+q.
Please do let us know if we are missing any topic or you want us to elaborate any topic, comment below and subscribe to be updated.