Welcome to RDK X5 Board repository
7. Scheduled Tasks
OpenClaw scheduled task tutorial
Before starting, please complete [01-Peripheral hardware configuration], [02-openclaw API-KEY configuration], [03-openclaw switching model], [04-OpenClaw prompt words], [05-AI voice interaction configuration], [06-Three dialogue scheme configuration tests] in the
Preparation before usedirectory. If you are currently only using TUI/WhatsApp, you can skip05first. By default, the basic environment of this article has been prepared and only the "automatic execution of scripts at fixed time" section will be expanded.
1. Tutorial Objectives
This article uses the method of "AI generated script + Linux scheduled execution" to show how OpenClaw can be further upgraded from real-time dialogue to automated peripheral applications. After completing this tutorial, readers will be able to:
- Understand the basic implementation ideas of OpenClaw scheduled tasks
- Distinguish the appropriate scenarios for
HEARTBEATandcron - Describe automation requirements through three methods: WhatsApp, TUI, and voice code
2. Hardware preparation
OpenClaw main control board
DHT temperature and humidity sensor
OLED display
RGB light strip/RGB lamp bead module
[optional] CSI camera[Optional] AI voice module + speaker
Description:
- The core of this tutorial is "scheduled execution", it is not mandatory for all peripherals to be connected at the same time
- Which type of automation tasks you want to do, just connect the corresponding hardware first
3. Test basic capabilities of scheduled tasks
Before starting the current project, please complete a basic dialogue self-test of openclaw tui; if you have not done so yet, please read [06-Three dialogue scheme configuration tests] first. After passing, enter the timed task special test.
It is recommended to test in the following order:
- First enter OpenClaw TUI
- Let OpenClaw generate a simple script
- Run the script manually in the terminal to confirm that the function is normal
- Then write the script into
crontab
Terminal input:
openclaw tui
It is recommended to try the following requirements first:
- Help me write a script to display the current temperature and humidity on OLED and save it to the desktop
- Generate a script that reads temperature and humidity and prints the results each time it is run. -Write a script to make the RGB light turn green for 3 seconds and then turn off
After the script is generated, run it manually first, for example:
xxxxxxxxxxpython3 /home/sunrise/Desktop/your_script.py4. Three options for talking to OpenClaw
| Solution | Suitable scenario | Advantages | Suggested positioning |
|---|---|---|---|
| Remotely describe automation requirements | Suitable for clarifying "what you want to do on a regular basis" first | Used to generate scripts and confirm requirements | |
| TUI | Create and debug scheduled tasks locally | The easiest way to jointly debug scripts and cron | The preferred implementation solution |
| Voice code | Voice description automation scene | Closer to desktop assistant experience | Suitable for demonstrating "speak a sentence to generate automation" |
If the AI voice module + speaker is optional, Feishu dialogue, tui, and WhatsApp dialogue need to broadcast the content of openclaw's reply. You can run the following program on the terminal. The AI voice module dialogue does not need to be run repeatedly
- Modify whether to open broadcast parameters
xxxxxxxxxx/home/sunrise/voice_to_openclaw/.env
xxxxxxxxxxENABLE_TTS=true #This parameter is to control whether to broadcast. After modification, save it and run the following program on the terminal.- Terminal input
xxxxxxxxxxcd ~/voice_to_openclawsource .venv/bin/activatepython -m src.openclaw_session_tts
4.1 WhatsApp solution
For WhatsApp access steps, please refer directly to [06-Configuration Test of Three Dialogue Schemes]. This section is more suitable for describing requirements, such as:
- Help me do a scheduled task: make the RGB light red every minute as a reminder and then turn off the light

4.2 TUI scheme
If you have completed the TUI self-test in Part 6, enter the terminal text dialogue directly:
xxxxxxxxxxopenclaw tuiThen you can directly enter project-related instructions, such as:
- Help me do a scheduled task: read the temperature and humidity every minute and display it on the OLED

4.3 Voice code scheme
xxxxxxxxxxRequires optional ai voice interaction module + speaker
For voice module installation, environment configuration and basic wake-up process, please refer directly to [05-AI Voice Interaction Configuration]. After waking up, you can directly say the control content, such as:
- Help me do a scheduled task: read the temperature and humidity every minute and display it on the OLED

If you want to close the scheduled task, you can ask Help me stop the current scheduled task in the current conversation.

You can use the command cron list to view the current scheduled tasks

5. Project implementation
Note: The following are all dialogue demonstrations in openclaw tui mode. You can also choose WhatsApp or voice mode to complete it.
5.2 Scenario 1: Hourly temperature and humidity sampling
Experimental goals
Let the device automatically read temperature and humidity every hour and record the results or sync to the screen.
Effect description
This is the most basic and common scheduled task scenario, and can be expanded into logs, dashboards, environmental alarms, or plant care projects later.
Example instructions
- Help me do a scheduled task: read the temperature and humidity every minute and display it on the OLED
5.3 Scenario 2: Scheduled status reminder
Experimental goals
Use RGB or OLED to make a clear reminder at a fixed time.
Effect description
This type of task is suitable for drinking water reminders, class reminders, inspection reminders, and status switching reminders. It does not emphasize continuous operation, but emphasizes triggering a clear action at a certain point in time.
Example instructions
- Help me do a scheduled task: make the RGB light red every minute as a reminder and then turn off the light
5.4 Scenario 3: Regular inspection script
Experimental goals
String together multiple peripheral actions to form a small automation task that can be executed periodically.
Effect description
For example, the temperature and humidity are read once every hour, and if the status is abnormal, a light will be lit to remind, and the results will be displayed on the OLED. This type of task is close to a complete small project, and it is also the most obvious place where "AI generation script" and "timed execution" are combined.
Example instructions
- Help me do a scheduled task: read the temperature and humidity once every minute, light up the red light when abnormal, and prompt on the OLED