# 온도 센서 활용

## 블루투스 + 온도센서

이 문서에서는 블루투스 통신과 온도센서를 조합하여 사용하는 내용에 대해서 다룬다.

### 결선도

![](/files/-Mf6zQGEQoiZB9L29tlE)

### 샘플 코드

```
#include <SoftwareSerial.h>

const int LM35PIN = A0;
SoftwareSerial BTSerial(2, 3);//TX, RX

void setup(){
  Serial.begin(9600);
  BTSerial.begin(9600);
  Serial.println("Start temparture system");
}

void loop(){
  if(BTSerial.available()){
    String input = BTSerial.readString();
    if(input.equals("temp")){
      int input = analogRead(LM35PIN);
      float temperature = (5.0 * input * 100) / 1024;
      BTSerial.print("Temperature(Celsius) : ");
      BTSerial.println(temperature);
    }
  }
}
```

### 컴파일

`Ctrl+R` 또는 스케치 메뉴의 `확인/컴파일`을 눌러 컴파일을 진행한다.

### 업로드

`Ctrl+U` 또는 스케치 메뉴의 `업로드`를 눌러 업로드를 진행한다.

### 실행 결과

블루투스 연결 후 temp를 입력하면 측정된 온도가 반환되는 것을 확인할 수 있다.


---

# 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://docs.sysout.co.kr/base-language/arduino/arduino-network/bluetooth/hc-06/undefined.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.
