> For the complete documentation index, see [llms.txt](https://cavedu.gitbook.io/cavedu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cavedu.gitbook.io/cavedu/hangeekduino/samplecode/input_module/dht11sensor.md).

# 溫溼度感測模組

![](/files/-MITXTD6ZQefrrdolSmM)

## **指令**

![](/files/-MITSeCEie_cZ4k6_jUr)

## **對應的**Arduino 語法

```
    dht11_p3.readTemperature();
    dht11_p3.readHumidity();
```

### 範例 BlocklyDuino 積木畫布

在OLED顯示模組上顯示溫溼度感測模組的溫度和濕度。

![](/files/-MITSu6qvRKO1NNVVbTd)

## Arduino 程式

```
#include "DHT.h"
DHT dht11_p3(3, DHT11);

#include <Arduino.h>
#include <U8x8lib.h>
U8X8_SSD1306_128X64_ALT0_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);

float temp;

float humi;

void setup()
{
  u8x8.begin();
  u8x8.setFlipMode(1);u8x8.setFont(u8x8_font_chroma48medium8_r);

}


void loop()
{
  temp = (dht11_p3.readTemperature());
  humi = (dht11_p3.readHumidity());
  u8x8.setCursor(0, 33);
  u8x8.print(String() + "Temp:" + temp + "C");
  u8x8.setCursor(0, 50);
  u8x8.print(String() + "Humi:" + humi + "%");
  delay(200);
}
```

## 影片教學:

{% embed url="<https://www.youtube.com/watch?v=bAbHAfYffQ0>" %}


---

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

```
GET https://cavedu.gitbook.io/cavedu/hangeekduino/samplecode/input_module/dht11sensor.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.
