[UNIHIKER K10 + ESP-Claw] Enable Your ESP-Claw AI Agent to Work with Any DFRobot Sensor
Preface to the UNIHIKER K10 and ESP-Claw Project:
1.ESP-Claw AI Agent Deployment on UNIHIKER K10 (ESP32-S3)
2.UNIHIKER K10 + ESP-Claw: Build a Perceptive and Proactively Responsive AI Desktop Butler
1. Project Overview
Through previous tutorials, you have learned how to deploy ESP-Claw on the UNIHIKER K10 (and other ESP32-series development boards) and build an AI Agent capable of environmental perception, demand comprehension and proactive task execution. Whether it involves reading sensor data, controlling peripherals, or triggering automatic responses to environmental changes, ESP-Claw transforms these development boards from basic hardware platforms into intelligent partners that interact with the physical world.
As you connect more hardware components, you may encounter an issue: some sensors work right after wiring, while others remain unrecognizable by ESP-Claw even with perfectly correct wiring. In fact, ESP-Claw can identify and control hardware only when it is equipped with corresponding Skills. A Skill acts as a textbook that teaches the AI Agent hardware knowledge, informing ESP-Claw how to initialize a sensor, read or manipulate hardware signals, and expose such functionalities to the Agent via natural language. ESP-Claw can truly "master" a piece of hardware only when the matching Skill is available.
This document takes the UNIHIKER K10 (ESP32-S3) as an example to demonstrate how to rapidly create custom Skills for any DFRobot sensor using the espclaw-skill-writer tool. The Skill development workflow covered herein is also applicable to other ESP32-series boards compatible with ESP-Claw. After finishing this tutorial, you will no longer be limited to sensor modules natively supported by ESP-Claw. Instead, you can train your ESP-Claw Agent to operate a wider range of hardware and build highly customizable, expandable AI Agents.
Notably, if you have deployed AI Agents such as OpenClaw and Hermes on your computer, you may install espclaw-skill-writer as an Agent tool (Skill). It automates driver analysis, Skill generation and Lua file completion through natural language interactions, streamlining the entire ESP-Claw sensor Skill development process into a collaborative dialogue with AI.
2. Understanding Sensor Skills
If ESP-Claw is our AI assistant, then Skills serve as its learning materials that teach the AI how to utilize specific capabilities. A Sensor Skill can be regarded as a dedicated set of learning documents tailored for a single sensor. By loading this document, ESP-Claw is able to identify the sensor, grasp its functional scope, and establish communication with it.
For instance, once ESP-Claw loads the Skill for the SFA40 carbon dioxide (CO₂) sensor, it gains the ability to read ambient CO₂ concentration, temperature and humidity values. With the UNIHIKER K10 as the main controller, you can then develop a wide array of air quality monitoring projects, such as real-time indoor and outdoor air quality display and monitoring, or an automated air purification system. In short, with the corresponding Sensor Skill in place, ESP-Claw can fully learn to operate the target hardware via any ESP32-series main controller.
So what exactly does a Sensor Skill consist of? What tasks do we need to complete when developing a new Sensor Skill? With these questions in mind, let’s first take a look at what a complete Sensor Skill looks like.
Taking the STCC4 CO₂ Sensor Skill from the official ESP-Claw Skills Lab as an example, we can examine the structure of a typical Sensor Skill:
dfrobot_stcc4_i2c
│
├── SKILL.md
│
└── scripts
└── read_sensor_data.luaSKILL.md: This file defines the identity of the sensor for the AI, acting as an instruction manual readable by ESP-Claw. It informs the AI of the sensor type, its available functional capabilities, applicable usage scenarios, and the correct methods to invoke its corresponding functions.

