Installing MicroPython on the ESP32

 Installing MicroPython on the ESP32.

1. Preparation:

Install Python (version 3.x)

Install the esptool utility:

pip install esptool

Install the USB-UART drivers for your chip (e.g., CP210x or CH340)


2. Download the MicroPython firmware:

Go to the official website

Select the latest stable version (e.g., ESP32_GENERIC-20240222-v1.22.2.bin)


3. Connect the ESP32:

Connect the board via USB

Identify the COM port:

Windows: Device Manager → Ports (COM and LPT)

Linux/Mac: Run the command ls /dev/tty.*


4. Erase the flash memory:

esptool.py --chip esp32 --port <COM_PORT> eras_flash

Example for Windows:

esptool.py --chip esp32 --port COM3 eras_flash


5. Write firmware:

esptool.py --chip esp32 --port <COM_PORT> --baud 460800 write_flash -z 0x1000 <firmware.bin>

Example for Linux:

esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x1000 ESP32_GENERIC-20240222-v1.22.2.bin


6. Verification:

Install the terminal program:

pip install pyserial

Connect to the REPL:

screen <COM_PORT> 115200

or use Putty/Serial Monitor in the Arduino IDE.


7. First Run:

If the firmware has installed successfully, you will see:

MicroPython v1.22.2 from February 22, 2024; ESP32 module with ESP32
Type "help()" for more information.
>>>

To work with files, use:

Thonny IDE (recommended)


Example test script:

from machine import Pin
import time

led = Pin(2, Pin.OUT)

while True:
    led.value(not led.value())
    time.sleep(1)

Done! You can now develop MicroPython projects for the ESP32.

Комментарии