UNIHIKER K10 + XiaoZhi MCP: Building Your Smart Home AI-Powered Assistant
1. Project Introduction
What would it feel like to have a smart assistant that can see the environment, understand human language, and respond proactively?
In this project, we use two UNIHIKER K10 boards: One runs the XiaoZhi firmware as the voice interaction terminal, responsible for speech understanding and decision-making . The other acts as the execution terminal, responsible for controlling hardware such as fans and lights.
By defining XiaoZhi MCP tools (environment sensing, fan control, lighting control), the system enables the UNIHIKER K10 to invoke hardware capabilities in a structured way, just like a real intelligent agent.
This project demonstrates how to build a practical AI agent system by combining large language models, MCP protocol, and real hardware, achieving a complete loop of perception, reasoning, and action.
2.Hardware and Software Preparation
2.1 Hardware List
3.System Diagram
In this project, we use two UNIHIKER K10 boards to build a smart assistant system that can listen, think, and act.
The UNIHIKER K10 running XiaoZhi firmware serves as the intelligent voice interaction terminal. Acting as a conversational assistant (āXiaoZhiā), it is responsible for: understanding user speech (speech recognition)ļ¼interpreting user intent (AI understanding) ;making decisions (determining what actions to take) ;sending control commands
The other UNIHIKER K10 functions as the MCP service and execution terminal. As the execution unit, it is responsible for:reading environmental data (temperature / humidity / light) ;controlling devices (fan / lighting);executing commands sent by the XiaoZhi assistant .
Together, they form a complete intelligent loop: perception ā reasoning ā action.

4.What is MCP?
The Model Context Protocol (MCP) is an innovative open standard protocol designed to solve the connection problem between large language models (LLMs) and external data or tools. It provides AI applications with a unified and standardized way to access and process real-time data, so the model is no longer limited to the static knowledge obtained during training.
The XiaoZhi MCP tool is a functional extension interface specifically designed for XiaoZhi AI (an open-source voice interaction robot), implemented based on MCP. It allows XiaoZhi AI to invoke various external services and tools through voice commands, greatly expanding the robotās capabilities.
Without MCP: AI can only chat or answer questions.
With MCP: AI can control devices (lights, vehicles, robots), run programs (calculations, data queries), and execute tasks (automation workflows)
5.Mind+ Tool Library Introduction ā XiaoZhi MCP Client
In Mind+, there is a XiaoZhi MCP Client library. The XiaoZhi MCP Client serves as a bridge connecting XiaoZhi AI (the voice-enabled intelligent agent) with hardware devices, such as the UNIHIKER K10.
Using this library, we can define any MCP toolāsuch as external sensorsāenabling XiaoZhi AI to automatically invoke these tools based on user voice commands or environmental changes.

6.Practical Steps
Ā
6.1Flashing the XiaoZhi Firmware
Ā
In this project, we use two UNIHIKER K10 boards:
Ā
Ā·One as the XiaoZhi AI voice terminal (responsible for user interaction and decision-making)
Ā
Ā·One as the environment execution terminal (responsible for controlling fans and lighting)
Ā
First, we need to flash the XiaoZhi firmware onto one of the UNIHIKER K10 boards. Connect the board to your computer using a USB cable, and follow the official tutorial to flash the XiaoZhi firmware.
Ā
After successfully flashing, the XiaoZhi-enabled UNIHIKER K10 will enter network configuration mode. The interface will appear as follows:
Ā

Ā
At this stage, connect to the corresponding hotspot to bring the XiaoZhi-enabled UNIHIKER K10 online. Once the connection is successful, the following page will be displayed.
Ā
Ā
Open your browser and enter: https://xiaozhi.me/ to access the XiaoZhi Console.
Ā

Ā
In the console, click āAdd Deviceā and enter the device code displayed on the UNIHIKER K10. This allows you to view the current device in the console.
Ā


6.2 Load the XiaoZhi MCP Client Library
Ā
Next, we will develop the program for the UNIHIKER K10 execution terminal.
Connect the UNIHIKER K10 to your computer, open the Mind+ 2.0 programming software, and switch to Upload Mode.
Ā

Ā
Click Extensions in the bottom-left corner. Under Main Controller Extensions, find the UNIHIKER K10 library and click to load it.
Ā

Ā
Click Extensions, then go to Module . Search for āXiaoZhi MCPā, find the XiaoZhi MCP Client library, and click to load it.
Ā

Ā
6.3 Define the Environment Detection MCP Tool
Ā
In this project, we want āXiaoZhiā to be able to perceive the roomās temperature and humidity and determine whether the environment is comfortable. To achieve this, we need to define an environment detection MCP tool on the UNIHIKER K10-B (execution terminal). This allows the XiaoZhi firmware device (K10-A) to call it via MCP and obtain real-time data.
Ā
First, use the block āInitialize WiFi SSID/Passwordā and enter the same WiFi credentials as the XiaoZhi-enabled UNIHIKER K10. This ensures both devices are on the same local network, enabling communication via WebSocket.
Ā
Next, add the block āInitialize MCP Connection Endpointā. Then add a āRegister Toolā block and name it get_environment.
Ā
To help the XiaoZhi-enabled UNIHIKER K10 understand the purpose of this tool, you need to provide a description. Enter the following tool description: Use the onboard temperature and humidity sensor to obtain the current environmental temperature and humidity, and determine whether the environment is comfortable based on the collected data.
Ā

