Welcome to RDK X5 Board repository
4. Temperature and Humidity Sensor
OpenClaw Temperature and Humidity Acquisition Tutorial
Before starting, please complete [01-Peripheral Hardware Configuration], [02-OpenClaw API-KEY Configuration], [03-OpenClaw Model Switching], [04-OpenClaw Prompts], [05-AI Voice Interaction Configuration], and [06-Three Conversation Scheme Configuration and Testing] in the
Preparation for Usedirectory. If you are currently only using TUI / WhatsApp, you can skip05for now. This document assumes the basic environment is already prepared and only expands on DHT-related content.
1. Tutorial Objectives
This tutorial demonstrates OpenClaw's natural language control capabilities through DHT temperature and humidity sensors. After completing this tutorial, readers will be able to:
- Understand the basic idea of OpenClaw reading temperature and humidity
- Interact with OpenClaw via three methods: WhatsApp, TUI, and voice code
- Complete four DHT cases: single reading, comfort judgment, threshold alert, OLED linkage display
- Understand the complete pipeline from "user question" to "sensor reading" and "result feedback"
2. Hardware Preparation
OpenClaw main board
DHT temperature and humidity sensor
[Default DHT11][Optional] OLED display[Optional] Microphone moduleWiring diagram

3. Software Preparation
Code entry points used in the tutorial
- Low-level driver code:
/home/sunrise/hardware_hal_demo/ - Temperature and humidity reading command:
/home/sunrise/hardware_hal_demo/dht - Temperature and humidity linkage display:
/home/sunrise/hardware_hal_demo/dht_oled - Voice entry point:
/home/sunrise/voice_to_openclaw/src/main.py
The dht tool already supports the following capabilities:
- Read current temperature and humidity
- Output results in
jsonortextformat - Use
mockfake data for local debugging
dht_oled # Display temperature and humidity data to OLEDdht # Feedback `json` resultIf you want to display temperature and humidity results directly on the OLED, you can also use dht_oled.
If you have selected the AI voice module + speaker, 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
4. Testing Temperature and Humidity Acquisition
Before starting this tutorial, please complete a basic openclaw tui conversation self-check first; if you haven't done so, see [06-Three Conversation Scheme Configuration and Testing]. After confirming that OpenClaw can respond normally, proceed to the DHT-specific test.
Enter the following command in the terminal to enter TUI:
xxxxxxxxxxopenclaw tui
You can try entering the following content in the terminal:
- Read current temperature and humidity
- What is the current environmental humidity?
- Help me judge if the current environment is comfortable
- Remind me if the temperature is too high

5. Three Schemes for Conversing with OpenClaw
| Scheme | Suitable Scenarios | Advantages | Suggested Positioning |
|---|---|---|---|
| Remote control, classroom demonstration | Easy access, suitable for multi-user experience | Demonstrate "remote natural language control" | |
| TUI | Local debugging, command verification | Most direct, easiest to troubleshoot | Get the control pipeline running first |
| Voice Code | Voice interaction, complete AI experience | Closest to real conversation experience | As the final demonstration scheme |
If you have selected the AI voice module + speaker, and WhatsApp conversation, TUI, or WhatsApp conversation need to broadcast OpenClaw's reply content, you can run the following program in the terminal. AI voice module conversation does not need to be run repeatedly.
- Modify whether to enable broadcast parameter
xxxxxxxxxx/home/sunrise/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 access steps, please refer directly to [06-Three Conversation Scheme Configuration and Testing]. This section only retains conversation examples suitable for the DHT tutorial.
After creation, you can converse directly, for example:
- Read current temperature and humidity
- Judge if it is a bit hot now
- Remind me if the humidity is too low

5.2 TUI Scheme
If you have completed the TUI self-check in Part 6, you can continue the conversation by entering the following command in the terminal:
xxxxxxxxxxopenclaw tui
5.3 Voice Code Scheme
xxxxxxxxxxRequires selection of 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].
You need to say "Hello Xiao Ya" to wake up and start the conversation.
After wake-up, you can directly speak control content, for example:
- What is the temperature now?
- Help me read the humidity
- Tell me if it is too stuffy

6. Comprehensive Cases
Note: The following are conversation demonstrations conducted via openclaw tui. You can also choose WhatsApp or voice methods to complete them.
6.1 Case 1: Single Reading
Experiment Objective
Obtain current temperature and humidity once to complete the most basic environmental sampling.
Effect Description
After receiving the instruction, OpenClaw will call the DHT driver to read the current temperature and humidity and return the results to the user in natural language.
Example Instructions
- Read current temperature and humidity
- What is the indoor temperature now?
- Help me check the current humidity
6.2 Case 2: Comfort Judgment
Experiment Objective
Let OpenClaw make a simple judgment on the current environment after reading the data.
Effect Description
In addition to directly reporting numbers, OpenClaw can also roughly judge states such as "a bit hot," "a bit cold," "a bit dry," or "a bit stuffy" based on temperature and humidity, making the results closer to natural conversation.
Example Instructions
- Help me judge if the current environment is comfortable
- Is the current temperature and humidity suitable for long-term office work?
- Give me a short evaluation based on temperature and humidity
6.3 Case 3: Threshold Alert
Experiment Objective
Let OpenClaw give a reminder when temperature or humidity exceeds the set range.
Effect Description
When the temperature is too high or too low, or when the humidity is too high or too low, OpenClaw can directly output reminder information, or link with RGB lights for more obvious feedback.
Example Instructions
- Remind me if the temperature exceeds 30 degrees
- Prompt that the air is a bit dry if the humidity is below 40%
- Has the alarm condition been reached now?
Expandable Gameplay
- Link with RGB for red, yellow, and blue three-color reminders
- Link with OLED to display alarm text
- Add a buzzer for stronger reminders
6.4 Case 4: OLED Linkage Display
Experiment Objective
Display the just-read temperature and humidity results directly on the OLED, forming a complete data display pipeline.
Effect Description
After completing an environmental sampling, OpenClaw can not only reply the results to the user but also synchronously write the temperature and humidity to the OLED screen, forming a complete effect of "reading + displaying on screen."
Example Instructions
- Read current temperature and humidity and display on OLED
- Write temperature and humidity to the screen
- Make a simple temperature and humidity display page
Expandable Gameplay
- Periodically refresh OLED content
- Make a temperature and humidity dashboard
- Link with the weather station project to form a complete application