# \[아두이노] 온습도 센서 코드

### 코드

{% code title="온도를 읽어올 때" %}

```
@아두이노 {핀 번호}번 핀 온도 읽어오기
```

{% endcode %}

{% code title="습도를 읽어올 때" %}

```
@아두이노 {핀 번호}번 핀 습도 읽어오기
```

{% endcode %}

***

### 설명

<mark style="color:purple;">`온도/습도 읽어오기`</mark>는 아두이노와 연결된 온습도 센서와의 온도와 습도 데이터를 읽어오는 코드예요.

***

### 주의사항

* Data 핀은 디지털 핀(2\~13번 핀)에 연결해야 하고, 입력으로 핀 모드 설정을 먼저 해야 해요.
* 온도는 0\~50도까지 읽어올 수 있어요. (일부 센서는 저 범위를 넘어서 읽어올 수 있음)
  * 영하는 -가 붙지 않은 채로 읽어와요. (ex: 영하 12도는 그냥 12로 읽어옴)
  * 영하일 때 -가 붙은 채로 읽어오길 원한다면, [\[아두이노\] 기압 센서 코드](/arduino/032.md)를 활용해 보세요.
* 습도는 5\~95%까지 읽어올 수 있어요. (일부 센서는 저 범위를 넘어서 읽어올 수 있음)

***

### 파이썬 대응 코드

아두이노 코드는 파이썬에 대응되는 코드가 없어 제공되지 않아요.

***

### 예시

{% code title="예시 코드" %}

```
@아두이노 4번 핀 입력 설정
(@아두이노 4번 핀 온도 읽어오기) 보여주기
(@아두이노 4번 핀 습도 읽어오기) 보여주기
```

{% endcode %}

{% code title="예시 코드의 결과" %}

```
24
67
```

{% endcode %}

***

### 검색 키워드

기온, 날씨


---

# 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://codebook.horang.it/arduino/031.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.
