Skip to content
This repository was archived by the owner on Jul 18, 2026. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP32 Serial Round Trip Speed Test

This PlatformIO project tests the round trip serial communication speed between a host computer and an ESP32 microcontroller.

Features

  • ESP32 Firmware: Responds to ping commands with precise timing measurements
  • Python Test Script: Measures round trip times from the host computer
  • Statistics Tracking: Both ESP32 and host-side performance metrics
  • Configurable Parameters: Baud rate, payload size, test count
  • Real-time Monitoring: Built-in LED indicates activity

Hardware Requirements

  • ESP32 development board (ESP32-DevKit, NodeMCU-32S, etc.)
  • USB cable for programming and serial communication
  • Computer with Python 3.6+ installed

Software Requirements

  • PlatformIO (VS Code extension or CLI)
  • Python 3.6 or higher
  • pyserial library (see requirements.txt)

Setup Instructions

1. Flash the ESP32 Firmware

# Clone or download this project
cd test-esp-serial-round-trip

# Build and upload firmware using PlatformIO
pio run --target upload

# Optional: Monitor serial output
pio device monitor

2. Install Python Dependencies

# Install required Python packages
pip install -r requirements.txt

3. Find Your Serial Port

# List available serial ports
python test_serial_speed.py --list-ports

Usage

Basic Speed Test

# Run 100 tests with default settings
python test_serial_speed.py --port /dev/ttyUSB0

# On Windows
python test_serial_speed.py --port COM3

Advanced Usage

# Custom test parameters
python test_serial_speed.py \
    --port /dev/ttyUSB0 \
    --baud 115200 \
    --tests 1000 \
    --size 50 \
    --delay 0.005

# Test different baud rates
python test_serial_speed.py --port /dev/ttyUSB0 --baud 921600

Command Line Options

  • --port, -p: Serial port device (required)
  • --baud, -b: Baud rate (default: 115200)
  • --tests, -n: Number of tests to run (default: 100)
  • --size, -s: Data payload size in characters (default: 10)
  • --delay, -d: Delay between tests in seconds (default: 0.01)
  • --list-ports, -l: List available serial ports

ESP32 Commands

The ESP32 firmware supports several commands via serial terminal:

  • PING <data> - Echo back data with timing information
  • STATS - Show performance statistics
  • RESET - Reset statistics counters
  • SPEED <baud> - Change baud rate dynamically

Example ESP32 Session

ESP32 Serial Round Trip Speed Test
===================================
Commands:
  PING <data> - Echo back the data with timing
  STATS - Show performance statistics  
  RESET - Reset statistics
  SPEED <baud> - Change baud rate
Ready for commands...

PING hello
PONG hello TIME:45 us

STATS
=== Performance Statistics ===
Total messages: 150
Average time: 42 us
Min time: 38 us
Max time: 67 us
Current baud rate: 115200

Performance Results

Typical performance on ESP32 at 115200 baud:

  • Round trip time: 2-10ms (depends on payload size and host system)
  • ESP32 processing time: 40-100 microseconds
  • Throughput: 100-500 messages/second
  • Effective data rate: 8-40 kbps (much lower than baud rate due to protocol overhead)

Factors Affecting Performance

  1. Baud Rate: Higher rates reduce transmission time
  2. Payload Size: Larger payloads increase transmission time linearly
  3. Host System: USB latency varies between systems
  4. USB-to-Serial Converter: Different chips have different latencies
  5. Operating System: Serial port drivers affect performance

Troubleshooting

Common Issues

  1. Permission Denied (Linux/macOS)

    sudo usermod -a -G dialout $USER
    # Log out and back in
  2. Port Not Found

    • Check cable connection
    • Verify ESP32 is powered on
    • Use --list-ports to find correct port
  3. Upload Failed

    • Hold BOOT button while uploading
    • Check that no serial monitor is open
    • Try different USB cable/port
  4. Poor Performance

    • Try higher baud rates (230400, 460800, 921600)
    • Reduce delay between tests
    • Check for USB hub latency

Understanding the Results

Round Trip Time Components

  1. Host → ESP32 transmission: Depends on baud rate and payload size
  2. ESP32 processing: Usually 40-100 microseconds
  3. ESP32 → Host transmission: Same as step 1
  4. Host USB latency: 1-16ms depending on system

Performance Optimization Tips

  • Use higher baud rates (921600 works well on ESP32)
  • Minimize payload size for latency testing
  • Use dedicated USB-to-Serial converters instead of built-in ones
  • Test on different host systems to compare USB stack performance

Project Structure

test-esp-serial-round-trip/
├── platformio.ini          # PlatformIO configuration
├── src/
│   └── main.cpp            # ESP32 firmware
├── test_serial_speed.py    # Python test script
├── requirements.txt        # Python dependencies
└── README.md              # This file

License

This project is open source and available under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages