Skip to main content

Supported ESP32 SoCs

The ESP32_USB_STREAM library is compatible with specific ESP32 System-on-Chip (SoC) variants that include USB OTG (On-The-Go) host capabilities.

ESP32-S2

Features:
  • Single-core Xtensa LX7 @ 240 MHz
  • USB OTG Full-Speed (12 Mbps)
  • 320 KB SRAM
  • Wi-Fi 802.11 b/g/n
Use Case: Cost-effective solution for basic UVC/UAC applications

ESP32-S3

Features:
  • Dual-core Xtensa LX7 @ 240 MHz
  • USB OTG Full-Speed (12 Mbps)
  • 512 KB SRAM
  • Wi-Fi 802.11 b/g/n + Bluetooth 5.0
Use Case: Recommended for demanding applications with concurrent processing
Not supported: ESP32 (original), ESP32-C3, ESP32-C6, ESP32-H2These chips lack USB OTG host functionality and cannot act as a USB host for UVC/UAC devices.
For most applications, especially those requiring concurrent UVC and UAC streaming, the ESP32-S3 offers significant advantages:
1

Dual-core processing

One core can handle USB streaming while the other manages application logic, Wi-Fi, or display updates.
2

More RAM

512 KB SRAM vs 320 KB on S2 allows larger frame buffers and more headroom for complex processing.
3

Better performance

Higher processing power ensures stable streaming at higher frame rates and resolutions.

USB Host Wiring

Proper USB connections are critical for reliable operation. The ESP32-S2/S3 USB OTG peripheral uses specific GPIO pins.

Standard USB Pin Configuration

SignalESP32-S2/S3 GPIOUSB Type-A PinColor (typical)
D+ (Data Plus)GPIO 20Pin 3Green
D- (Data Minus)GPIO 19Pin 2White
VBUS (5V Power)5VPin 1Red
GND (Ground)GNDPin 4Black

USB Type-A Connector Wiring

┌─────────────────┐
│  1   2   3   4  │  Looking into USB Type-A receptacle
│ ┌─┐ ┌─┐ ┌─┐ ┌─┐ │
│ │ │ │ │ │ │ │ │ │
│ └─┘ └─┘ └─┘ └─┘ │
└─────────────────┘
  │   │   │   │
  │   │   │   └── Pin 4: GND (Black)
  │   │   └────── Pin 3: D+ (Green) → GPIO 20
  │   └────────── Pin 2: D- (White) → GPIO 19
  └────────────── Pin 1: VBUS 5V (Red)

Connection Diagram

The ESP32’s internal USB PHY handles the USB signal levels automatically. You can connect the data lines directly without level shifters.

Power Considerations

USB devices can draw significant current, and proper power design is essential.

USB Power Requirements

Low-Power Devices
≤100 mA
Examples: Simple webcams, basic microphonesCan typically be powered from ESP32 development board’s 5V pin if it has sufficient supply.
Standard Devices
100-500 mA
Examples: Most USB cameras, audio interfacesRequires external 5V power supply. Do not rely on USB-to-Serial converter or computer USB port.
High-Power Devices
>500 mA
Examples: High-resolution cameras, active speakersRequires dedicated 5V power supply rated for at least 2A. May need powered USB hub.

Power Supply Options

Use when:
  • Device draws less than 100 mA
  • Dev board has robust 5V regulator
  • External power adapter is connected to dev board
Don’t use when:
  • Device is high-power
  • Powering from computer USB only
  • Experiencing brown-out or reset issues
When to use:
  • Multiple USB devices
  • Very high-power devices (>1A)
  • Maximum compatibility
Setup:
  • Connect powered hub to ESP32 USB host pins
  • Hub provides power to all connected devices
  • ESP32 draws minimal current for USB signals
Brown-out ProtectionIf you experience random resets during USB device enumeration or streaming, it’s almost always a power issue. Use a dedicated 5V power supply rated for at least 2A.

Compatible USB Devices

The library supports standard UVC (Video Class) and UAC (Audio Class) compliant devices.

USB Video Class (UVC) Devices

Supported Devices

  • Standard USB webcams
  • USB endoscopes
  • USB microscopes
  • Action cameras with UVC support
  • USB capture cards (UVC compatible)
  • Industrial USB cameras

Requirements

  • UVC 1.0, 1.1, or 1.5 compliant
  • MJPEG format (default support)
  • Full-Speed USB (12 Mbps)
  • Resolutions up to ~720p @ 15fps

USB Audio Class (UAC) Devices

Supported Devices

  • USB microphones
  • USB headsets
  • USB speakers
  • USB audio interfaces
  • USB sound cards
  • Conference speakerphones

Requirements

  • UAC 1.0 or 2.0 compliant
  • Full-Speed USB (12 Mbps)
  • Sample rates: 8-96 kHz
  • Bit depths: 8, 16, 24, 32-bit

Tested Device Examples

While the library supports standard UVC/UAC devices, actual compatibility depends on the device’s implementation. Some devices may have non-standard behavior.
Known Working Cameras:
  • Generic 480p/720p USB webcams
  • Logitech C270 (at lower resolutions)
  • USB endoscope cameras
Known Working Audio:
  • Generic USB microphones
  • USB conference speakers
  • Simple USB headsets
For best results, test with inexpensive generic USB cameras and microphones first. High-end devices may have proprietary features that exceed the ESP32’s capabilities.

Device Compatibility Checks

Before purchasing a USB device, verify it meets these criteria:
1

Check USB class compliance

Device must be standard UVC (video) or UAC (audio) compliant. Look for “UVC” or “USB Video Class” in specifications.
2

Verify power requirements

Check device current draw (usually in mA). Ensure your power supply can handle it.
3

Confirm USB Full-Speed support

ESP32 supports Full-Speed (12 Mbps) only. High-Speed (480 Mbps) devices may work at reduced performance.
4

Check format support

For cameras, MJPEG is best supported. For audio, PCM is standard.

Concurrent Streaming Limits

The ESP32_USB_STREAM library supports concurrent streaming with these constraints:

Maximum Simultaneous Streams

1 UVC

One USB camera providing video stream

1 Microphone

One USB microphone input

1 Speaker

One USB speaker output

Bandwidth Considerations

USB Full-Speed theoretical maximum is 12 Mbps, but practical limits are lower:
ConfigurationEstimated BandwidthFeasibility
640×480 @ 15 fps MJPEG~4-6 Mbps✅ Excellent
1280×720 @ 15 fps MJPEG~8-10 Mbps⚠️ Marginal
1920×1080 @ 15 fps MJPEG~12-16 Mbps❌ Exceeds USB
48 kHz stereo 16-bit audio~1.5 Mbps✅ Excellent
UVC + UAC mic + UAC speaker~5-8 Mbps✅ Good
Higher resolutions (>720p) or frame rates (>15 fps) may exceed USB Full-Speed bandwidth, causing frame drops or connection instability.

Memory Constraints

// Typical memory usage

// UVC Streaming (640×480 MJPEG)
uint8_t *xferA = malloc(55 * 1024);    // 55 KB
uint8_t *xferB = malloc(55 * 1024);    // 55 KB  
uint8_t *frame = malloc(55 * 1024);    // 55 KB
// Total: ~165 KB for video

// UAC Streaming (48 kHz, stereo, 16-bit)
uint32_t mic_buf = 9600;               // ~10 KB
uint32_t spk_buf = 9600;               // ~10 KB
// Total: ~20 KB for audio

// Combined: ~185 KB + driver overhead + application
// ESP32-S2: 320 KB SRAM (tight)
// ESP32-S3: 512 KB SRAM (comfortable)
For concurrent UVC + UAC streaming, the ESP32-S3 with its 512 KB SRAM is strongly recommended.

Circuit Design Guidelines

Minimal USB Host Circuit

ESP32-S2/S3 Development Board

         ┌─────────────────────────┐
         │                         │
  5V ────┤ VIN              GPIO19 ├──── USB D- (White)
         │                         │
  GND ───┤ GND              GPIO20 ├──── USB D+ (Green)
         │                         │
         └─────────────────────────┘
                    
        USB Type-A Connector
        ┌───────────────┐
 5V ────┤ 1 (VBUS)      │
GND ────┤ 4 (GND)       │
        │ 2 (D-)  3 (D+)│
        └───┬───────┬───┘
            │       │
           D-      D+
For production designs, add protection components:
From ESP32          USB Type-A
GPIO 19 ───[33Ω]────┬───── D- (Pin 2)
                    ├─TVS─┐
GPIO 20 ───[33Ω]────┼───── D+ (Pin 3)
                    │     │
                    GND  GND
                    
5V ──[Fuse 500mA]───┬───── VBUS (Pin 1)

              [100µF Bulk]

                   GND ────── GND (Pin 4)
                   
TVS: ESD protection diode (e.g., PRTR5V0U2X)
Fuse: Resettable polyfuse (e.g., 0.5A hold)

Development Board Recommendations

Popular ESP32-S2/S3 boards suitable for USB host applications:

ESP32-S3-DevKitC-1

Official Espressif board
  • ESP32-S3-WROOM-1 module
  • USB-to-UART + USB OTG ports
  • Exposed GPIO 19/20 for USB host
  • Recommended for development

ESP32-S2-Saola-1

Official Espressif board
  • ESP32-S2-WROVER module
  • USB OTG port available
  • Cost-effective option
  • Good for basic applications
Ensure your development board breaks out GPIO 19 and GPIO 20, or has a dedicated USB OTG port you can use in host mode.

Troubleshooting Hardware Issues

Possible causes:
  • Incorrect wiring (check D+/D- connections)
  • Insufficient power supply
  • Device not UVC/UAC compliant
  • Faulty USB cable
Solutions:
  • Verify GPIO 19 → D-, GPIO 20 → D+ connections
  • Use external 5V/2A power supply
  • Test with a known-good USB device
  • Try a different (shorter) USB cable
Cause: Brown-out due to insufficient powerSolutions:
  • Use dedicated 5V power supply (not computer USB)
  • Add bulk capacitors (100µF-470µF) near ESP32 and USB VBUS
  • Reduce USB device power consumption (lower resolution/frame rate)
  • Consider powered USB hub
Possible causes:
  • Poor USB cable quality
  • Electrical noise on data lines
  • Power supply ripple
  • Long cable lengths
Solutions:
  • Use high-quality shielded USB cable (less than 1 meter)
  • Add 33Ω series resistors on D+/D- lines
  • Add ferrite bead on USB cable
  • Ensure solid ground connections
Possible causes:
  • USB bandwidth exceeded
  • Insufficient ESP32 processing power
  • Memory allocation issues
Solutions:
  • Reduce resolution or frame rate
  • Lower audio sample rate
  • Use ESP32-S3 instead of S2
  • Increase buffer sizes if memory permits

UVC Streaming

Learn about USB video streaming configuration

UAC Streaming

Learn about USB audio streaming configuration

Build docs developers (and LLMs) love