yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
ESP32 Core Board📖
1. ESP32 Introduction
  • 1. ESP32S3 Overview
  • 2. Environment Setup Introduction
  • 3. Dev Board Introduction
2. ESP-IDF Development Tutorial
1. Before Development
  • 1. Environment Setup (Windows)
  • 2. Environment Setup (Linux)
  • 3. Build and Flash
2. Basic Peripherals
  • 1. LED Control
  • 2. Button Detection
  • 3. Peripheral Interrupts
  • 4. ESP_TIMER
  • 5. GPTIMER
  • 6. Watchdog Timer
  • 7. DMA
  • 8. ADC
  • 9. PWM Breathing LED
  • 10. RGB LED Effects
3. Serial Communication and Storage System
  • 1. Serial UART Communication Experiment
  • 2. I2C_OLED Display Experiment
  • 3. SPI Bus Communication Experiment
  • 4. PSRAM External Memory Experiment
  • 5. Flash Read and Write Experiment
  • 6. USB Emulated Mass Storage Experiment
4. FreeRTOS operating system
  • 1.FreeRTOS Core Concepts Theory
  • 2.Task Creation and Management
  • 3.Queue
  • 4.Binary Semaphore
  • 5.Mutex
  • 6.Event Groups
  • 7.Software Timer
  • 8.Task Scheduler
  • 9.Low Power Mode
  • 10.Deadlock
  • 11.Priority Inversion
5. Network Protocols and Wireless Communication
  • 1. WIFI Network Basics
  • 2. WIFI STA Mode
  • 3. WIFI AP Mode
  • 4. UDP Client Experiment
  • 5. UDP Server Experiment
  • 6. TCP Client Experiment
  • 7. TCP Server Experiment
  • 8. Socket Programming Basics
  • 9. HTTP Client Experiment
  • 10. HTTP Server Experiment
  • 11. MQTT IoT Communication Protocol
  • 12. WIFI OTA Upgrade
  • 13. Bluetooth Fundamentals
  • 14. Bluetooth Slave Mode
  • 15. Bluetooth Master Mode
6. Audio Applications
  • 1.I2S Microphone Recording and U-Disk Playback
  • 2.I2S Audio Playback Experiment
  • 3.Repeater Experiment
7. Xiaozhi AI Voice
  • 1. Burn Xiaozhi Firmware
  • 2. Network and Configuration
  • 3. AI Agent Settings
  • 4. Program Analysis
  • 5. Free Chat
3. Arduino Development Course
1. Before Development
  • 1. Environment Setup
  • 2. Build and Flash
2. Basic Peripherals
  • 1. LED Control
  • 2. Button Detection
  • 3. Peripheral Interrupts
  • 4. ESP_TIMER
  • 5. GPTIMER
  • 6. Watchdog Timer
  • 7. ADC
  • 8. PWM Breathing LED
  • 9. RGB LED Effects
3. Serial Communication and Storage System
  • 1. Serial UART Communication
  • 2. I2C OLED Display
  • 3. SPI Bus Communication
  • 4. Flash Read and Write
  • 5. USB Emulated Mass Storage
4. Network Protocols and Wireless Communication
  • 1. WIFI Network Basics
  • 2. WIFI STA Mode
  • 3. WIFI AP Mode
  • 4. UDP Server Experiment
  • 5. UDP Client Experiment
  • 6. TCP Client Experiment
  • 7. TCP Server Experiment
  • 8. HTTP Client Experiment
  • 9. HTTP Server Experiment
  • 10. MQTT IoT Communication Protocol
  • 11. WIFI OTA Upgrade
  • 12. Bluetooth Fundamentals
  • 13. Bluetooth Slave Mode
  • 14. Bluetooth Master Mode
5. Audio Applications
  • 1.I2S Microphone Recording and U-Disk Playback
  • 2.I2S Audio Playback Experiment
  • 3.Repeater Experiment
