MicroPython ESP32 minimal UART example
This example shows how to use UART on the ESP32 using MicroPython. In this example, we use UART1
which is mapped to pins GPIO9 (RX)
and GPIO10 (TX)
.
from machine import UART
uart = UART(1, 115200) # 1st argument: UART number: Hardware UART #1
# Write
uart.write("test")
# Read
print(uart.read()) # Read as much as possible using
Don’t know how to upload the file to MicroPython so it is automatically run on boot?
- To flash over USB, see How to upload files to MicroPython over USB/serial
- To flash over the network (with WebREPL already enabled), see How to upload files to MicroPython using WebREPL using webrepl_cli.py