How to Install MicroPython on ESP32 Tutorial

How to Install MicroPython on ESP32 Tutorial

In this how to install micropython on esp32 tutorial, we will download the official micropython binaries and flash them to esp32. Then verify the working of micropython on esp32.

What You Need:

  1. ESP32 Module: This is the hardware you'll be programming.
  2. Micro USB Cable: To connect ESP32 to your computer.
  3. Computer: With internet access to download necessary files and software.

Steps to install micropython on esp32:

Step 1: Download the Firmware

  1. Go to the MicroPython Website: Visit the MicroPython downloads page.
  2. Select Firmware for ESP32: Look for the section labeled 'Firmware for ESP32 boards'.
  3. Download the Latest Version: Click on the link to download the latest firmware (.bin file) to your computer.

Step 2: Install esptool.py

  1. Install Python: Make sure you have Python installed on your computer. You can download it from the Python official website.
  2. Open Command Line: Open Command Prompt (Windows) or Terminal (macOS/Linux).
  3. Install esptool: Type pip install esptool and press Enter. This tool is used to communicate with the ESP32 chip. Link to documentation

Step 3: Connect ESP32 to Computer

  1. Plug in Your ESP32: Use the micro USB cable to connect the ESP32 to your computer.
  2. Check the COM Port:
    • On Windows, open Device Manager and look under 'Ports (COM & LPT)' to find out which COM port the ESP32 is connected to.
    • On macOS/Linux, open Terminal and type ls /dev/tty.* to list the devices connected.

Step 4: Erase the Flash

  1. Open Command Line: If you closed it earlier, open it again.
  2. Go to the ESP32 Port: Type esptool.py --port COMx erase_flash (replace 'COMx' with the correct COM port).
  3. Execute the Command: Press Enter to erase the existing flash on the ESP32.

Step 5: Flash MicroPython

  1. Locate the Downloaded Firmware: Find where you saved the .bin file (that you downloaded in step 1)
  2. Flash the Firmware: Type esptool.py --port COMx --baud 460800 write_flash -z 0x1000 path-to-your-downloaded.bin (replace 'COMx' with your COM port and 'path-to-your-downloaded.bin' with the path to the downloaded .bin file).

Step 6: Verify Installation

Verify installation using Thonny

One simple way to verify the installation is install thonny and select your COM Port or tty connected device from settings. You will see the >>> sign on thonny's shell indicating that micropython is installed.

Verify installation using Putty on windows:

  1. Install a Serial Terminal: Install a program like PuTTY or use the built-in terminal for communication. Open the serial terminal, select the COM port, set the baud rate to 115200, and connect.
  2. Check for MicroPython Prompt: You should see the MicroPython prompt >>>. If you see this, congratulations, MicroPython is installed!

You've successfully installed MicroPython on your ESP32. Enjoy! To see what you can do using micropython, I have a tutorial to host a website using micropython here