4. MicroPython Development Course
1. Before Development
  • 1. Environment Setup
  • 2. Build and Flash
  • 3. Thonny IDE
2. Basic Peripherals
  • 1. LED Control
  • 2. Button Detection
  • 3. Peripheral Interrupts
  • 4. TIMER_IT
  • 5. Watchdog Timer
  • 6. ADC
  • 7. PWM Breathing LED
  • 8. RGB LED Effects
3. Serial Communication and Storage System
  • 1. Serial UART Communication Experiment
  • 2. I2C_OLED Display Experiment
  • 3. SPI Bus Communication Experiment
  • 4. Flash Read and Write Experiment
  • 5. Print Storage
4. Network Protocols and Wireless Communication
  • 1. WIFI Network Basics
  • 2. WIFI STA Mode
  • 3. WIFI AP Mode
  • 4. UDP Client Experiment
  • 5. UDP Server Experiment
  • 6. TCP Client Experiment
  • 7. TCP Server Experiment
  • 8. HTTP Client Experiment
  • 9. HTTP Server Experiment
  • 10. MQTT
  • 11. Bluetooth Fundamentals
  • 12. Bluetooth Slave Mode
  • 13. Bluetooth Master Mode
5. Audio Applications
  • 1. I2S Audio Playback Experiment
  • 2. Repeater Experiment
Download
  • Code
  • Hardware_Info
  • 3D_Model_File
  • Software_Tools
  • VMware
  • VM_File
Download ZIP

Welcome to ESP32 Core Board repository

1. Serial UART Communication Experiment

Serial UART Communication Experiment


Serial UART Communication Experiment1. UART Communication Overview2. Core Concepts2.1 What is UART2.2 UART Parameter Selection2.3 Core API3. Hardware Dependencies4. Project Architecture and Flow5. Source Code Details5.1 UART Initialization5.2 Transmit and Receive5.3 Main Loop6. Operation Procedure6.1 Flashing and Running6.2 Serial Output Example6.3 Expected Behavior6.4 Verification Method7. Common Issues


1. UART Communication Overview

UART (Universal Asynchronous Receiver/Transmitter) is a serial communication protocol that only needs two wires, TX (transmit) and RX (receive), to achieve bidirectional data transfer.

In this experiment, machine.UART is used to configure UART1 of the ESP32-S3, continuously sending a string at 115200 baud and performing loopback reception.

Typical application scenarios:

ApplicationExample
Debug outputSerial terminal, log printing
Module communicationGPS, Bluetooth module, 4G module
Device interconnectionData exchange between MCUs
Sensor readingsSerial sensors (PM2.5, temperature/humidity, etc.)

2. Core Concepts

2.1 What is UART

UART converts parallel data into a serial bit stream, transmitted bit by bit according to the frame format:

Start bit + Data bits (5~8) + Parity bit (optional) + Stop bit (1/1.5/2)
  │            │                  │                      │
  ▼            ▼                  ▼                      ▼
 1bit       8bit (LSB)         0/1bit                  1bit

The common format 8N1 = 8 data bits, no parity, 1 stop bit (MicroPython default).

2.2 UART Parameter Selection

ParameterValue in this experimentDescription
PortUART1Avoids UART0 (occupied by the REPL system)
Baud rate115200Standard rate, compatible with most devices
TX pinGPIO10Transmit data line
RX pinGPIO11Receive data line
Data bits8 (default)8 data bits
ParityNone (default)No parity

ESP32-S3 has 3 UARTs: UART0 (occupied by REPL), UART1 and UART2 (available to users).

2.3 Core API

​x
from machine import UART, Pin
​
uart = UART(1, baudrate=115200, tx=Pin(10), rx=Pin(11, Pin.IN, Pin.PULL_UP))  # Create UART, RX pull-up
uart.write(b'hello\r\n')                          # Send byte string
buf = uart.read(255)                               # Read up to 255 bytes
data = buf.decode('utf-8').strip()                 # Decode into a string

3. Hardware Dependencies