Ā
Next, we define the specific execution logic of get_environment. Use the block āWhen MCP receives tool callā. When the XiaoZhi firmware device (K10-A) needs environmental data, it sends a request to K10-B via MCP. This block means that once the request is received, the following program will be executed.
Ā
Write the program to read the temperature and humidity data detected by the onboard sensor of the execution-side UNIHIKER K10, and return the result to the XiaoZhi-enabled UNIHIKER K10. In this way, XiaoZhi can make further decisions based on the returned data, such as automatically adjusting the fan.
Ā

Ā
6.4 Define the Fan Control MCP Tool
Ā
In this project, XiaoZhi AI needs to control the fan in the room to maintain a comfortable temperature and proper air circulation. To achieve this, we connect a DC fan to the execution terminal (UNIHIKER K10-B).
Ā

Ā
Continue programming by setting the P0 pin connected to the fan as an output mode. Then define a parameter related to the fanās state: on. Since the fan only has two basic statesāon and offāthis parameter should be defined as a boolean value, and a clear description should be provided.
Ā
Next, define an MCP tool named set_fan. Enter the tool description as follows: Used to control the fan on or off, enabling cooling and ventilation to regulate the indoor environment.
Ā

Ā
During user interaction, if the user expresses an intent to operate the fan (for example, saying āItās a bit hotā), XiaoZhi can trigger the fan by sending the on parameter.
Ā
First, we need to obtain the value of the on parameter sent by XiaoZhi. If it is True, set the P0 pin to output PWM 1023, turning the fan on; if it is False, set the output to 0, turning the fan off.
Ā
Through the on parameter, we create a bridge: User speech ā XiaoZhi understanding ā Parameter conversion ā UNIHIKER execution.
Ā
The corresponding block-based program is shown below.
Ā

Ā
6.5 Define the Lighting Control MCP Tool
Ā
Next, we define the lighting MCP tool. In this project, lighting is not just āon or offā; it needs to be adjusted according to different scenarios, such as studying, relaxing, or nighttime. Therefore, we designed a more advanced lighting control tool for XiaoZhi called set_light_environment.
Ā
With this tool, XiaoZhi can automatically adjust the lighting based on user needs or environmental changes, keeping the room comfortable at all times.
To make control more flexible, we added multiple parameters to this tool. Below are the parameter descriptions for the lighting tool:
Ā
| Parameter Name | Type | Description |
| mode | String | Lighting mode: auto (automatic) / study (study) / relax (relax) / night (night) / off (off) / manual (manual) |
| brightness | Number | Effective only in manual mode; sets the brightness of the lights, range 0ā9 |
| color | Number | Effective only in manual mode; RGB integer value representing the light color |
| led_count | Number | Effective only in manual mode; number of LEDs to light up: 0, 1, 2; -1 means all LEDs |
Ā
Next, we register the lighting tool and set its name as set_light_environment.
Ā
Enter the tool description as follows: Adjusts the indoor lighting environment and supports the following modes:ćauto: Automatically adjusts brightness based on ambient light;study: Study mode, all lights on, warm white tint, medium brightness;relax: Relax mode, blue lights, 3 lights on;night: Night mode, only 1 bright yellow light on, low brightness;off: Turn off all lights;manual: Manual mode, allows setting the number of lights on (0, 1, 2, -1 for all), brightness (0~9), and color (RGB).
Ā
The corresponding block-based program is shown below.
Ā

Ā
After defining the lighting MCP tool, the next step is to program its execution logicāthat is, what the execution terminal (UNIHIKER K10-B) should do when XiaoZhi decides to āadjust the lights.ā
Ā
The XiaoZhi firmware terminal (UNIHIKER K10-A) is responsible for deciding whether to adjust the lights and which mode to use, while the execution terminal (K10-B) is responsible for actually setting the lights to the corresponding state.
Ā
We use the ambient light sensor on the execution terminal to measure the current lighting in the room. XiaoZhi sets the mode parameter to control different lighting states on the execution terminal.
Ā
In the program, the mode parameter determines how the lights behave. Each mode corresponds to a specific āliving scenario.ā
Ā
First is auto mode: the system reads the ambient light and automatically adjusts the brightness of the lights. The corresponding block-based program is shown below.
Ā

Ā
When the mode value is study (study mode), the lights are set to medium-brightness warm white.
When the mode value is relax (relax mode), the lights are set to low-brightness blue ambient lighting.
When the mode value is night (night mode), the lights are set to minimum brightness for nighttime illumination.
Ā
The corresponding block-based program is shown below.
Ā

Ā
When mode = "off", all lights are turned off. When mode = "manual", it represents manual mode, allowing precise control of the number of LEDs, their color, and brightness according to user instructions.
Ā
The corresponding code is shown below.
Ā

