# 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
