Installing and getting started with MicroPython on a ESP8266

The ESP8266 is an amazing microcontroller that includes a Wifi chip, for a very low price (about $15 for two on Amazon). It offers enough resources to make it the ideal microcontroller choice for most Internet of Things projects.

There are several ways to program it, including but not limited to, pseudo-C++ with the Arduino IDE, LUA scripts or MicroPython. In this tutorial we will learn how to set up the ESP8266 with a MicroPython firmware, making it possible to run MictoPython scripts.

This tutorial is based on a NodeMCU version of the ESP8266, or any version that has a serial to USB adapter. It is also fine if you build it yourself, as long as you have serial access to the device. You can find a 2-pack of the NodeMCU below:


The first step is to install It’s a very useful tool that will help us interact with the flash memory of the ESP8266. We’ll use it to erase the flash memory, and then flash the firmware on the board. Install it by running:

Download the CP2102 driver

This driver is the one used by the NodeMCU boards, and you can download it here. If you’re using another serial to USB adapter, you don’t need to install this driver, instead use your adapter’s driver.

Find the ESP8266 in the serial devices

To find which device in /dev corresponds to your ESP8266, follow those steps:

  • Connect the esp8266 via USB
  • Your device will be named /dev/tty.something. If you can’t find it easily:
    • Unplug the module and type ls -l /dev > log_before
    • Plug the module and type ls -l /dev > log_after
    • Get the difference between those 2 files by typing diff log_before log_after
    • For  example:

In this case the device name is /dev/tty.SLAB_USBtoUART. You can ignore the corresponding cu.* device. Keep this device name in mind, as we’ll need it in the next steps.

Install the MicroPython firmware

Download the latest MicroPython firmware here. Once it is downloaded, connect the ESP8266 to the USB port of your computer, and erase its flash memory:

Now flash the MicroPython firmware you just downloaded (replace the filename accordingly):

Note that the argument -fm dio 0 is only needed with some boards. I had to include it or the firmware would not flash correctly. You can try without it first, and if it fails add the option.

Next steps

Once the firmware is flashed, the ESP8266 should act as a Wifi access point, broadcasting a SSID with the format MicroPython-******, where the stars are a part of the MAC address of the module. If you don’t see this SSID in the list of networks on your computer, the firmware most likely failed to flash. Feel free to leave a comment below to ask for help!

You can now access the MicroPython prompt (also called Read Evaluate Print Loop or REPL). It uses a baud rate of 115200, and you can use screen as a serial terminal on Linux or Mac OSX:

To exit screen, type Ctrl+A , then : (colon), then type quit and enter.

For Windows users, you can use a terminal emulator such as RealTerm.

Once you are connected to the ESP8266, type enter a few times, and a prompt (“>>>”) should appear. You can now type any MicroPython command.

More content?

  • If you’re interested in IoT, be sure to check our tutorial on how to install Mosquitto on a Raspberry Pi! Mosquitto is an ideal MQTT broker for any IoT application, and is very often used to interconnect ESP8266 devices.
  • For more Python tutorials, check our Python articles!
  • You can find more microcontrollers tutorials on our Microcontrollers page.
  • And to be sure to receive our future articles, subscribe to our newsletter below!

Be the first to comment

%d bloggers like this: