아두이노 우노 Q LM35 온도 센서

LM35는 온도에 비례하는 전압을 출력하는 간단한 아날로그 온도 센서입니다. Arduino UNO Q에서 MCU의 12비트 ADC는 표준 10비트 보드보다 더 높은 정밀도를 제공합니다. 이 튜토리얼은 LM35를 배선하고 프로그래밍하는 방법을 보여주며, Telegram을 통해 원격으로 모니터링하는 방법도 소개합니다.

이 튜토리얼에서 배우는 내용:

Arduino UNO Q lm35 온도 센서

필요한 하드웨어

1×Arduino UNO Q 아마존
1×USB Cable for Arduino Uno Q 아마존
1×LM35 Temperature Sensor 아마존
1×브레드보드 쿠팡 | 아마존
1×점퍼케이블 쿠팡 | 아마존
1×(추천) 아두이노 우노용 스크루 터미널 블록 쉴드 쿠팡 | 아마존
1×(추천) Sensors/Servo Expansion Shield for Arduino Uno 쿠팡 | 아마존
1×(추천) 아두이노 우노용 브레드보드 쉴드 쿠팡 | 아마존
1×(추천) 아두이노 우노용 케이스 쿠팡 | 아마존
1×(추천) 아두이노 우노용 프로토타이핑 베이스 플레이트 & 브레드보드 키트 아마존
공개: 이 포스팅 에 제공된 일부 링크는 아마존 제휴 링크입니다. 이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.

LM35 온도 센서 정보

핀배치

LM35는 세 개의 핀을 가지고 있습니다:

  • GND: GND (0V)에 연결
  • VCC: 5V에 연결 (LM35는 최소 4V 공급 필요)
  • OUT: 아날로그 출력 — Arduino UNO Q MCU의 아날로그 핀에 연결
lm35 온도 센서 사용법 핀아웃

작동 원리

LM35는 온도에 따라 선형적으로 증가하는 전압을 출력합니다: 1°C 상승시 출력이 10mV 증가합니다. 온도를 읽으려면 출력 전압을 측정하고 10으로 나누면 됩니다.

Arduino UNO Q에서, MCU (STM32U585)는 12비트 ADC (값 0–4095)와 3.3V 기준을 사용합니다. 이는 표준 10비트 Arduino 보드보다 더 나은 해상도를 제공합니다.

배선 다이어그램

Arduino UNO Q lm35 온도 센서 연결 배선도

이 이미지는 Fritzing을 사용하여 만들어졌습니다. 이미지를 확대하려면 클릭하세요.

LM35 핀 Arduino UNO Q MCU
GND GND
VCC 5V
OUT A0

※ 주의:

LM35 VCC5V 핀에 연결하세요. 3.3V가 아닙니다 — LM35는 작동하려면 최소 4V가 필요합니다. 아날로그 출력은 여전히 MCU의 3.3V ADC 범위 내에 있습니다.

LM35을 위한 프로그래밍 방법

  • 아날로그 핀에서 ADC 값 읽기:
int adcVal = analogRead(PIN_LM35);
  • ADC 값을 밀리볼트로 변환 (3.3V 기준 및 12비트 해상도 사용):
float milliVolt = adcVal * (ADC_VREF_mV / ADC_RESOLUTION); // ADC_VREF_mV = 3300.0 (3.3V reference on UNO Q MCU) // ADC_RESOLUTION = 4096.0 (12-bit ADC on UNO Q MCU)
  • 밀리볼트를 섭씨로 변환:
float tempC = milliVolt / 10;
  • 섭씨를 화씨로 변환:
float tempF = tempC * 9.0 / 5.0 + 32.0;

Arduino UNO Q 코드

Arduino UNO Q는 함께 작동하는 두 개의 프로세서를 가지고 있습니다:

  • STM32 MCU는 12비트 ADC를 통해 LM35 아날로그 출력을 직접 읽습니다 — 모든 센서 읽기 및 변환은 MCU에서 실행됩니다
  • Qualcomm MPU는 Debian Linux를 실행하고 Wi-Fi, Python, 클라우드 연결을 처리합니다
  • 이 섹션에서는 MCU만 프로그래밍됩니다 — Linux 측은 유휴 상태입니다. 이후 섹션에서 두 프로세서가 Bridge를 통해 함께 작동하는 방식을 보여줍니다.

MCU는 매초 LM35을 읽고 온도를 Serial Monitor에 출력합니다.

/* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-lm35-temperature-sensor */ // Arduino UNO Q MCU (STM32U585) uses a 12-bit ADC (0–4095) with a 3.3V reference #define ADC_VREF_mV 3300.0 // MCU reference voltage in millivolts #define ADC_RESOLUTION 4096.0 // 12-bit ADC resolution #define PIN_LM35 A0 // Analog pin connected to LM35 OUT pin void setup() { Serial.begin(115200); delay(1500); Serial.println("Arduino UNO Q LM35 Temperature Sensor ready"); } void loop() { int adcVal = analogRead(PIN_LM35); float milliVolt = adcVal * (ADC_VREF_mV / ADC_RESOLUTION); float tempC = milliVolt / 10; float tempF = tempC * 9.0 / 5.0 + 32.0; Serial.print("Temperature: "); Serial.print(tempC); Serial.print("°C = "); Serial.print(tempF); Serial.println("°F"); delay(1000); }

빠른 단계

Arduino UNO Q를 처음 사용하나요? 계속하기 전에 아두이노 우노 Q 시작하기 튜토리얼을 따르세요.

  • 연결: 배선 다이어그램에 표시된 대로 LM35 센서를 Arduino UNO Q MCU에 배선합니다.
  • Arduino App Lab 열기: Arduino App Lab을 실행하고 Arduino UNO Q를 감지할 때까지 대기합니다.
  • 새 앱 만들기: Create New App 버튼을 클릭합니다.
create new app in 아두이노 app lab on Arduino UNO Q
  • 앱에 이름을 지정합니다 (예: Lm35TemperatureSensor).
  • Create를 클릭하여 확인합니다.
아두이노 app lab app folders and files on Arduino UNO Q
  • 스케치 붙여넣기: 위의 MCU 코드를 복사하여 sketch/sketch.ino에 붙여넣습니다. 다른 파일은 기본값으로 유지합니다.
  • 라이브러리 불필요 — LM35은 내장된 analogRead() 함수만 사용합니다.
  • 업로드: Arduino App Lab에서 Run 버튼을 클릭합니다.
click run 버튼 in 아두이노 app lab on Arduino UNO Q
  • 센서를 손에 들고 있으세요 — 콘솔에서 온도가 올라가는 것을 지켜보세요.

App Lab 콘솔 출력

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
Message (Enter to send a message to "Newbiely" on usb(2820070321))
New Line
9600 baud
[2026-04-29 09:00:01] Arduino UNO Q LM35 Temperature Sensor ready [2026-04-29 09:00:02] Temperature: 26.31°C = 79.36°F [2026-04-29 09:00:03] Temperature: 26.44°C = 79.59°F [2026-04-29 09:00:04] Temperature: 26.87°C = 80.37°F [2026-04-29 09:00:05] Temperature: 27.25°C = 81.05°F

Bridge: Linux + MCU

이 섹션에서는 Arduino UNO Q의 두 프로세서를 모두 프로그래밍하여 Linux 측에서 Bridge를 통해 LM35 온도를 읽는 방법을 보여줍니다:

  • LM35 센서는 MCU (STM32) 아날로그 핀에 연결되어 있으며 — MCU는 매초 ADC 값을 읽고 변환합니다
  • MPU는 아날로그 핀에 직접 접근할 수 없습니다 — Bridge 함수를 호출하여 읽기를 검색해야 합니다
  • MPU에는 Wi-Fi가 있습니다 — 전체 Debian Linux를 실행하면서 데이터를 기록하고, 대시보드에 게시하거나, 인터넷을 통해 알림을 보낼 수 있습니다
  • Arduino_RouterBridge는 두 프로세서 간 RPC 통신을 활성화합니다
  • ⚠️ /dev/ttyHS1 (Linux)과 Serial1 (MCU)은 라우터에 예약됨 — 사용자 코드에서 이들을 열지 마세요

