High-quality 16-bit audio streaming from turntables (or any analog source) over WiFi using ESP32-S3 and PCM1808 ADC.
- 24-bit stereo audio capture (48kHz, configurable)
- Downsampling to 16-bit WAV streaming over HTTP
- Lock-free ring buffer for smooth playback
- Up to 3 concurrent clients
- WiFi STA mode with auto-reconnect
- Captive portal for WiFi and sample rate setup
- Home Assistant MQTT auto-discovery
- MQTT playback state publishing (
playing/idle) - MQTT stream URL attributes and live connection status
- Web UI for MQTT settings, connection testing, and factory reset
- Real-time status and diagnostics page (HTML/JSON)
- Clipping detection and recovery
- Comprehensive serial logging
- Board: ESP32-S3
- PSRAM: 8MB (required for audio buffer)
- Flash: 4MB minimum
- Cores: Dual-core (Core 0: audio, Core 1: networking)
- Chip: Texas Instruments PCM1808
- Resolution: 24-bit
- Sample rates: 8kHz - 96kHz
- Mode: Slave (ESP32 provides all clocks)
- Format: I²S Philips, 24-bit
| PCM1808 Pin | Function | ESP32 GPIO | Signal |
|---|---|---|---|
| SCKI (15) | System clock | GPIO8 | MCLK (12.288 MHz @ 48kHz) |
| BCK (14) | Bit clock | GPIO16 | BCK |
| LRCK (13) | Word select | GPIO18 | LRCK |
| DOUT (12) | Audio data | GPIO17 | I²S RX |
| MD0 (5) | Mode 0 | GND | Hardwired LOW |
| MD1 (6) | Mode 1 | GND | Hardwired LOW |
| FMT0 (7) | Format 0 | GND | Hardwired LOW |
| FMT1 (8) | Format 1 | GND | Hardwired LOW |
| VA (1,20) | Analog 5V | 5V | Power |
| VD (10) | Digital 3.3V | 3.3V | Power |
| AGND (2,19) | Analog GND | GND | Ground |
| DGND (9) | Digital GND | GND | Ground |
- PlatformIO (VSCode extension or CLI)
- Python 3.7+ (for PlatformIO)
- USB drivers for ESP32 (CP210x or CH340)
- Clone repository:
git clone <repo-url> cd esp32-turntable-analog-streamer
- Build:
platformio run
If you are building from WSL with the same setup used in this repository, use:
/mnt/c/Users/Miguel/.platformio/penv/Scripts/platformio.exe run --environment esp32-s3-n16r8
- Flash to ESP32:
platformio run --target upload
- Monitor serial output (115200 baud):
platformio device monitor
If you have no access to the serial port, you can follow the progress of device initialization using the onboard RGB LED (Neopixel):
| Step | LED Color | RGB Value |
|---|---|---|
| NVS Init | Blue | (0, 0, 32) |
| WiFi Init | Cyan | (0, 32, 32) |
| Config Portal | Yellow | (32, 32, 0) |
| HTTP Server | Magenta | (32, 0, 32) |
| Audio Buffer | Orange | (32, 16, 0) |
| I²S Init | Purple | (16, 0, 32) |
| Audio Capture | White | (32, 32, 32) |
| Success | Green | (0, 32, 0) |
| Error | Flashing Red | (32, 0, 0) |
How it works:
- The LED changes color at the start of each initialization step.
- If a step fails, the LED flashes red and stays red.
- If all steps succeed, the LED turns green.
This allows you to visually debug where the device gets stuck during boot.
- Flash firmware and power on the ESP32
- Connect to WiFi network ESP32-Audio-Streamer from your phone/laptop
- Navigate to http://192.168.4.1 (captive portal should redirect automatically)
- Select your WiFi network, enter password, choose sample rate
- Click Save — device restarts and connects to your network
- Check serial output for the assigned IP address
Open the stream URL in any media player:
Browser (Chrome/Firefox):
http://<esp32-ip>:8080/stream
VLC:
Media → Open Network Stream → http://<esp32-ip>:8080/stream
foobar2000:
File → Open Location → http://<esp32-ip>:8080/stream
FFmpeg:
ffplay http://<esp32-ip>:8080/stream
Navigate to http://<esp32-ip>:8080/status to view real-time diagnostics:
- Audio pipeline: sample rate, buffer fill, underruns, clipping status
- System health: CPU usage per core, free heap, uptime
- Network: WiFi RSSI, active clients, stream URL
- MQTT: enabled flag, broker, connection state, last published playback state
Also available as JSON: curl -H "Accept: application/json" http://<esp32-ip>:8080/status
- Open
http://<esp32-ip>:8080/mqtt-settings - Enable MQTT and enter your broker host, port, and optional credentials
- Use Test Connection before saving
- Adjust the audio threshold while watching the live level meter
- Save settings and verify the device appears in Home Assistant via MQTT discovery
Published topics follow the feature contract:
- Discovery:
homeassistant/binary_sensor/<device_id>/playback_status/config - State:
turntable/<device_id>/state - Attributes:
turntable/<device_id>/attributes - Availability:
turntable/<device_id>/availability
The device publishes:
- Playback state as
playingoridle - Stream URL as
http://<device-ip>:8080/stream - Availability as
online/offline
- Discovery missing in Home Assistant: verify the broker is reachable and MQTT integration is enabled in Home Assistant.
- Connection test fails: confirm broker host, port, credentials, and local network reachability.
- Playback state never changes: lower the audio threshold on the MQTT settings page until the live level exceeds it during playback.
- Stream URL is stale after DHCP renewal: reconnect WiFi or wait for the next
IP_EVENT_STA_GOT_IPrepublish.
- Container: WAV (RIFF)
- Codec: PCM (uncompressed)
- Bit depth: 16-bit
- Sample rate: 48000 Hz (default)
- Channels: 2 (stereo)
- Byte rate: 288 kB/s
- Latency: <100ms
- Max clients: 3 simultaneous streams
- 4th client: Returns HTTP 503 with
Retry-After: 5header
| Region | Size | Usage |
|---|---|---|
| Internal SRAM | 327 KB | Code, stack, DMA buffers (8.6 KB) |
| PSRAM | 8 MB | Audio ring buffer (1.1 MB) |
| Flash | 1.5 MB | Firmware |
| Core | Task | Priority | Stack | Function |
|---|---|---|---|---|
| 0 | Audio Capture | 24 (highest) | 4 KB | I²S DMA → PSRAM ring buffer |
| 1 | HTTP Server | 6 | 16 KB | Stream serving, status page |
| 1 | WiFi Manager | 8 | 4 KB | Connection, auto-reconnect |
| 1 | Main Loop | 1 | 4 KB | Monitoring, logging |
PCM1808 ADC → I²S (GPIO46) → DMA (Internal SRAM) → Ring Buffer (PSRAM)
↓
HTTP Client 1 ← TCP/IP Stack
HTTP Client 2 ← (Core 1)
HTTP Client 3 ←
- mDNS as
esp32-audio-stream.local - OTA firmware updates
- Equalization
See LICENSE file.