Welcome to Jetson Orin NX SUPER repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
6. AI Script Peripheral Control
OpenClaw AI Script Writing for Peripheral Control Tutorial
Before starting, please complete the following in the
Pre-use Preparationdirectory: [01-Peripheral Hardware Configuration], [02-OpenClaw Ajetson-KEY Configuration], [03-OpenClaw Model Switching], [04-AI Voice Interaction Configuration], [05-Three Dialogue Scheme Configuration Test]. If you are currently only using TUI / WhatsApp, you can skip04for now. This article assumes the basic environment is already prepared and only covers the AI script generation feature.
1. Tutorial Objective
This article demonstrates through "natural language hardware script generation" that OpenClaw can not only directly control peripherals but also generate reusable script files from your control logic. After completing this tutorial, readers will be able to:
- Understand the basic approach of OpenClaw generating hardware control scripts
- Interact with OpenClaw through three methods: WhatsApp, TUI, and voice interaction
- Generate four types of common scripts: RGB, servo, temperature and humidity, OLED
2. Hardware Preparation
- OpenClaw main control board
- Servo / RGB light strip / OLED / DHT temperature and humidity sensor
[Optional] AI voice module + speaker
Description:
- This tutorial does not require connecting all peripherals at once
- Connect the corresponding hardware first depending on which type of script you plan to demonstrate
3. Software Preparation
Code entry points used in this tutorial
- Script generation skill:
/home/jetson/.openclaw/workspace/skills/script-runner/SKILL.md - Default script save directory:
/home/jetson/Desktop/ - Hardware command examples directory:
/home/jetson/hardware_hal_demo/ - Voice entry:
/home/jetson/voice_to_openclaw/src/main.py
The core of this capability is not "executing an instant command" but having OpenClaw generate a standalone Python script for you. According to the existing skill conventions:
- When the user says "generate script", "write a script", or "save to desktop", it will prioritize using
script-runner - Hardware scripts use
openclaw_libby default - The default serial port is
/dev/ttyTHS1 - The default baud rate is
115200 - Scripts are typically saved in
/home/jetson/Desktop/
You can understand this as two usage modes:
- Mode 1: Generate script and run immediately
- Mode 2: Only generate the script and save it to the desktop for later modification or execution
4. Testing Script Generation Capability
Before starting this tutorial, please complete a basic openclaw tui dialogue self-check first; if you haven't done so, see [05-Three Dialogue Scheme Configuration Test]. After confirming that OpenClaw can reply normally, proceed to the script generation-specific test.
Enter the following command in the terminal to enter TUI:
openclaw tui
It is recommended to start with the simplest script requests, for example:
- Help me write a script to make the RGB red light blink 5 times, save to desktop and run
- Generate a script to read temperature and humidity, don't run it yet
- Write a script to make servo 1 swing back and forth between 0, 90, and 180 degrees
- Generate a script to display "Hello OpenClaw" on the OLED
5. Three Schemes for Communicating with OpenClaw
| Scheme | Suitable Scenarios | Advantages | Recommended Use |
|---|---|---|---|
| Remote requests, classroom demonstration | Can describe the desired script in natural language | Used to demonstrate natural language generation capability | |
| TUI | Local debugging, verify generation results | Easiest to observe script generation and execution output | Preferred debugging scheme |
| Voice code | Voice interaction, complete AI experience | Can verbally describe script needs | As a complete demonstration scheme |
If you have the optional AI voice module + speaker, Feishu dialogue, TUI, and WhatsApp dialogue need to play back OpenClaw's replies via TTS. You can run the following program in the terminal. The AI voice module dialogue does not need to run this repeatedly.
- Modify the TTS toggle parameter
xxxxxxxxxx/home/jetson/voice_to_openclaw/.env
xxxxxxxxxxENABLE_TTS=true #This parameter controls whether to broadcast. After modifying and saving, run the following program in the terminal- Enter in terminal
xxxxxxxxxxcd ~/voice_to_openclawsource .venv/bin/activatepython -m src.openclaw_session_tts
5.1 whatsapp Scheme
For WhatsApp connection steps, please directly refer to [05-Three Dialogue Scheme Configuration Test]. This section only includes dialogue examples suitable for the script generation tutorial.
You can directly converse, for example:
- Generate a script for the servo to swing left and right for 10 seconds and run it

5.2 TUI Scheme
If you have completed the TUI self-check in Part 0, simply enter the following command in the terminal to continue the conversation:
xxxxxxxxxxopenclaw tuiThen you can directly enter script requests, for example:
Help me write a script to control RGB to become a blue breathing light and run it
)
5.3 Voice Code Scheme
xxxxxxxxxxRequires optional AI voice interaction module + speaker
For voice module installation, environment configuration, and basic wake-up process, please directly refer to [04-AI Voice Interaction Configuration]. After wake-up, you can issue voice commands directly, for example:
- Write a script to display the current temperature and humidity on the screen and run it

6. Comprehensive Cases
Note: The following are all demonstrated using the openclaw tui method. You can also choose WhatsApp or voice methods to complete them.
6.1 Case 1: RGB Blink Script
Experimental Objective
Have OpenClaw generate a basic light script to verify the "script creation + peripheral execution" chain.
Effect Description
OpenClaw will organize your natural language requirements into a Python script. After the script is saved to the desktop, you can run it directly or keep it for later modification.
Example Instructions
- Help me write a script to make the RGB red light blink 5 times
- Generate a blue breathing light script, save to desktop and run
- Write a script to make RGB do a rainbow light effect
6.2 Case 2: Servo Action Script
Experimental Objective
Generate a servo action script to turn a one-off conversational action into a reusable script.
Effect Description
This type of script is suitable for actions like "nod", "shake head", "swing back and forth", and "return to center", and is also suitable for further expansion into classroom demonstrations or combined projects.
Example Instructions
- Write a script to make servo 1 rotate back and forth among 0, 90, and 180 degrees
- Generate a servo nodding script
- Help me write a script to make four servos return to 90 degrees together
6.3 Case 3: Temperature and Humidity Reading Script
Experimental Objective
Generate a script that reads the current temperature and humidity and outputs the results.
Effect Description
This type of script is suitable for sensor self-checks, data sampling, or subsequent log recording, and is also the most commonly used basic script type for scheduled tasks later.
Example Instructions
- Generate a script to read temperature and humidity, save to desktop
- Help me write a script to print the current temperature and humidity
- Write a script to read DHT data once and run it
6.4 Case 4: OLED Display Script
Experimental Objective
Generate a script that displays text or metric content on the OLED.
Effect Description
This case is suitable for welcome pages, status pages, and simple dashboards, and is also the foundation for integrating with temperature/humidity sensors, cameras, and other capabilities later.
Example Instructions
- Help me write a script to display "Hello OpenClaw" on the OLED
- Generate a script to display temperature and humidity on the OLED
- Write a script to display a page of simple status information
6.5 Case 5: Combined Script
Experimental Objective
Have OpenClaw generate a comprehensive script that includes multiple peripheral actions at once.
Effect Description
This type of script can chain together "read sensor", "display on OLED", "control RGB", and "drive servo", making it suitable for transitioning from single peripheral control to small project scripts.
Example Instructions
- Write a comprehensive script: read temperature and humidity then display on OLED
- Generate a script: first turn on green light, then rotate servo to 90 degrees
- Help me write a script: if temperature is too high, turn on red light and show alert on OLED