A Quick Start Guide to ESP32 Development: Bridging Cloud AI to the Physical World

A Quick Start Guide to ESP32 Development: Bridging Cloud AI to the Physical World

Introduction

Forgive me for starting a new project again; I will gradually update the previous ones, but I simply cannot contain my excitement to share this new toy with everyone. Without further ado, let’s get straight to the point.

Learning ESP32 development allows AI capabilities to transition from the cloud to reality. It acts as the “hands and feet” of the brain, transforming intelligent algorithms into tangible tools for perceiving and controlling the physical world. In the AI era, mastering this skill equips you with the ability to create “brain + plugins,” turning ideas into interactive, learning intelligent entities at a low cost.

What is ESP32?

Technical Positioning: SoC or MCU?

The ESP32 is more accurately positioned as a SoC, but it integrates the functionalities of an MCU. This can be understood as follows:

From a functional perspective, it is a SoC because it integrates the following on a single chip:

  • Two CPU cores (Xtensa LX6 microprocessor)
  • Memory
  • Wi-Fi, Bluetooth, and Bluetooth Low Energy
  • Various peripherals (GPIO, I2C, SPI, ADC, etc.)
  • RF unit

This high level of integration is a typical characteristic of SoCs.

From an application perspective, it is often used as a powerful MCU because developers can control its GPIO pins directly, running a single main program for embedded control, just like programming a microcontroller.

Simple Summary

The ESP32 is a highly integrated SoC centered around Wi-Fi and Bluetooth wireless connectivity, serving as a super microcontroller in embedded system development.

For software engineers, in layman’s terms: it is a remote server that can control devices.

Complete Tutorial for Developing ESP32-S3 Using VS Code and MicroPython on Windows

This tutorial is easy to understand; as long as you know how to use VS Code and Python, you can complete it in ten minutes.

Step 1: Install Necessary Software

1. Install VS Code

  • Visit https://code.visualstudio.com/
  • Download the Windows version and install it
  • Launch VS Code

2. Install Python

  • Visit https://www.python.org/downloads/
  • Download Python 3.8+ for Windows
  • Make sure to check “Add Python to PATH” during installation
  • Verify installation: Open Command Prompt and enter <span>python --version</span>

3. Install VS Code Extensions

Search for and install the following in the VS Code extension store:

  • Python (Official Microsoft extension)
  • MicroPico (for MicroPython development, optional)
  • Serial Monitor (for serial monitoring, optional)

Step 2: Install ESP32-S3 Development Tools

1. Install esptool (firmware flashing tool)

pip install esptool

2. Install ampy (file management tool)

pip install adafruit-ampy

3. Install rshell (interactive file management)

pip install rshell

Step 3: Prepare MicroPython Firmware

1. Download ESP32-S3 Firmware

  • Visit https://micropython.org/download/ESP32_S3/
  • Select the latest version of the ESP32-S3 firmware (e.g., <span>esp32s3-20240222-v1.22.2.bin</span>)
  • Download it to a local directory, e.g., <span>C:\micropython\</span>

2. Find the COM Port of ESP32-S3

  • Connect the ESP32-S3 to the computer via USB
  • Open Device Manager (Win+X → Device Manager)
  • Find the port number of the ESP32-S3 under “Ports (COM & LPT)” (e.g., COM5)

Step 4: Flash MicroPython Firmware

1. Erase existing firmware

python -m esptool --chip esp32s3 --port COM5 erase-flash

Note: Replace COM5 with your actual port number

2. Flash new firmware

python -m esptool --chip esp32s3 --port COM5 --baud 115200 write_flash -z 0x0 D:\esp32\ESP32_GENERIC_S3-20250911-v1.26.1.bin

Note: Replace COM5 with your actual port number, and the firmware path with the actual path

Step 5: Test Connection

1. Test REPL using PuTTY

  • Download and install: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
  • Open PuTTY, select “Serial”
  • Set the port (e.g., COM5) and baud rate 115200
  • Click “Open”, press the reset button on the ESP32-S3, and you should see the MicroPython prompt <span>>>></span>

2. Test basic commands

print("Hello ESP32-S3!")import machinemachine.freq()  # Check CPU frequency

Step 6: Configure VS Code Project

1. Create project folder structure

C:\esp32s3_project\├── main.py├── boot.py└── lib\    └── (store library files)

2. Create example code in main.py

from machine import Pin, Timerimport time
# Configure onboard LED (adjust pin number according to your ESP32-S3 development board)led = Pin(2, Pin.OUT)  # GPIO2 is usually the onboard LED
def blink_led(timer):    led.value(not led.value())
# Create a timer to blink the LED every 500ms
timer = Timer(0)timer.init(period=500, mode=Timer.PERIODIC, callback=blink_led)
print("ESP32-S3 MicroPython running successfully!")

Step 7: Manage Files Using Command Line Tools

1. Use ampy to upload files

# Upload main.pyampy --port COM5 put main.py
# Upload entire directoryampy --port COM5 put lib /lib
# Run fileampy --port COM5 run main.py

2. Use rshell for interactive file management

# Connect to device
rshell -p COM5
# Operate in rshell
ls /pyboardcp main.py /pyboardrepl  # Enter REPL mode

Step 8: Create Convenient Batch Scripts

1. Create upload script upload.bat

@echo off
echo Uploading files to ESP32-S3...ampy --port COM5 put main.pyampy --port COM5 put boot.pyecho File upload complete!pause

2. Create serial monitor script monitor.bat

@echo off
echo Starting serial monitor...python -m serial.tools.miniterm COM5 115200

Step 9: Advanced Development Configuration

1. Create VS Code tasks (.vscode/tasks.json)

{    "version": "2.0.0",    "tasks": [        {            "label": "Upload to ESP32-S3",            "type": "shell",            "command": "ampy",            "args": ["--port", "COM5", "put", "main.py"],            "group": "build"        },        {            "label": "Serial Monitor",            "type": "shell",            "command": "python",            "args": ["-m", "serial.tools.miniterm", "COM5", "115200"],            "group": "build"        }    ]}

2. Create launch configuration (.vscode/launch.json)

{    "version": "0.2.0",    "configurations": [        {            "name": "MicroPython REPL",            "type": "python",            "request": "launch",            "program": "${workspaceFolder}/main.py",            "console": "integratedTerminal",            "args": ["--port", "COM5"]        }    ]}

Step 10: Summary of Common Development Commands

# 1. File uploadampy --port COM5 put main.py
# 2. File downloadampy --port COM5 get main.py main_backup.py
# 3. List filesampy --port COM5 ls
# 4. Execute codeampy --port COM5 run test.py
# 5. Enter REPLrshell -p COM5 repl
# 6. Soft reset deviceampy --port COM5 reset

Troubleshooting

Common Issues and Solutions:

  1. Port not found: Check USB drivers and try different USB ports
  2. Upload failed: Ensure the device is not in REPL mode, try resetting the device
  3. Insufficient memory: Optimize code, use <span>gc.collect()</span>
  4. Import error: Ensure library files are correctly uploaded to the device

Useful Test Commands:

# Test in REPL
import osos.listdir()
import machinemachine.freq()
import gcgc.mem_free()

This tutorial covers the complete process from setting up the environment to actual development. It is recommended to follow the steps and ensure each step is successful before proceeding to the next.

Wishing you successful development! 🚀

Leave a Comment