Lua Scripts:Lua scripts teach the AI how to drive the sensor. Simply letting the AI know basic information about the sensor is insufficient — the AI also needs to physically retrieve sensor data, a task handled entirely by Lua scripts. ESP-Claw invokes the sensor's library functions via Lua scripts to carry out operations including sensor initialization and data acquisition.
3. How to Write a Sensor Skill
Now that you have learned the structure of a Sensor Skill, you should understand that ESP-Claw can only operate a sensor after loading its matching Sensor Skill. This raises a key question: what should you do if no official Skill is available for your sensor?
The solution is straightforward: create a custom Skill by yourself.
This may sound complicated, but there is no need to write all files from scratch. To help developers quickly integrate new DFRobot sensors, DFRobot officially provides an automated tool called espclaw-skill-writer.
This tool automatically parses sensor driver libraries hosted on DFRobot’s GitHub repository and generates Skill frameworks compliant with ESP-Claw specifications, handling most repetitive tasks automatically, including:
- · Searching for the official driver repository matching the target sensor
- ·Downloading driver source code
- ·Analyzing sensor interfaces
- ·Auto-generating the SKILL.md file
- ·Auto-generating template Lua scripts
In short, it takes care of the most tedious and error-prone repetitive work during Skill development, allowing you to focus solely on sensor-specific business logic.
The overall development workflow can be summarized as follows:
1. Locate the official driver
↓
2. Generate the Skill scaffold
↓
3. Supplement sensor-specific logic in Lua files
↓
4. Deploy to UNIHIKER K10 with ESP-Claw for testingNext, this tutorial will walk you through the entire process of developing your first custom Sensor Skill step by step using the espclaw-skill-writer tool, starting with environment setup. Finally, we will deploy the finished Skill onto the UNIHIKER K10 running ESP-Claw for functional verification.
Tip: If you have already deployed AI Agents that support tool calling such as OpenClaw and Hermes on your computer, you do not even need to manually run the Python commands described later. You may skip ahead to Section 4 "Install the espclaw-skill-writer Skill for AI Agents". Through natural language conversations, the AI Agent can automatically complete driver analysis, Skill generation, Lua file filling and other related tasks.
3.1 Environment Preparation
- Install Python 3.8 on your computer
- Install Git on your computer with access to https://github.com/DFRobot
- Download espclaw-skill-writer Open the espclaw-skill-writer repository link: https://github.com/YeezB/espclaw-skill-writer and click Download.

Once the download finishes, extract the compressed file. The directory structure after extraction is shown in the figure below.

3.2 Generate Your First Sensor Skill
Next, we will walk you through the step-by-step creation of your first custom Sensor Skill using espclaw-skill-writer. We will use the DFRobot formaldehyde sensor as a demonstration to cover the full workflow. Upon completing this section, you will obtain a functional Skill for the formaldehyde sensor, which can be deployed to UNIHIKER K10 running ESP-Claw. The AI Agent will then be able to directly access the formaldehyde sensor wired to the UNIHIKER K10 and read formaldehyde concentration data for environmental monitoring. The whole process consists of only four steps:
1. Search for the matching driver library of the sensor
↓
2. Generate Skill files
↓
3. Manually refine the Lua files
↓
4. Deploy to UNIHIKER K10 with ESP-Claw for testingStep 1: Search for the Sensor's Matching Driver Repository
Before generating a Skill, you need to locate the official DFRobot driver library for your target sensor. The sensor driver library consists of official sensor driver code developed by DFRobot, which defines how the microcontroller communicates with the SFA40 sensor. Open-source driver code for most DFRobot sensors is publicly available on GitHub.
We will use the Gravity: SFA40 Formaldehyde (HCHO) Sensor as the demonstration device. When you open the product Wiki page on the DFRobot store, the link to its corresponding GitHub driver repository is generally placed at the bottom of the page.
For the SFA40 sensor, its official driver repository is DFRobot_SFA40 GitHub repository, where "sfa40" serves as the keyword for this formaldehyde sensor. The official DFRobot_SFA40 library implements core functions including sensor initialization, measurement triggering, and reading formaldehyde concentration, temperature and humidity values. The espclaw-skill-writer tool parses these driver files to automatically generate Skill frameworks compatible with ESP-Claw.

Locate the extracted espclaw-skill-writer folder. Right-click any blank space inside the folder, enter `cmd` and press Enter to quickly open a command prompt window pointing to this directory.