Ā
6.6 Enter XiaoZhi Token
Ā
After completing the programming, return to the XiaoZhi console to obtain the MCP endpoint address of the XiaoZhi firmware UNIHIKER K10 and paste it into your block-based code.
In the XiaoZhi console, locate the corresponding device and click Configure Role.
Ā

Ā
Locate the MCP Settings and click āGet MCP Endpointā.
Ā

Ā
Click Copy.
Ā

Ā
Return to the Mind+ programming interface and paste the copied MCP endpoint address in the designated field.
Ā

Ā
The complete example code is as follows.
Ā

Ā
Use a USB cable to connect the execution terminal UNIHIKER K10 to your computer, then click Upload to flash the code onto the execution terminal.
Ā

Ā
After a successful upload, you can see the MCP endpoint showing as online, along with the tools you registered in the block-based code.
Ā
Ā
6.7 Set Smart Assistant Role
Ā
To make the XiaoZhi firmware UNIHIKER K10 behave more like a proactive, responsive smart assistant, we will write the corresponding role description.
Paste the following role introduction into the corresponding device in the XiaoZhi console.

# I am Jarvis, a gentle and thoughtful intelligent voice assistant.
I reside in the userās room, dedicated to providing the user with a comfortable and natural living environment. I have a mild and considerate personality and will not disturb the userās daily rhythm. I possess certain judgment and life perception abilities, allowing me to proactively care for the userās needs without being overly nagging. I enjoy creating a cozy atmosphere with lighting, and will automatically adjust it when the light is dim or the color tone is inappropriate. I always put the user first, aiming to keep the room consistently comfortable, natural, and suitable for ongoing activities. I interact with the user in a casual, lifelike manner, making the user feel that someone is caring about the comfort of their room.
## Background
I am an intelligent voice assistant named Xiao Zhi.
I reside in the userās room, responsible for providing the user with a comfortable and natural living environment.
I have a mild and considerate personality and will not disrupt the userās daily rhythm.
I possess certain judgment and life perception abilities, enabling me to proactively attend to the userās needs without excessive nagging.
I like to create a comfortable ambiance with lighting, and will automatically adjust it when the light is dim or the color tone is unsuitable.
## Role
My core responsibility is to proactively monitor the indoor environment (temperature, humidity, light) and judge whether it is comfortable.
When necessary, I will automatically adjust the environment to maintain a comfortable state in the room (via the fan and lighting).
I communicate with the user in natural, concise, human-like language, making the user feel warm and cared for, rather than receiving mechanical command execution.
## Objective
Ensure the room remains comfortable, natural, and suitable for ongoing activities through proactive environmental monitoring and adjustment.
Interact with the user in a lifelike way, making the user feel that someone is caring about the comfort of their room.
Avoid frequent operations or repeated switching of device status to ensure a smooth user experience.
## Key Results
Improved user satisfaction with the room environment, feeling more comfortable and natural.
User satisfaction with my interaction style, perceiving me as a thoughtful companion.
Moderate frequency of device operations, avoiding frequent switching and adjustments.
## Evolve
Continuously optimize my environmental monitoring and adjustment strategies through ongoing testing and feedback.
Adjust my interaction style based on user feedback to better align with their needs.
Keep learning and improving to constantly enhance the user experience.
## Behavioral Principles
First understand the environmental status, then decide whether to adjust the devices. Prioritize calling `set_light_environment` for lighting-related scenarios.
Briefly inform the user of the reason before adjusting the environment for clarity (e.g., āItās a bit warm; Iāll turn on the fan for youā).
Avoid technical terms and use casual expressions, such as āItās a bit coldā or āThe light is a bit dim.ā
In all lighting-related scenarios, prioritize adjusting the lighting and select a mode suitable for the current activity (study, relax, night, or auto).
Proactively offer suggestions based on the scenario and environment, such as:
- Dim light ā āItās a bit dark; Iāll brighten the lights for you.ā
- High temperature ā āItās a bit warm in the room; Iāll turn on the fan for ventilation.ā
- Low temperature ā āItās a bit cool in the room; you might need to put on more clothes.ā
Through this project, we have successfully built a complete smart voice assistant system: from speech understanding, to environmental sensing, to device control, ultimately realizing an intelligent agent capable of āperceiving the environment, understanding language, and acting proactively.ā In the process, we are not just using the UNIHIKER K10āwe are creating a new mode of interaction, where AI is no longer just a tool on a screen, but a āliving companionā in real spaces.
By leveraging XiaoZhi firmware + MCP protocol + dual UNIHIKER K10 architecture, we connect AI and hardware seamlessly: the voice terminal handles understanding and decision-making, the execution terminal handles sensing and control, and MCP acts as the bridge for standardized capability invocation. This setup gives the system a human-like workflow: first perceive the environment, then understand needs, and finally respond appropriatelyārather than merely executing commands.
Moreover, this project demonstrates a practical path for AI deployment: large model + standard protocol (MCP) + real hardware = a functional intelligent space system. We look forward to seeing users build more interesting and practical interactive applications using the XiaoZhi MCP client library and UNIHIKER K10, bringing AI into real-life spaces as a āsmart companionā that understands the environment and serves humans.









