> For the complete documentation index, see [llms.txt](https://nkust.gitbook.io/micro-bit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nkust.gitbook.io/micro-bit/micropython-dht11-du-gan-qi.md).

# MicroPython DHT11溫濕度感測器

在嵌入式系統中常見的溫濕度感測器DHT11，在micro:bit中也可以使用MicroPython來完成量測的程式。這次我們使用是以下的這個模組：

{% embed url="<https://github.com/rhubarbdog/microbit-dht11>" %}

同樣地，請下載之後解壓縮，然後把dht11.py上傳到micro:bit板子上，利用以下的程式即可讓micro:bit的LED顯示器以捲動的方式顯示出目前正確的環境溫濕度：

```python
from microbit import *
from dht11 import DHT11

while True:
    sensor = DHT11(pin0)
    t, h = sensor.read()
    display.scroll("{}C,{}%".format(t, h))
    sleep(2000)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://nkust.gitbook.io/micro-bit/micropython-dht11-du-gan-qi.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