After opening CMD, enter the following command:
python .\scripts\create_espclaw_skill.py --sensor "sfa40" --list-onlyThe full command serves to search the DFRobot GitHub for driver repositories related to SFA40 and display the search results for confirmation. After execution, espclaw-skill-writer will automatically search DFRobot's GitHub repositories for SFA40-related driver libraries and return matching entries. As shown in the figure below, this indicates the driver library for the formaldehyde sensor has been successfully retrieved.

What if you are working with a different sensor? Simply replace "sfa40" with the keyword corresponding to your target sensor. In most cases, the keyword is the core identifier contained in the name of the DFRobot GitHub driver repository. Example: Search for the BMM350 magnetometer:
python .\scripts\create_espclaw_skill.py --sensor "bmm350" --list-onlySearch for the SSD1306 OLED display:
python .\scripts\create_espclaw_skill.py --sensor "ssd1306" --list-onlyStep 2: Generate the Sensor's Corresponding Skill
Once you confirm the target driver repository appears in the search results, you can proceed to generate the Skill. Taking the SFA40 formaldehyde sensor as an example, run the following command:
python .\scripts\create_espclaw_skill.py --sensor "sfa40" --repo "DFRobot/DFRobot_SFA40"Here, `--sensor "sfa40"` specifies that the Skill to be generated corresponds to the SFA40 formaldehyde sensor. `--repo "DFRobot/DFRobot_SFA40"` indicates that the official DFRobot SFA40 driver repository will be used for parsing. After running the command, espclaw-skill-writer will automatically complete the following tasks:
1. Download the driver repository
↓
2. Parse the sensor driver code
↓
3. Extract interface information
↓
4. Generate Skill directory structure
↓
5. Generate SKILL.md
↓
6. Generate Lua script templateIf the execution succeeds, you will see output similar to the following:

Meanwhile, the corresponding files will be generated in the current directory. The existence of the newly created folder means a formaldehyde sensor Skill that complies with ESP-Claw specifications has been fully generated.

components
└── common
└── skill_builder
└── skills
└── dfrobot_sfa40_i2c
├── SKILL.md
└── scripts
└── read_sensor_data.luaStep 3: Manually Complete the Lua File
After running espclaw-skill-writer, the Skill directory and Lua files for the formaldehyde sensor are generated, yet these files are merely a Skill scaffold. A "scaffold" refers to the basic framework for Skill development: it pre-builds the Skill directory structure, generates SKILL.md and read_sensor_data.lua, and implements generic code including I2C initialization, parameter parsing and error handling. Developers still need to manually configure the sensor's communication address and parameter output format. For instance: What is the default I2C address of the SFA40? How to read formaldehyde (HCHO) data? In what format should the results be returned to the AI Agent in the end? All these details need to be supplemented manually in the Lua file. Open the newly generated folder `dfrobot_sfa40_i2c`:
scripts/read_sensor_data.luaYou can see the default configurations at the top of the file as shown below:
```lua
local DEFAULT_I2C_PORT = 0
local DEFAULT_SDA = 47
local DEFAULT_SCL = 48
local DEFAULT_I2C_FREQ_HZ = 400000
local DEFAULT_ADDR = 0x00The highest priority item to check here is the sensor address.
```lua
local DEFAULT_ADDR = 0x00The value `0x00` here is merely a placeholder automatically generated by the tool and does not represent the actual I2C address of the sensor. Therefore, when developing a Skill for any sensor, the first step is to check the official driver library to confirm the real communication address of the sensor. Take the SFA40 as an example; you can find the valid address definition in the header file of DFRobot's official SFA40 driver library:

#define SFA40_I2C_ADDR 0x5DAccordingly, modify the Lua file as follows:

