Qualcomm MPU는 Debian Linux를 실행하고 Wi-Fi, Python 및 클라우드 연결을 처리합니다
이 섹션에서는 MCU만 프로그래밍됩니다 — Linux 측은 유휴 상태로 유지됩니다. 나중 섹션에서는 두 프로세서가 Bridge를 통해 함께 작동하는 방법을 보여줍니다.
MCU는 매초 온도를 읽고 OLED 중앙에 표시합니다.
/* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-temperature-sensor-oled */#include <Wire.h>#include <Adafruit_GFX.h>#include <Adafruit_SSD1306.h>#include <OneWire.h>#include <DallasTemperature.h>#define OLED_WIDTH 128#define OLED_HEIGHT 64#define SENSOR_PIN 4 // Arduino UNO Q MCU pin connected to DS18B20 DATA pinAdafruit_SSD1306oled(OLED_WIDTH, OLED_HEIGHT, &Wire, -1);OneWire oneWire(SENSOR_PIN);DallasTemperature DS18B20(&oneWire);void oled_display_center(String text) {int16_t x1, y1;uint16_t width, height;oled.getTextBounds(text, 0, 0, &x1, &y1, &width, &height);oled.clearDisplay();oled.setCursor((OLED_WIDTH - width) / 2, (OLED_HEIGHT - height) / 2);oled.println(text);oled.display();}voidsetup() {Serial.begin(115200);delay(1500);if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {Serial.println("SSD1306 allocation failed");while (true); }oled.clearDisplay();oled.setTextSize(2);oled.setTextColor(WHITE); DS18B20.begin();Serial.println("Arduino UNO Q Temperature Sensor + OLED ready");}voidloop() { DS18B20.requestTemperatures();float temperature_C = DS18B20.getTempCByIndex(0);float temperature_F = temperature_C * 9.0 / 5.0 + 32.0;String display_str = String(temperature_C, 1) + char(247) + "C"; oled_display_center(display_str);Serial.print("Temperature: ");Serial.print(temperature_C);Serial.print("°C ~ ");Serial.print(temperature_F);Serial.println("°F");delay(1000);}
※ 주의:
코드는 온도 텍스트를 OLED 디스플레이의 수평 및 수직 중앙에 자동으로 배치합니다. 도 기호는 char(247)를 사용하여 표시됩니다.
빠른 단계
Arduino UNO Q를 처음 사용하시나요? 진행하기 전에 아두이노 우노 Q 시작하기 튜토리얼을 따르세요.
연결: 배선도에 표시된 대로 DS18B20 센서 및 OLED 디스플레이를 Arduino UNO Q MCU에 배선합니다.
Arduino App Lab 열기: Arduino App Lab을 실행하고 Arduino UNO Q를 감지할 때까지 기다립니다.
새 앱 만들기:Create New App 버튼을 클릭합니다.
앱에 이름을 지정합니다 (예: TemperatureSensorOled)
Create를 클릭하여 확인합니다.
스케치 붙여넣기: 위의 MCU 코드를 복사하여 sketch/sketch.ino에 붙여넣습니다. 다른 파일은 기본값으로 유지합니다.
Install the library: Click the Add sketch library button (the open book icon with a + sign) in the left sidebar.
Search for Adafruit SSD1306 created by Adafruit 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
Adafruit SSD1306
Adafruit SSD1306Adafruit
SSD1306 oled driver library for monochrome 128x64 and 128x32 displays
2.5.9
Install
More Info
Search for Adafruit GFX Library created by Adafruit 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
Adafruit GFX Library
Adafruit GFX LibraryAdafruit
Install this library in addition to the display library for your hardware.
1.12.6
Install
More Info
Search for DallasTemperature created by Miles Burton , Tim Newsome , Guil Barros , Rob Tillaart 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
DallasTemperature
DallasTemperatureMiles Burton , Tim Newsome , Guil Barros , Rob Tillaart
Supports DS18B20, DS18S20, DS1822, DS1820
3.9.0
Install
More Info
Search for OneWire created by Jim Studt, Tom Pollard, Robin James, Glenn Trewitt, Jason Dangel, Guillermo Lovato, Paul Stoffregen, Scott Roberts, Bertrik Sikken, Mark Tillotson, Ken Butcher, Roger Clark, Love Nystrom 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
OneWire
OneWireJim Studt, Tom Pollard, Robin James, Glenn Trewitt, Jason Dangel, Guillermo Lovato, Paul Stoffregen, Scott Roberts, Bertrik Sikken, Mark Tillotson, Ken Butcher, Roger Clark, Love Nystrom
2.3.8
Install
More Info
업로드: Arduino App Lab에서 실행 버튼을 클릭합니다.
센서를 손에 쥐거나 뜨거운/찬 물에 담그세요 — OLED에서 온도가 업데이트되는 것을 확인하세요.
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))
/* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-temperature-sensor-oled */from arduino.app_utils import *import timedef loop(): status = Bridge.call("get_status")print(status) time.sleep(1)App.run(user_loop=loop)
빠른 단계
연결: 배선도에 표시된 대로 DS18B20 센서 및 OLED를 Arduino UNO Q에 배선합니다.