Skip to content

ru-sh/esp-smart-speaker

Repository files navigation

ESP32-S3 Smart Speaker Project

Board: XIAO ReSpeaker Lite (ESP32-S3 + XU316 + AIC3204) Version: 1.0.0 Status: Phase 2 Complete - Audio Playback

Project Overview

This project implements a smart speaker application on the XIAO ReSpeaker Lite board, featuring:

  • Audio playback from SPIFFS storage
  • Audio recording from XU316-processed microphones
  • Network transmission of recorded audio via TCP
  • Visual feedback via RGB LED
  • User interaction via button control

Hardware Components

  • ESP32-S3: Main MCU (8MB Flash, 8MB PSRAM)
  • XMOS XU316: Audio DSP (I2C: 0x42) - microphone processing
  • TLV320AIC3204: Audio codec (I2C: 0x18) - speaker output
  • WS2812 RGB LED: GPIO1 - status indication
  • User Button: GPIO3 (D3) - user interaction

Current Implementation Status

✅ Phase 1: Basic Infrastructure (COMPLETE)

Implemented Components:

Features:

  • ✅ SPIFFS filesystem mounted and operational
  • ✅ I2C communication with AIC3204 codec
  • ✅ I2C communication with XU316 processor
  • ✅ Button press detection (short and long press)
  • ✅ LED color control and effects (blink, pulse)
  • ✅ Volume control via AIC3204
  • ✅ XU316 firmware version reading
  • ✅ VNR (Voice Noise Reduction) value reading

✅ Phase 2: Audio Playback (COMPLETE)

Implemented Components:

Features:

  • ✅ WAV file playback from SPIFFS
  • ✅ I2S TX in slave mode (XU316 provides clocks)
  • ✅ Support for 16-bit and 32-bit PCM audio
  • ✅ Automatic bit depth conversion
  • ✅ Synchronous and asynchronous playback
  • ✅ Volume control integration
  • ✅ Playback statistics tracking
  • ✅ Button-triggered playback
  • ✅ LED status indication

🚧 Phase 3: Audio Recording (PLANNED)

To Be Implemented:

  • audio_recording.c/h - Recording management
  • wav_encoder.c/h - WAV file creation
  • i2s_input.c/h - I2S RX operations

🚧 Phase 4: Network Transmission (PLANNED)

To Be Implemented:

  • audio_tcp_client.c/h - TCP audio transmission
  • network_manager.c/h - Network state management

🚧 Phase 5: Integration (PLANNED)

To Be Implemented:

  • state_machine.c/h - Application state management

Building and Flashing

Prerequisites

  • ESP-IDF v5.x installed and configured
  • XIAO ReSpeaker Lite board connected via USB

Build Commands

# Set ESP-IDF environment
. $HOME/esp/esp-idf/export.sh

# Configure project (optional)
idf.py menuconfig

# Build project
idf.py build

# Flash to device
idf.py -p /dev/ttyACM0 flash

# Monitor output
idf.py -p /dev/ttyACM0 monitor

Windows Commands

# Build project
idf.py build

# Flash to device (adjust COM port as needed)
idf.py -p COM3 flash monitor

Phase 2 Testing

The current Phase 2 implementation provides audio playback functionality:

Test Instructions

  1. Power on the board - LED will show RGB startup sequence (Red → Green → Blue)
  2. LED turns green - System is ready
  3. Short press button - Plays WAV file from SPIFFS (LED turns blue during playback)
  4. Press again during playback - Stops playback
  5. Long press button (hold for 1 second) - Cycles through volume levels (MAX → HIGH → MEDIUM → LOW)

Expected Serial Output

I (xxx) smart_speaker: === XIAO ReSpeaker Lite Smart Speaker ===
I (xxx) smart_speaker: Version: 1.0.0
I (xxx) smart_speaker: Phase 1: Basic Infrastructure Test
I (xxx) smart_speaker: Initializing SPIFFS...
I (xxx) smart_speaker: SPIFFS: 1536 KB total, 0 KB used
I (xxx) smart_speaker: Initializing I2C bus...
I (xxx) smart_speaker: Scanning I2C bus...
I (xxx) i2c: Found device at address: 0x18 (AIC3204)
I (xxx) i2c: Found device at address: 0x42 (XU316)
I (xxx) smart_speaker: AIC3204 initialized successfully
I (xxx) smart_speaker: Volume set to 0x10
I (xxx) xu316: XU316 Firmware: v1.2.3
I (xxx) smart_speaker: XU316 VNR value: 50
I (xxx) smart_speaker: LED controller initialized successfully
I (xxx) smart_speaker: Button handler initialized successfully
I (xxx) smart_speaker: Phase 1 Infrastructure Test Complete!