local DEFAULT_I2C_PORT = 0
local DEFAULT_SDA = 47
local DEFAULT_SCL = 48
local DEFAULT_I2C_FREQ_HZ = 400000
local DEFAULT_ADDR = 0x5DAfter modification, ESP-Claw will be able to correctly detect the SFA40 sensor connected to the Hummingbird K10 board. Scroll down further and you will see the existing code snippet. This code only implements the following functions: initializing the I2C bus for the formaldehyde sensor, connecting to the sensor device, and printing debug logs. However, the following core logic is still missing: configuring the SFA40 I2C address, triggering measurement acquisition, reading formaldehyde concentration values, reading temperature, and reading humidity. As a result, no valid sensor readings can be obtained even after uploading this file to ESP-Claw.
local function run()
local i2c_port = parse_int_arg("i2c_port", DEFAULT_I2C_PORT, 0, 1)
local sda = parse_int_arg("sda", DEFAULT_SDA, 0, 63)
local scl = parse_int_arg("scl", DEFAULT_SCL, 0, 63)
local i2c_freq_hz = parse_int_arg("i2c_freq_hz", DEFAULT_I2C_FREQ_HZ, 10000, 1000000)
local addr = parse_int_arg("addr", DEFAULT_ADDR, 0x08, 0x77)
local bus = nil
local dev = nil
local ok, err = xpcall(function()
bus = i2c.new(i2c_port, sda, scl, i2c_freq_hz)
dev = bus:device(addr)
print(string.format(
"[dfrobot_sfa40_i2c] scaffold ready sensor=sfa40 addr=0x%02X",
addr
))
print("[dfrobot_sfa40_i2c] TODO: implement register/protocol reads")
end, debug.traceback)
cleanup(dev, bus)
endStep 3: Complete the Lua File
Next, you need to add the actual sensor data reading code according to the implementation logic in the official driver. If you are familiar with C++, I2C and sensor development, you can directly refer to the `.h` and `.cpp` files in the official sensor repository to get the driver logic and complete the Lua porting work by yourself.

