Welcome to Raspberry Pi 5 repository
4. AI Pet
OpenClaw AI Pet Tutorial
Before starting, please complete [01-Peripheral Hardware Configuration], [02-OpenClaw API-KEY Configuration], [03-OpenClaw Model Switching], [04-AI Voice Interaction Configuration], and [05-Three Dialogue Configuration Tests] in the
Preparation Before Usedirectory. If you are only using TUI/WhatsApp, you can skip04. This article assumes the basic environment is ready and only covers the AI pet project itself.
1. Tutorial Objectives
This article demonstrates OpenClaw's interactive capability as a desktop AI pet through the combination of "actions + lights + screen + dialogue". After completing this tutorial, readers will be able to:
- Understand how to create an AI pet with emotional feedback using servo, RGB, and OLED
- Communicate with OpenClaw via WhatsApp, TUI, and voice commands
- Complete four project scenarios: greeting, emotional expression, companionship Q&A, sleep and wake
2. Hardware Preparation
- OpenClaw main control board
- Servo
[recommended at least 1 unit] - RGB light strip / RGB LED module
- OLED display screen
[Optional] AI voice module + speaker- Wiring diagram

3. Software Preparation
Code entry points used in this tutorial:
- Servo control command:
/home/pi/hardware_hal_demo/cli/servo - Voice entry:
/home/pi/voice_to_openclaw/src/main.py
This project does not have a fixed set of "pet scripts", but lets OpenClaw orchestrate several basic peripheral actions:
- Servo is responsible for nodding, head shaking, and swinging
- RGB is responsible for expressing mood and status
- OLED is responsible for displaying names, expressions, or short text
- Voice dialogue is responsible for making the pet more like an interactive character
4. Testing Project Basic Capabilities
Before starting this project, please complete an openclaw tui basic conversation self-check first; if you haven't done this yet, see [05-Three Dialogue Configuration Tests]. After passing, proceed with the AI pet project-specific test.
Enter OpenClaw TUI:
openclaw tui
Then separately test several basic capabilities:
- Make the servo nod
- Change the lights to pink breathing light
- Display "Hello" on OLED
5. Three Ways to Communicate with OpenClaw
| Method | Suitable Scenario | Advantages | Suggested Use |
|---|---|---|---|
| Remote interaction, classroom demonstration | Suitable for demonstrating "remote pet keeping" | Demonstrate character interaction capability | |
| TUI | Local debugging, action verification | Easiest to check if actions and feedback match | First to get character action logic working |
| Voice Code | Ultimate interactive experience | Most like a real chatty desktop pet | As the final demonstration solution |
If you have the optional AI voice module + speaker, the TUI and WhatsApp conversations need to broadcast OpenClaw's replies. You can run the following program in the terminal. This is not needed for AI voice module conversations.
- Modify the TTS enable parameter
xxxxxxxxxx/home/pi/voice_to_openclaw/.env
xxxxxxxxxxENABLE_TTS=true # This parameter controls whether to broadcast replies. After saving, run the program below in the terminal.- Terminal input
xxxxxxxxxxcd ~/voice_to_openclawsource .venv/bin/activatepython -m src.openclaw_session_tts
5.1 WhatsApp Solution
For WhatsApp integration and bot creation steps, please refer directly to [05-Three Dialogue Configuration Tests]. After creating, you can interact with the AI pet remotely in WhatsApp, for example:
- Take a photo to see if there is dog food. If yes, display smile expression on OLED, make servo dance, and light up ambient lights on OLED. If no dog food, display sad expression on OLED.

5.2 TUI Solution
If you have already completed the TUI self-check from chapter 0, directly enter terminal text dialogue:
xxxxxxxxxxopenclaw tuiThen input project-related commands, for example:
- Take a photo to see if there is dog food. If yes, display smile expression on OLED, make servo dance, and light up ambient lights on OLED. If no dog food, all servos shake heads simultaneously.

5.3 Voice Code Solution
xxxxxxxxxxRequires optional AI voice interaction module + speaker
For voice module installation, environment configuration, and basic wake-up flow, please refer directly to [04-AI Voice Interaction Configuration]. After waking up, you can directly speak control content, for example:
- Take a photo to see if there is dog food. If yes, display smile expression on OLED. If no dog food, display sad expression on OLED.

6. Project Implementation
Note: All demonstrations below use the openclaw tui method for conversation. You can also choose WhatsApp or voice to complete.
6.1 Scenario 1: Greeting
Experiment Objective
Have the AI pet respond with actions and text feedback when the user sends a greeting.
Effect Description
The servo can do a simple nodding or head-shaking action, OLED displays welcome text, and RGB lights up with soft colors, so the feeling of the pet "appearing" will be very obvious.
Example Commands
- Have the little pet say hello to me
- Have the pet welcome me
6.2 Scenario 2: Emotional Expression
Experiment Objective
Have the AI pet express states such as happy, quiet, angry, and sleepy using lights and screen.
Effect Description
This scenario is most suitable for reflecting "character feeling". For example, warm-colored breathing light when happy, blue glow when sleepy, and only short status when quiet.
Example Commands
- Have the pet enter happy state
- Draw simple expressions on OLED
6.3 Scenario 3: Companionship Q&A
Experiment Objective
Have the AI pet, in addition to being able to move, respond to questions like a desktop companion character.
Effect Description
OpenClaw can first complete the dialogue, then combine with servo nodding, head shaking, and screen text to make "speaking" and "actions" happen simultaneously, making it look more like a character with personality.
Example Commands
- First answer my question, then nod
- If you agree, express it with actions
- Chat with me about today's mood
6.4 Scenario 4: Sleep and Wake
Experiment Objective
Have the AI pet have the ability to switch between standby, sleep, and wake states.
Effect Description
In sleep mode, most lights can be turned off, keeping only low-brightness status; when waking up, restore lights, screen, and action feedback, making the project more complete.
Example Commands
- Have the pet enter sleep mode
- Wake up the pet