요약하면: MCU는 12비트 ADC를 통해 매초 LM35을 읽음 → MPU는 Bridge를 통해 온도를 읽음 → MPU는 Wi-Fi를 통해 게시하거나 알림을 보냄

MCU 코드 (Bridge)

/* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-lm35-temperature-sensor */ // Arduino UNO Q MCU (STM32U585) uses a 12-bit ADC (0–4095) with a 3.3V reference#include "Arduino_RouterBridge.h" #define ADC_VREF_mV 3300.0 #define ADC_RESOLUTION 4096.0 #define PIN_LM35 A0 float last_temp_c = 0.0; float last_temp_f = 0.0; unsigned long last_read_ms = 0; void read_lm35() { int adcVal = analogRead(PIN_LM35); float milliVolt = adcVal * (ADC_VREF_mV / ADC_RESOLUTION); last_temp_c = milliVolt / 10.0; last_temp_f = last_temp_c * 9.0 / 5.0 + 32.0; } String get_temp_c(String arg) { return String(last_temp_c, 2); } String get_temp_f(String arg) { return String(last_temp_f, 2); } String get_status(String arg) { return "Temp: " + String(last_temp_c, 2) + "°C / " + String(last_temp_f, 2) + "°F"; } void setup() { Bridge.begin(); Monitor.begin(); read_lm35(); Bridge.provide("get_temp_c", get_temp_c); Bridge.provide("get_temp_f", get_temp_f); Bridge.provide("get_status", get_status); Monitor.println("Arduino UNO Q LM35 Temperature Sensor Bridge ready"); } void loop() { unsigned long now = millis(); if (now - last_read_ms >= 1000) { last_read_ms = now; read_lm35(); Monitor.println("Temp: " + String(last_temp_c, 2) + "°C / " + String(last_temp_f, 2) + "°F"); } }

Python 코드 (Bridge)

/* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-lm35-temperature-sensor */ from arduino.app_utils import * import time def loop(): temp_c = Bridge.call("get_temp_c") temp_f = Bridge.call("get_temp_f") print(f"Temperature: {temp_c}°C = {temp_f}°F") time.sleep(1) App.run(user_loop=loop)

빠른 단계

  • 연결: 배선 다이어그램에 표시된 대로 LM35 센서를 Arduino UNO Q에 배선합니다.
  • Arduino App Lab 열기: Arduino App Lab을 실행하고 보드가 감지될 때까지 대기합니다.
  • 새 앱 만들기: Create New App을 클릭하고, 이름을 Lm35TemperatureSensorBridge로 지정한 후, Create을 클릭합니다.
  • MCU 스케치 붙여넣기: 위의 MCU Bridge 코드를 복사하여 sketch/sketch.ino에 붙여넣습니다.
  • Python 코드 붙여넣기: 위의 Python Bridge 코드를 복사하여 앱의 Python 파일에 붙여넣습니다.
  • Install the library: Click the Add sketch library button (the open book icon with a + sign) in the left sidebar.
add sketch 라이브러리 in 아두이노 app lab on Arduino UNO Q
  • Search for Arduino_RouterBridge created by Arduino and click the Install button.
My Apps / DIYables Apps
Run
Bricks
No bricks added...
Sketch Libraries
No sketch libra...
Files
python
sketch
.gitignore
README.md
app.yaml
sketch.ino
Add sketch library
Arduino_RouterBridge Arduino

This library provides a simple RPC bridge for Arduino UNO Q boards, allowing communication between the board and other devices using MsgPack serialization.

0.4.1
Install
More Info
  • 업로드: Arduino App Lab에서 Run 버튼을 클릭합니다.
click run 버튼 in 아두이노 app lab on Arduino UNO Q
  • Python 콘솔에서 매초 온도 읽기가 나타나는 것을 지켜보세요.

App Lab 콘솔 출력

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
Message (Enter to send a message to "Newbiely" on usb(2820070321))
New Line
9600 baud
[2026-04-29 09:00:01] Arduino UNO Q LM35 Temperature Sensor Bridge ready [2026-04-29 09:00:02] Temp: 26.31°C / 79.36°F [2026-04-29 09:00:03] Temp: 26.44°C / 79.59°F [2026-04-29 09:00:04] Temp: 26.87°C / 80.37°F
DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
[2026-04-29 09:00:02] Temperature: 26.31°C = 79.36°F [2026-04-29 09:00:03] Temperature: 26.44°C = 79.59°F [2026-04-29 09:00:04] Temperature: 26.87°C = 80.37°F [2026-04-29 09:00:05] Temperature: 27.25°C = 81.05°F

Telegram

LM35 온도를 원격으로 모니터링하고 온도가 35°C를 초과할 때 자동 Telegram 알림을 받습니다.

MCU 스케치: 이전 Bridge 섹션의 동일한 MCU 스케치를 유지합니다.

Python 코드 (Telegram)

/* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-lm35-temperature-sensor */ from arduino.app_utils import * import requests import time TELEGRAM_BOT_TOKEN = "YOUR_TELEGRAM_BOT_TOKEN" CHAT_ID = "YOUR_CHAT_ID" last_update_id = 0 ALERT_THRESHOLD_C = 35.0 alert_sent = False def get_updates(): global last_update_id url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/getUpdates" params = {"offset": last_update_id + 1, "timeout": 5} try: response = requests.get(url, params=params, timeout=10) data = response.json() if data["ok"]: return data["result"] except Exception as e: print(f"Error getting updates: {e}") return [] def send_message(chat_id, text): url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage" payload = {"chat_id": chat_id, "text": text} try: requests.post(url, data=payload, timeout=10) except Exception as e: print(f"Error sending message: {e}") def loop(): global alert_sent # Auto-alert on high temperature temp_c_str = Bridge.call("get_temp_c") try: temp_c = float(temp_c_str) if temp_c > ALERT_THRESHOLD_C and not alert_sent: alert_sent = True temp_f = Bridge.call("get_temp_f") msg = f"⚠️ High temperature alert: {temp_c_str}°C / {temp_f}°F" print(msg) send_message(CHAT_ID, msg) elif temp_c <= ALERT_THRESHOLD_C: alert_sent = False except ValueError: pass # Handle Telegram commands updates = get_updates() for update in updates: last_update_id = update["update_id"] if "message" not in update: continue message = update["message"] chat_id = message["chat"]["id"] text = message.get("text", "").strip() print(f"Received: {text}") if text == "/start": send_message(chat_id, "Arduino UNO Q LM35 Temperature Sensor Bot\n" "/temp - Read temperature (°C and °F)\n" "/tempC - Read temperature in Celsius\n" "/tempF - Read temperature in Fahrenheit\n" "/status - Get sensor status") elif text == "/temp": temp_c = Bridge.call("get_temp_c") temp_f = Bridge.call("get_temp_f") send_message(chat_id, f"Temperature: {temp_c}°C = {temp_f}°F") elif text == "/tempC": result = Bridge.call("get_temp_c") send_message(chat_id, f"Temperature: {result}°C") elif text == "/tempF": result = Bridge.call("get_temp_f") send_message(chat_id, f"Temperature: {result}°F") elif text == "/status": result = Bridge.call("get_status") send_message(chat_id, result) else: send_message(chat_id, "Unknown command. Send /start for help.") time.sleep(1) App.run(user_loop=loop)