Configuration

Audio Configuration

Edit main/Kconfig.projbuild or use idf.py menuconfig:

  • Audio Sample Rate: 16000 Hz (default)
  • Recording Duration: 10 seconds (default)
  • Default Volume: 0x10 (default)
  • TCP Server IP: 192.168.1.100 (default)
  • TCP Server Port: 3333 (default)

Hardware Configuration

Edit main/board_config.h:

  • GPIO pin assignments
  • I2C addresses
  • Audio parameters
  • LED colors
  • Buffer sizes

Pin Mapping

Function GPIO Description
I2S BCK GPIO8 Bit Clock (from XU316)
I2S WS GPIO7 Word Select (from XU316)
I2S DOUT GPIO43 Data Out to AIC3204
I2S DIN GPIO44 Data In from XU316
I2C SDA GPIO5 I2C Data
I2C SCL GPIO6 I2C Clock
RGB LED GPIO1 WS2812 LED
Button GPIO3 User Button (D3)

I2C Devices

Device Address Description
AIC3204 0x18 TLV320AIC3204 Audio Codec
XU316 0x42 XMOS Audio Processor

LED Status Indicators

Color Status
Green Idle / Ready
Blue Playing Audio
Yellow Volume Adjustment
Red Error

Troubleshooting

No LED Response

  • Check GPIO1 connection
  • Verify WS2812 power supply
  • Check LED strip component installation

Button Not Working

  • Verify GPIO3 (D3) connection
  • Check pull-up resistor configuration
  • Test with multimeter for button continuity

I2C Communication Fails

  • Run I2C bus scan to detect devices
  • Check SDA (GPIO5) and SCL (GPIO6) connections
  • Verify I2C pull-up resistors (typically 4.7kΩ)
  • Check device addresses (0x18 for AIC3204, 0x42 for XU316)

Build Errors

  • Ensure ESP-IDF v5.x is properly installed
  • Run idf.py fullclean and rebuild
  • Check that all dependencies are installed
  • Verify led_strip component is available

Project Structure

esp-smart-speaker/
├── CMakeLists.txt              # Top-level CMake configuration
├── partitions.csv              # Custom partition table
├── sdkconfig.defaults          # Default SDK configuration
├── README.md                   # This file
├── PHASE1_COMPLETE.md          # Phase 1 completion report
├── PHASE2_COMPLETE.md          # Phase 2 completion report
├── main/
│   ├── CMakeLists.txt          # Main component CMake
│   ├── Kconfig.projbuild       # Project configuration menu
│   ├── idf_component.yml       # Component dependencies
│   ├── tcp_client_main.c       # Main application
│   ├── board_config.h          # Hardware definitions
│   ├── app_config.h            # Application configuration
│   ├── filesystem_manager.c/h  # SPIFFS operations
│   ├── i2c_manager.c/h         # I2C bus management
│   ├── aic3204_driver.c/h      # AIC3204 codec driver
│   ├── xu316_driver.c/h        # XU316 processor driver
│   ├── button_handler.c/h      # Button handler
│   ├── led_controller.c/h      # LED controller
│   ├── wav_decoder.c/h         # WAV file parser
│   ├── i2s_output.c/h          # I2S TX operations
│   └── audio_playback.c/h      # Audio playback manager
├── plans/
│   └── smart-speaker-plan-complete.md  # Complete implementation plan
└── managed_components/
    ├── espressif__esp_audio_codec/
    └── espressif__led_strip/

References

License

This project is provided as-is for educational and development purposes.

Contributing

This is an active development project. Contributions and suggestions are welcome!


Last Updated: 2026-01-02 Phase: 2 of 5 Complete

About

ReSpeaker Lite based smart voice assistant

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages