4.Xiaozhi AI Tutorial

The Xiaozhi AI solution used in this project is open source and is based on xiaozhi-esp32. If you only want to use the device, follow the flashing steps in this tutorial. If you want to customize features or continue development, see Open Source and Secondary Development.

Backend Setup

First, Register a Xiaozhi Account

  1. Visit the AI Chatbot Management System: Xiaozhi.me

  2. Click the “Console” button on the page to enter the console

  3. Fill in the registration form:

    • Select your country and enter your mobile phone number (for receiving verification code)

    • graphic verification code

  4. Then click “Send Code”. The system will send a verification code to your phone. enter the verification code to complete registration

  5. After registration, you can add a password in the account management in the upper right corner

../_images/sign0.png
../_images/sign1.png
../_images/sign2.png

Adding Devices to the Management Backend

  1. Create an Agent:

    • Click the “Create Agent” button

    • Fill in the agent name and then click Confirm

    • In the agent card, click Configure Role

Create Agent Interface
Configure Agent Parameters
Add Device Interface
  1. Configure Agent Parameters:

    • Assistant Name: Name your AI assistant

    • Voice Role: Select your preferred voice style

    • Language Preference: Set the conversation language

    • Role Introduction: Define the personality traits of the AI assistant

    • Language Model: Select the language model to use

  2. Set the Role Prompt. It is recommended to use the following template, or you can create your own role prompt:

    I am a virtual assistant called {{assistant_name}}. I communicate exclusively in English with a natural, friendly voice. I provide helpful, accurate information and assist users with their queries while maintaining a conversational tone. I adapt my speaking style to match the user's needs and always aim to deliver clear, concise responses in fluent English.
    
../_images/web4.png
  1. Click the “Save” button to save the role configuration

../_images/web5.png

Firmware Upload

Online Flashing

You can also use an online flashing tool. The advantage of this method is that you simply open the webpage, select your device and firmware version, and it requires no configuration. Once flashing is complete, you can start using it right away.

Note

Online flashing is supported only in Chrome or Edge browsers.

Warning

Use a USB Type-C cable that supports data transfer. A charging-only cable may power the board but will not work for flashing.

Note

On Windows, connect the USB Type-C data cable to the ESP32-S3 UART port on the left side of the board before clicking Connect. On macOS, connect the cable to the ESP32-S3 USB port on the right side, then press and hold BOOT, press RESET while still holding BOOT, and enter download mode before clicking Connect. The screen will turn black after the device enters download mode; this is normal.

For detailed instructions on using the online flasher, see Online Flasher.

Follow these steps:

  1. Open the LAFVIN Web Flasher

  2. Select the following options:

    • Device: ESP32S3 AI Chatbot Kit

    • Firmware: Xiaozhi-esp32

    • Version: 2.2.4

  3. Connect the development board to your computer using the correct USB Type-C port for your operating system, as described in the note above, before clicking Connect.

  4. Click Connect, then select your device in the browser pop-up window and click Connect again.

  5. Click Flash to start flashing. Wait for the process to complete.

  6. After flashing is complete, restart the device by pressing the RST or RESET button on the ESP32-S3 board. You do not need to unplug the USB cable unless the device does not respond.

Local Flashing (Alternative)
  1. Double-click to open Flash Download Tools, then select the options as shown below:

../_images/flashtool1.png
  1. Follow these steps to upload the firmware:

    1. Click the “Select File” button to choose your downloaded firmware file (.bin format)

    2. In the address input box after the bin file selection box, enter 0 or 0x0 (indicating that the firmware will be downloaded to the starting position of the development board’s memory)

    3. Select the COM port corresponding to ESP32-S3 from the port selection dropdown menu (refer to the Driver Installation section for how to check the device manager for the specific port number)

    4. Set the baud rate (we use 460800 here)

    5. Click the “START” button to begin downloading the firmware to the ESP32-S3 development board

    ../_images/flash_xiaozhi1.png
    ../_images/flash_xiaozhi2.png

Note

The ESP32-S3 supports only 2.4 GHz Wi-Fi networks. Make sure the Wi-Fi network you select is not 5 GHz only.

  1. After the firmware is flashed, press the RST or RESET button on the development board. The board will restart and enter network configuration mode.

  2. Connect your phone to the hotspot named Xiaozhi-XXXX. The configuration page should open automatically. If not, manually enter http://192.168.4.1 in your browser to access the configuration interface.

../_images/wificonfig_xiaozhi.png
  1. Select your Wi-Fi network, enter the password, and click Save. The device will save the settings and restart automatically.

  2. After restarting, the board will connect to your Wi-Fi and announce a 6-digit verification code. If it does not restart within about 30 seconds, press the RST or RESET button once.

  3. Go to the backend interface and add the device in the Agent you just created:

    • Click the “Add Device” button

    • Enter the 6-digit verification code announced by the device

../_images/web6.png
../_images/verify_xiaozhi.png

After clicking “Confirm” and restarting the device, you’ll see this interface. At that point, just say “Hi, ESP,” and you can start the conversation.

../_images/main_xiaozhi.png

For flashing help, driver troubleshooting, or alternative flashing methods, see Online Flasher.