빠른 단계

  • YOUR_TELEGRAM_BOT_TOKEN을 BotFather에서 얻은 실제 봇 토큰으로 바꾸세요.
  • YOUR_CHAT_ID를 Telegram 채팅 ID로 바꾸세요.
  • 이 Python 코드를 앱의 Python 파일에 붙여넣습니다 (동일한 MCU 스케치 유지).
  • Run 버튼을 클릭합니다. Telegram에서 /temp를 보내거나 센서를 들어서 고온 알림을 트리거하세요.

App Lab 콘솔 출력

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
[2026-04-29 09:10:00] Waiting for Telegram messages... [2026-04-29 09:10:15] ⚠️ High temperature alert: 36.25°C / 97.25°F [2026-04-29 09:10:30] Received: /temp [2026-04-29 09:10:45] Received: /tempC
Telegram
Telegram 12:45
Welcome to Telegram!
ArduinoBot 10:19
Chatting with Arduino...
telegram-botfather
BotFather Yesterday
Your bot has been created.

ArduinoBot

bot
Today
/temp
10:15 AM ✓✓
Temperature: 26.31°C = 79.36°F
10:16 AM
/tempC
10:17 AM ✓✓
Temperature: 26.31°C
10:18 AM
/tempF
10:19 AM ✓✓
Temperature: 79.36°F
10:20 AM
/status
10:21 AM ✓✓
Temp: 26.31°C / 79.36°F
10:22 AM
⚠️ High temperature alert: 36.25°C / 97.25°F
10:23 AM

OpenClaw

You can adapt the OpenClaw to this tutorial by refering the instruction on 아두이노 우노 Q - OpenClaw Tutorial

프로젝트 아이디어

LM35과 Arduino UNO Q로 많은 유용한 프로젝트를 구축할 수 있습니다:

  • 아날로그 온도 모니터: LM35의 연속 아날로그 출력과 MCU의 12비트 ADC는 부드럽고 고해상도의 읽기를 제공합니다 — 매초 기록하고 미세한 온도 변화를 식별합니다
  • 과열 보호기: LM35을 사용하여 장치 (모터, 회로)를 모니터링합니다 — MCU는 온도가 안전 한계를 초과할 때 Bridge를 통해 릴레이를 트리거하고, Telegram이 알림을 보냅니다
  • 다중 영역 온도 조사: 여러 LM35 센서를 다른 아날로그 핀에 연결합니다 — Python 측은 Bridge를 통해 각각을 쿼리하고 나란히 온도 비교를 표시합니다
  • 보정된 온도계: LM35의 공장 정확도 (±0.5°C)를 사용하여 Telegram 명령으로 온디맨드 읽기를 제공하는 정밀한 디지털 온도계를 구축합니다
  • 온도 기반 팬 속도 컨트롤러: LM35 ADC 읽기를 MCU의 PWM 출력 값에 직접 매핑하여 팬 속도를 제어합니다 — Python 측은 Bridge를 통해 팬 듀티 사이클을 모니터링할 수 있습니다

도전 문제

Arduino UNO Q의 LM35로 더 나아갈 준비가 되셨나요? 이 도전 문제들을 시도해보세요:

  • 쉬움: MCU 스케치에 지난 10개의 ADC 읽기를 평균하는 이동 평균 필터를 추가합니다 — 이는 출력의 노이즈를 줄입니다.
  • 중간: LM35과 DS18B20 읽기를 나란히 비교합니다: 두 센서를 모두 연결하고 두 읽기를 모두 단일 응답으로 반환하는 compare_sensors(String) Bridge 함수를 추가합니다. 쉬운 비교를 위해.
  • 고급: 보정 도구를 구축합니다: 10초 동안 100개의 LM35 읽기를 수집하고, 평균 및 표준 편차를 계산하고, get_stats(String) Bridge 함수를 통해 JSON 문자열로 반환합니다 — Python은 보정 결과를 표시하고 기록합니다.