mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-27 04:49:47 +01:00
- Curated guides under docs/; trim China-only integration docs and screenshots - Root and main README set aligned with westernized product positioning - LICENSE text update where applicable
8.3 KiB
8.3 KiB
🔌 First Device Setup
Connect your first ESP32 device to Xiaozhi and start having conversations! This guide will walk you through the complete process from hardware setup to voice interaction.
🎯 What You'll Accomplish
By the end of this guide, you'll have:
- ✅ ESP32 device properly configured
- ✅ Firmware compiled and flashed
- ✅ Device connected to Xiaozhi server
- ✅ Voice interaction working
- ✅ Basic commands responding
🔧 Hardware Setup
Required Components
ESP32 Development Board
Choose one of these recommended options:
- ESP32-S3-DevKitC-1 - Official Espressif board
- ESP32-S3-BOX - With built-in microphone and speaker
- ESP32-S3-BOX-3 - Latest version with improved audio
- ESP32-S3-Korvo-2 - Audio-focused development board
Audio Components (if not built-in)
- Microphone: SPH0645LM4H or INMP441
- Speaker: Small speaker (8Ω, 0.5W+) with amplifier
- Amplifier: PAM8403 or MAX98357A
Connection Components
- USB Cable: Type-C or Micro-USB
- Breadboard: For prototyping
- Jumper Wires: For connections
- Resistors: 10kΩ, 4.7kΩ
Wiring Diagram
graph TB
A[ESP32-S3] --> B[Microphone]
A --> C[Speaker Amplifier]
A --> D[USB Power]
B --> E[SPH0645LM4H]
C --> F[PAM8403]
C --> G[Speaker]
H[3.3V] --> B
H --> C
I[GND] --> B
I --> C
I --> G
Pin Connections
| Component | ESP32-S3 Pin | Notes |
|---|---|---|
| Microphone VCC | 3.3V | Power supply |
| Microphone GND | GND | Ground |
| Microphone WS | GPIO 15 | Word select |
| Microphone BCK | GPIO 16 | Bit clock |
| Microphone DIN | GPIO 17 | Data input |
| Amplifier VCC | 3.3V | Power supply |
| Amplifier GND | GND | Ground |
| Amplifier DIN | GPIO 18 | Audio data |
| Amplifier BCK | GPIO 19 | Bit clock |
| Amplifier LRC | GPIO 20 | Left/right clock |
💾 Firmware Preparation
Step 1: Get Firmware Source
# Clone the ESP32 firmware repository
git clone https://github.com/78/xiaozhi-esp32.git
cd xiaozhi-esp32
Step 2: Configure Build Environment
Install ESP-IDF
# Download ESP-IDF
git clone --recursive https://github.com/espressif/esp-idf.git
cd esp-idf
./install.sh
# Set up environment
. ./export.sh
Alternative: Use ESP-IDF Installer
- Windows: Download from Espressif
- macOS:
brew install espressif/esp-idf/esp-idf - Linux: Follow official guide
Step 3: Configure Firmware
-
Open project in ESP-IDF
-
Run configuration:
idf.py menuconfig -
Configure settings:
- WiFi: Set your network credentials
- Audio: Configure microphone and speaker pins
- WebSocket: Set server URL (will be configured later)
Step 4: Build Firmware
# Build the firmware
idf.py build
# This creates firmware.bin in build/ directory
🔌 Device Flashing
Method 1: Web-based Flashing (Easiest)
- Go to: ESP-Launchpad
- Upload firmware: Select your
firmware.binfile - Connect ESP32: Via USB cable
- Select port: Choose your ESP32's COM port
- Flash: Click "Flash" and wait for completion
Method 2: Command Line
# Install esptool
pip install esptool
# Flash firmware (adjust port and baud rate)
esptool.py --chip esp32s3 --port COM3 --baud 921600 write_flash 0x0 firmware.bin
Method 3: ESP-IDF
# Flash using ESP-IDF
idf.py -p COM3 flash
# Monitor output
idf.py -p COM3 monitor
🌐 Network Configuration
Step 1: Configure WiFi
- Power on your ESP32 device
- Wait for WiFi setup mode (LED indication)
- Connect to ESP32 WiFi network
- Open browser to configuration page
- Enter WiFi credentials:
- Network name (SSID)
- Password
- Server URL:
ws://YOUR_SERVER_IP:8000/xiaozhi/v1/
Step 2: Verify Connection
- Check OTA interface: http://YOUR_SERVER_IP:8003/xiaozhi/ota/
- Look for your device in the connected devices list
- Verify WebSocket connection is active
🎤 Audio Testing
Step 1: Test Microphone
- Say "Hello" near the microphone
- Check server logs for audio input
- Verify audio levels are appropriate
Step 2: Test Speaker
- Send test command via web interface
- Listen for audio output
- Adjust volume if needed
Step 3: Test Voice Interaction
- Say: "Hello Xiaozhi"
- Wait for response
- Try basic commands:
- "What's the weather?"
- "Tell me a joke"
- "What time is it?"
⚙️ Device Configuration
Web Interface Configuration
- Open web interface: http://YOUR_SERVER_IP:8001
- Go to Devices section
- Find your ESP32 device
- Configure settings:
- Device name
- Audio settings
- Wake word sensitivity
- Response behavior
Advanced Configuration
# Device configuration example
device:
name: "My ESP32 Assistant"
wake_word: "Hello Xiaozhi"
audio:
microphone_gain: 1.0
speaker_volume: 0.8
noise_reduction: true
behavior:
response_delay: 0.5
max_response_length: 100
enable_interruptions: true
🧪 Testing and Validation
Basic Functionality Tests
-
Wake Word Detection
- Say "Hello Xiaozhi"
- Verify device responds
-
Voice Recognition
- Speak clearly
- Check text accuracy
-
Response Generation
- Ask questions
- Verify appropriate responses
-
Audio Output
- Listen to synthesized speech
- Check audio quality
Advanced Tests
-
Multiple Commands
- Try various command types
- Test conversation flow
-
Error Handling
- Test with unclear speech
- Verify graceful error handling
-
Performance
- Measure response times
- Check resource usage
🛠️ Troubleshooting
Device Won't Connect
- Check WiFi credentials
- Verify server URL format
- Check firewall settings
- Restart device and server
No Audio Input
- Check microphone connections
- Verify audio configuration
- Test microphone separately
- Check audio levels
No Audio Output
- Check speaker connections
- Verify amplifier power
- Test speaker separately
- Check volume settings
Poor Voice Recognition
- Improve microphone positioning
- Reduce background noise
- Adjust microphone gain
- Check audio quality
🎉 Success! What's Next?
🎯 Try These Features
- Voice Commands: Control your device with voice
- Conversations: Have natural conversations
- Custom Responses: Create personalized responses
- Integrations: Connect to other services
🔧 Advanced Configuration
- Custom Wake Words: Set your own wake phrase
- Audio Optimization: Fine-tune audio settings
- Response Customization: Personalize AI responses
- Plugin Integration: Add custom functionality
📚 Next Steps
- Configuration Guide - Fine-tune your setup
- Features Guide - Explore capabilities
- Integrations Guide - Connect to other systems
- Custom Plugins - Add custom functionality
🆘 Need Help?
- Hardware Issues? Check Hardware Troubleshooting
- Configuration Problems? See Configuration Guide
- General Issues? Browse Troubleshooting Guide
🎯 Quick Reference
Key Commands
# Build firmware
idf.py build
# Flash firmware
idf.py -p COM3 flash
# Monitor output
idf.py -p COM3 monitor
Key URLs
- OTA Interface: http://YOUR_SERVER_IP:8003/xiaozhi/ota/
- Web Interface: http://YOUR_SERVER_IP:8001
- Device Config: Web Interface → Devices
Pin Reference
- Microphone: GPIO 15-17
- Speaker: GPIO 18-20
- Power: 3.3V, GND
Congratulations! Your ESP32 device is now connected and ready for voice interaction! 🎉