Introduction: The Super Easy Micropython ESP8266 Windows Guide. No Guesswork Required!
So you want to check out Micropython, but aren't sure where to begin? Confused by the many guides, boards, and instructions out there that seemingly only work for everyone but you? Want a guide to take ALL of the guesswork out of the equation for you, and show you step by step where to start?
Great - because you found one! BOOM!
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 optimised to run on microcontrollers and in constrained environments. The differences between Micropython and the regular Python 3 are so small and meaningless, that it's not really worth getting into. With that out of the way, what are we gearing up for?
With Micropython & this tutorial, we'll be able to:
- Use Python on freggin' microcontrollers (arduino devices, etc)!
- Use a python interpreter in a web browser or from a program to change code ON THE FLY with your creations, no compiling necessary!
- Connect to your device WIRELESSLY via a broadcasted SSID! WHAT!? CRAZY!
Let's get started!
Step 1: Materials Needed
To take the guesswork out of which guide to use or what instructions to use, we're going to work with a single board - the NodeMCU 12-E. We'll be referencing this board and it's instructions for the entirety of this particular instructable. If you're using a different board, I will list some other tutorials you may want to follow at the end of this guide.
Things we'll need:
Step 2: Install + Configure Python 2.7
Unfortunately, the tool we need to flash the appropriate binary on the NodeMCU 12E ESP8266 board for Micropython only works with Python 2.7.x (not the latest Python 3.x). So, we'll need to install it and make sure it works.
- Download python 2.7 here and begin the installation
- Install python somewhere easy to find. I choose root C. We'll need to access the folder to place some files and scripts later. (check screenshot)
- On the next screen, be sure to add python.exe to PATH. This will be required for later. (check screenshot)
- Once you've installed it successfully, check that it's working right by going to a command prompt (Run --> CMD, or Windows Key + R --> CMD) and typing 'python'. It should return the version installed (screenshot).
Great! Now we'll need to install the thing that will actually do the flashing - esptool.
Step 3: Install Esptool
From a command prompt, we'll need to go into our installed python 2.7 directory.
We'll need to type:
- cd /
- cd Python27 (or whatever directory you installed it to)
- cd Scripts
- pip install esptool
Check the screenshot for a visual of the commands and the output of the install.
esptool is a Python-based, open source, platform independent, utility to communicate with the ROM bootloader in Espressif ESP8266.
Step 4: Connect to Board + Install Micropython
The moment of truth has arrived!
Now we'll hook up the board and flash it with the binary to run Micropython! :-)
- Plug your USB cable into the NodeMCU board, and then into your computer.
- Go into device manager and confirm what port your device is on. We'll need this information later. I'm on COM port 3 (screenshot).
- Download the micropython ESP8266 code I've conveniently hosted for you on my github, and place it in your python/Scripts directory from earlier (screenshot).
- Place the NodeMCU board into bootloader mode by holding the flash button, pressing the RST button, then releasing the flash button. You'll see the blue light briefly flash once when you've done this (screenshot).
- Open a command prompt, and return to the scripts directory.
- Run the following command, keeping in mind to substitute COM3 with YOUR particular COM port:
esptool.py --port COM3 --baud 460800 write_flash --flash_size=detect 0 esp8266-20161110-v1.8.6.bin
Congratulations! You've successfully flashed Micropython onto a microcontroller! AWWW YESS!!!
Now it's time to access it, and enable easy web access!
Step 5: Connect Using PuTTY + WebREPL
- Unplug and plug your NodeMCU board back into USB. This should let the code compile and work properly after flashing.
- Open up PuTTY. Use a serial connection to your COM port, with a baud rate of 115200. You may want to save this for quick access later on. (check screenshot)
- Once we've got our command prompt, we should be at the interpreter. AWESOME! Now we can run and do all kinds of crazy cool python stuff right from the command line!
- Let's give ourselves the capability to control it via the web! type import webrepl_setup in order to start the WebREPL daemon on startup. type E to enable on boot, then type y to change the default password. Use something you'll remember, but strong enough to keep others from guessing. Reference the screenshot for help.
- Unplug and plug your NodeMCU board back in again.
- We can now see a new SSID being broadcast. It's our Micropython-enabled NodeMCU board! WHOA! Connecting to this right now will cause us to lose connectivity, so just make note of it. The default password is: micropythoN (capital N at the end)
- To save space on the board, the required files to connect to our web interface must be downloaded on your local machine. Go here to download the webREPL files. Extract them somewhere you can find them, then open up webrepl.html
- Go ahead and connect to the Micropython SSID with the micropythoN password. Be careful, you'll lose internet connectivity at this point! Make sure you have these instructions loaded and ready to go in another window.
- Go to your webrepl browser window you opened up previously. You should see the ws://192.168.4.1:8266/ address by default in the connect window. Click connect, and enter the password you set earlier. You now have access to your Micropython-enabled ESP8266 board via wireless! BLACK MAGIC! (screenshot)
Step 6: AWESOME IT WORKS....Now What?
You have access to an amazing microcontroller and all it's powerful sensors + actions in REAL TIME! You can access it over the web from your couch in another room.
Want to dynamically draw on LED displays? How about control a servo motor? Why not some kind of funky watch? It's all possible!
I highly recommend you check out the Micropython guides over at Adafruit. You will learn the intricacies of Micropython, as well as discover some easy projects to get you started. Most of these projects are headed by the fabulous Tony DiCola, a fantastic and prolific Micropython communicator and expert. Stop reading this - get going! :)
Step 7: Non-Specific Guides + Resources
- A guide for boards other the NodeMCU board can be found here: https://learn.adafruit.com/micropython-basics-how...
- The official Micropython.org guide to flashing your ESP8266 can be found here: https://docs.micropython.org/en/latest/esp8266/es...
- To download the binary to flash the NodeMCU 12E board back to it's original state, download this file from my github.