For this step, it is more recommended to use AI tools such as ChatGPT, Claude or Cursor to simplify the work. Upload the following files to the AI tool (e.g. ChatGPT):
DFRobot_SFA40.cpp
DFRobot_SFA40.h
read_sensor_data.luaThen use the following prompt: This is the official driver library of DFRobot SFA40 formaldehyde sensor.
Please analyze the driver implementation and generate a Lua file for ESP-Claw Skill.
Requirements:
1. Communicate via the i2c module of ESP-Claw
2. Compatible with UNIHIKER K10
3. Set the default address to 0x5D
4. Reserve the following configurable parameters:
- i2c_port
- sda
- scl
- addr
5. Implement complete functions:
- Sensor initialization
- Start measurement
- Read HCHO concentration
- Read temperature value
- Read humidity value
6. Return data in JSON format as shown below:
{
"hcho": xxx,
"temperature": xxx,
"humidity": xxx
}
7. Keep all error handling logic
8. Output the full complete read_sensor_data.lua fileReplace the original prompt code block with the code provided by AI. Locate the position of the code snippet shown below.
print("[dfrobot_sfa40_i2c] TODO: implement register/protocol reads")Replace it with the SFA40 initialization and data reading code generated by AI. The final structure should be similar to the example below:
------------------------------------------------------------
-- Main
------------------------------------------------------------
local function run()
local i2c_port =
parse_int_arg(
"i2c_port",
DEFAULT_I2C_PORT,
0,
1
)
local sda =
parse_int_arg(
"sda",
DEFAULT_SDA,
0,
63
)
local scl =
parse_int_arg(
"scl",
DEFAULT_SCL,
0,
63
)
local i2c_freq_hz =
parse_int_arg(
"i2c_freq_hz",
DEFAULT_I2C_FREQ_HZ,
10000,
1000000
)
local addr =
parse_int_arg(
"addr",
DEFAULT_ADDR,
0x08,
0x77
)
local bus = nil
local dev = nil
local ok, err = xpcall(function()
--------------------------------------------------------
-- Init I2C
--------------------------------------------------------
bus = i2c.new(
i2c_port,
sda,
scl,
i2c_freq_hz
)
dev = bus:device(addr)
if not dev then
error(
string.format(
"SFA40 not found at 0x%02X",
addr
)
)
end
--------------------------------------------------------
-- Start Measurement
--------------------------------------------------------
write_command(dev, CMD_START)
if sys and sys.wait then
sys.wait(100)
end
--------------------------------------------------------
-- Read Data
--------------------------------------------------------
local b = read_measurement(dev)
--------------------------------------------------------
-- Status
--------------------------------------------------------
local status = b[11]
if status ~= 0 then
if (status & 0x01) ~= 0 then
error("sensor not ready")
end
if (status & 0x02) ~= 0 then
error("sensor out of specification")
end
error(
string.format(
"sensor status=0x%02X",
status
)
)
end
--------------------------------------------------------
-- CRC Verify
--------------------------------------------------------
if calc_crc(b[1], b[2]) ~= b[3] then
error("HCHO CRC failed")
end
if calc_crc(b[4], b[5]) ~= b[6] then
error("Humidity CRC failed")
end
if calc_crc(b[7], b[8]) ~= b[9] then
error("Temperature CRC failed")
end
--------------------------------------------------------
-- Parse HCHO
--------------------------------------------------------
local raw_hcho =
b[1] * 256 +
b[2]
local hcho =
raw_hcho / 10.0
--------------------------------------------------------
-- Parse Humidity
--------------------------------------------------------
local raw_humidity =
b[4] * 256 +
b[5]
local humidity =
125.0 *
(raw_humidity / 65535.0) -
6.0
if humidity < 0 then
humidity = 0
end
if humidity > 100 then
humidity = 100
end
--------------------------------------------------------
-- Parse Temperature
--------------------------------------------------------
local raw_temperature =
b[7] * 256 +
b[8]
local temperature =
175.0 *
(raw_temperature / 65535.0) -
45.0
--------------------------------------------------------
-- JSON Output
--------------------------------------------------------
print(
string.format(
'{"hcho":%.1f,"temperature":%.2f,"humidity":%.2f}',
hcho,
temperature,
humidity
)
)
--------------------------------------------------------
-- Stop Measurement
--------------------------------------------------------
write_command(dev, CMD_STOP)
end, debug.traceback)
cleanup(dev, bus)
if not ok then
print(
string.format(
'{"error":"%s"}',
tostring(err):gsub('"', "'")
)
)
error(err)
end
end
run()Once this step is finished, we will obtain a fully functional Skill that can read real sensor data. Afterwards, simply upload the Skill to the UNIHIKER K10 with ESP-Claw firmware for testing. This identical development workflow can be reused when integrating new gas sensors, environmental sensors, magnetometers or display modules in the future.
Step 4: Deploy to ESP-Claw UNIHIKER K10 for Testing
After generating and editing the Skill files, the final step is deploying them to the ESP-Claw UNIHIKER K10 to verify whether the board can correctly acquire data from the SFA40 sensor. 1. Connect your computer to the Wi-Fi hotspot broadcast by the ESP-Claw UNIHIKER K10. 2. Once connected, your browser will automatically redirect to the ESP-Claw management dashboard at the address: http://192.168.4.1/

Click **Files** in the left sidebar menu to enter the file management page.

Then click **skills** to enter the Skill storage directory.

By default, the Skill directory is protected. Developer Mode must be enabled to make edits. Click **DevMode** in the top-right corner to turn it on. After activation, you can create, upload and modify Skill folders.

Create a new folder named `dfrobot_sfa40_i2c` consistent with the Skill name we generated, then enter this folder after creation.

Upload the revised SKILL.md file to the path: skills/dfrobot_sfa40_i2c/

Click the Upload button and select the local SKILL.md file. After uploading, the directory structure will be as follows:
skills
└── dfrobot_sfa40_i2c
└── SKILL.md
Next, create a new folder named `scripts` inside the `dfrobot_sfa40_i2c` directory to store Lua scripts.

Upload the file `/skills/sfa40/scripts/read_sensor_data.lua` to the `scripts` folder.