GPIOPeripheralModeDescription
10UART1 TXUARTTransmit pin
11UART1 RXUARTReceive pin

Loopback test: Short GPIO10 (TX) and GPIO11 (RX) with a Dupont wire to transmit and receive on its own.

Wiring diagram:

Wiring diagram


4. Project Architecture and Flow

xxxxxxxxxx
Script execution (single-file .py)
  │
  ├─ UART(1, baudrate=115200, tx=10, rx=11)
  │
  └─ while True:
       ├─ print("Sent: ...")                       // Print sent data
       ├─ uart.write(...)                          // Send
       ├─ sleep_ms(50)                             // Wait for data to fully arrive
       ├─ uart.read(255) → decode('utf-8') → print("Received:")  // Receive and print
       └─ sleep_ms(2000)                           // 2s interval

5. Source Code Details

Complete source code: 5.Source Code → MicroPython → 3.Serial Communication and Storage System → 1. UART → 1. UART.py

5.1 UART Initialization

xxxxxxxxxx
from machine import UART, Pin   # UART and Pin classes
import time                     # delay
​
# Initialize UART1 (avoid REPL UART0)
# RX pull-up to avoid garbage when floating
uart = UART(1, baudrate=115200, tx=Pin(10), rx=Pin(11, Pin.IN, Pin.PULL_UP))

5.2 Transmit and Receive

xxxxxxxxxx
# TX function
def uart_tx(data):
    uart.write(data)
​
# RX function
def uart_rx():
    buf = uart.read(255)                    # Read serial buffer, max 255 bytes
    if buf:
        try:
            print("Received:", buf.decode('utf-8').strip())   # Normal text decode
        except UnicodeError:
            print("Received raw:", buf)     # Print raw bytes on failure

5.3 Main Loop

xxxxxxxxxx
# Main logic
print("UART Started, TX=GPIO10, RX=GPIO11")
while True:
    send_str = "GOOD GOOD STUDY,DAY DAY UP!!!!!!\r\n"
    print("Sent:", send_str.strip())       # Print what was sent
    uart_tx(send_str)
    time.sleep_ms(50)                      # Brief delay for RX to complete
    uart_rx()
    time.sleep_ms(2000)                    # 2s interval

6. Operation Procedure

6.1 Flashing and Running

Thonny IDE operation steps: See MicroPython → 1. Before Development → 3.Thonny IDE.

  1. Loopback test: Short GPIO10 (TX) and GPIO11 (RX) with a Dupont wire
  2. Open 1. UART.py with Thonny IDE and click Run

6.2 Serial Output Example

xxxxxxxxxx
UART Started, TX=GPIO10, RX=GPIO11
Sent: GOOD GOOD STUDY,DAY DAY UP!!!!!!
Received: GOOD GOOD STUDY,DAY DAY UP!!!!!!
Sent: GOOD GOOD STUDY,DAY DAY UP!!!!!!
Received: GOOD GOOD STUDY,DAY DAY UP!!!!!!
...

Serial print

6.3 Expected Behavior

Prints the received string every 2 seconds. If TX/RX is shorted correctly, the Received content is identical to the sent content.

6.4 Verification Method

ActionExpected result
Short GPIO10 - GPIO11Received: shows the complete sent content
Remove the shorting wireNo Received: output (no data received)
Change baudrate=9600Garbled data (TX/RX baud rates do not match)
Change uart.write("Hello")Received content becomes "Hello"

7. Common Issues

SymptomCauseSolution
No Received outputTX/RX not shortedConnect GPIO10 and GPIO11 with a Dupont wire
Received shows garbage or abnormal charactersBaud rate mismatchConfirm baudrate=115200 is the same on both ends
UART(0, ...) failsUART0 is occupied by the system REPLUse UART(1) or UART(2) instead
Received is empty after sendingInsufficient receive delayIncrease the sleep_ms() delay
RGB LED Effects
I2C_OLED Display Experiment

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文