Participated in the
Epilog Contest 8

Participated in the
Arduino Contest 2016
17 Comments
Tip 2 years ago
I don't know if it was the same problem with "giberish" in terminal and constantly blinking diode after flashing micropython I have, that others mentioned there, but I fixed this by erasing flash ram first prior to flashing firmware itself, by doing "esptool.py --port erase_flash ". The reason why it is needed explained in section "SDK Init Data" there https://nodemcu.readthedocs.io/en/release/flash/
It helped for me.
Question 4 years ago on Step 6
I successfully flashed micropython to my nodemcu. but when connecting to PuTTY, I am not able to type anything but get gibrish when press reset button.
Answer 2 years ago
You just set Serial Connection Flow Control to None in Putty. (see image).
I hope this help you. :-)
Answer 4 years ago
SOLVED!!!!
I was having the same problem.... stayed up all night flashing, re-flashing to no avail. I was trying to figure out what I was doing wrong but nothing I did helped. I still got the gibberish on the output, I have 2 of these chips and I connected the other one and POOF, there it was, it worked!!! I was using a different version of the esp8266, You have the older version of the 8266 board. Get the updated version or find another program that will work. Hope this helps
Reply 3 years ago
it seems the reason is in ch340 usb-driver chip. I was having the same problem but with d1 mini board
4 years ago
I programmed a D1 Mini. All went well and as described.
Now I get the Blue LED flashing, and when I connect to COM3 at 115200, I get giberish.
I tried other baud rates. Tried an up-to-date firmware with the same result!
Any ideas on what I'm doing wrong? I'm all out of ideas :(
Reply 3 years ago
I have the same trouble. in baudrate - 74880 - repeat:
"
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x40100000, len 32024, room 16
tail 8
chksum 0x37
load 0x3ffe8000, len 1092, room 0
tail 4
chksum 0xce
load 0x3ffe8450, len 3000, room 4
tail 4
chksum 0x16
csum 0x16
#0 ets_task(40209c10, 31, 3ffe9020, 4)
rf_cal[0] !=0x05,is 0x00
"
3 years ago
It seems, on my machine, webrepl is very touchy. My machine mostly choke trying to connect to the mcu. I've tried both an esp32 wifi kit and a nodemcu 12E. Using esp8266-20190529-v1.11.bin for the nodemcu and esp32-20191024-v1.11-498-gf69ef97f2.bin for the ESP32.The noemcu broadcasts and I can connect, but windows has this habit if there is no internet, he drops it. The ESP32 Doesn't seem to broadcast at all.
5 years ago
Whoa that was painful - but got there in the end! Having failed several other methods to install the bin file, I succeeded with NodeMCU-PyFlasher-2.0 :-)
Now, the fun begins...
6 years ago
You wrote: "We can now see a new SSID being broadcast. It's our Micropython-enabled NodeMCU board! WHOA!"
Sorry, but all I can see, when I connect ptty, is that micropython has started:
">>>"
Furthermore no connection is possible on ws://192.168.4.1:8266/. Only the message DSICONNECTED is written. Nothing more. What do I do wrong??
Best regards
Eric
Sorry, but I cannot see
Reply 6 years ago
Does your SSID say MicroPython or ESP8266? Make sure you've loaded your binaries correctly, and have used the com port appropriate for your device to do so. For me, it was COM3. For you , it may be something different!
Reply 6 years ago
I used this device : see photo
Reply 6 years ago
Make sure you've imported WEB REPL on the device from PuTTY
import webrepl_setup
Reply 6 years ago
I did so! When I started the webrepl_setup -> I have to define a new password -> then after I had done -> nothing happens.
6 years ago
Any tips for porting Micropython to a different embedded devices?
Reply 6 years ago
Absolutely! If you check step 7, you'll see in #1 a guide to put Micropython on other boards :) Cheers!
6 years ago
Here are the pictures of my steps: