In this Tutorial we are going to now how to get started with MicroPython on ESP8266 boards by flashing and loading the MicroPython firmware on them. This tutorial is going to be in step by step process so that it would be easier for you you to understand and remember it for a long time. As ESP8266 as an inbuilt WiFi we can grab the advantages of it in communication. Before starting the tutorial let’s learn about what are the requirements below.
Table of Contents
Requirements:
- An ESP8266 board like nodemcu wemos D1 or any
- A Windows PC With Python installed
- Few software’s needed and their download links are provided below
Step1: Get started with Python installation
As the first step we need to install python to use the ESP tool which helps us to 2 flash and load MicroPython firmware on our ESP8266 board if your PC already has python installed skip this step. To download Python visit python.org and download the executable file for your operating system.
After downloading install it and set the path in environment variables through the advance system settings of your PC properties.
Add the path of the python in the path section of system variables in the environment variables by default it is located at
C:\Users\<yourusername>\AppData\Local\Programs\Python\Python38-32\
Tip: If you dont know python path simply type the below code on command prompt
where python
And also add the path of the pip to the environment variables found at
C:\Users\<yourusername>\AppData\Local\Programs\Python\Python38-32\Scripts
If you don’t know how to do that click on the below tutorial link.
Tutorial in how to install latest python on your windows pc.
After this to check whether everything is installed correctly open command prompt and type the below line of code to get the version of the python if installed.
python --version
so it displays the python version which you had installed. if it doesn’t display the version check the path and correct it.
Step2: Install esptool
To install esptool open command prompt and type the below command and make sure you need to connect to working internet to download the files.
pip install esptool
Step3: Erase the flash of the ESP board
Before installing the MicroPython firmware on board we need to erase the complete flash memory on the board to get the clean installation.
Connect the ESP8266 board through the USB cable to the PC and run the following command to erase it
esptool.py --port /dev/ttyUSB0 erase_flash
here replace the “/dev/ttyUSB0″ with the port as we are using windows PC go to device manager and check the port of the board which looks as COMX.
Related Article: Raspberry Pi Pico ADC with MicroPython example
Step4: Download the microPython firmware for ESP8266
Download the latest MicroPython firmware for your board through the following link which is in .bin format.
Latest generic ESP8266 MicroPython firmware : here
Step5: Installing or flashing the Firmware on ESP8266
Now set the path of the command prompt to the path where firmware had downloaded. by default it will be saved in downloads folder so run the below command
cd downloads
To flash or install the firmware run the following command below
esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 esp8266-20191220-v1.12.bin
in the above code we need to change 3 values
- port: /dev/ttyUSB0 –> COMX
- baud: 460800 –> 115200 (default baudrate of ESP8266)
- filename: name of the file you had downloaded
Example:
esptool.py --port COM6 --baud 115200 write_flash --flash_size=detect 0 esp8266-20191220-v1.12.bin
After typing the above command hit enter to start flashing the MicroPython on the ESP8266, it takes few seconds and that’s it your development board is ready to run MicroPython.
To learn how to upload the MicroPython code to the Development board read the below article.
How to upload and run the Python code using uPycraft.