> For the complete documentation index, see [llms.txt](https://docs.sysout.co.kr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sysout.co.kr/base-language/arduino/arduino-network/bluetooth/hc-06/undefined.md).

# 온도 센서 활용

## 블루투스 + 온도센서

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

### 결선도

![](/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를 입력하면 측정된 온도가 반환되는 것을 확인할 수 있다.