After the upload is complete, the final directory structure should match the one shown below. If consistent, the Skill has been successfully deployed into ESP-Claw.
skills
└── dfrobot_sfa40_i2c
├── SKILL.md
└── scripts
└── read_sensor_data.luaReturn to the ESP-Claw chat page. ESP-Claw now supports reading data from the SFA40 sensor. You may enter the following command for testing:
‘ Read the current HCHO concentration.’
‘Check indoor air quality.’
If your Skill description is properly written, the Lua script runs without errors, and the SFA40 sensor is correctly wired to the UNIHIKER K10, ESP-Claw will automatically invoke the newly deployed Skill, fetch sensor readings and return the measured data.

At this point, you have fully completed the entire development workflow for an ESP-Claw sensor Skill:
Locate official sensor driver
↓
Generate Skill template scaffold
↓
Complete Lua script and SKILL configuration file
↓
Deploy files to UNIHIKER K10
↓
Call sensor via natural language dialogueCongratulations! If you have followed through all the steps above, you have not only learned how to write a dedicated Skill for the SFA40 formaldehyde sensor, but also mastered the universal workflow for integrating new hardware with ESP-Claw. Moving forward, you can rapidly expand support for any DFRobot sensors—including air quality detectors, magnetometers, environmental monitoring modules, OLED screens, GPS units and more—by following this identical process, enabling your ESP-Claw UNIHIKER K10 to interact with nearly all DFRobot hardware.
4. Install the espclaw-skill-writer Skill for AI Agent
In the previous tutorial, we generated the Skill scaffold manually via command line step by step. If you have deployed a local AI Agent such as OpenClaw or Hermes on your computer, there exists a much more streamlined alternative workflow. You no longer need to memorize Python commands or manually locate code repositories. Simply provide the GitHub repository link of `espclaw-skill-writer` to your AI Agent, and it will handle the entire Skill generation process through natural language instructions. Sample prompt you can send directly to your AI Agent: Please install and utilize this tool: https://github.com/YeezB/espclaw-skill-writer Generate an ESP-Claw compatible Skill for DFRobot SFA40 formaldehyde sensor. The official repository of SFA40: https://github.com/DFRobot/DFRobot_SFA40
Generate an ESP-Claw-compatible Skill files for DFRobot SFA40 formaldehyde sensor.
Official repository: https://github.com/DFRobot/DFRobot_SFA40
The AI Agent will automatically parse your requirements and complete all the multi-step operations that previously required manual execution, including:
Install espclaw-skill-writer tool
↓
Analyze DFRobot official driver repository
↓
Generate SKILL.md configuration file
↓
Generate Lua script scaffold template
↓
Complete sensor initialization logic
↓
Complete sensor data reading process
↓
Output full set of finished Skill filesThe AI Agent can directly generate all Skill files required for the formaldehyde sensor, including SKILL.md and read_sensor_data.lua, as well as parameter definitions and calling instructions, plus complete communication logic adapted from the official driver. This means you do not need to fully understand all underlying driver code or manually write Lua scripts. Simply describe your requirements in natural language, and you can quickly get a usable sensor Skill for ESP-Claw.

As you can see, the AI Agent can automatically generate all Skill files for the formaldehyde sensor with one click.

Of course, it is still recommended to perform a brief verification on the AI-generated files, including the following checks: 1. Whether the default I2C address is correct 2. Whether the initialization process matches the official driver logic 3. Whether the returned data format meets the expected standard After confirming everything is correct, follow the deployment steps mentioned earlier: upload the AI-generated SKILL.md and read_sensor_data.lua to the corresponding Skill directory in the ESP-Claw backend, then finish deployment and testing.
As demonstrated, this method streamlines the entire workflow that originally required repository searching, script writing and driver code reading into a single natural language conversation with the AI Agent. Powered by the espclaw-skill-writer-master tool, the AI is not merely able to control hardware, but also capable of learning and expanding hardware compatibility. Once you install this tool on your local AI Agent, you can generate a matching Skill with just one sentence, continuously equipping your ESP-Claw UNIHIKER K10 with new hardware functions.
5. Appendices Appendix
1: Ready-to-use formaldehyde sensor Skill files completed in this tutorial.
2: ESP-Claw sensor development tool file — espclaw-skill-writer-master








