아두이노 우노 R4 WiFi 블루투스 다중 앱 예제 올인원 BLE 튜토리얼

개요

블루투스 다중 앱 예제는 BLE를 사용하여 하나의 Arduino UNO R4 WiFi에서 9개의 블루투스 앱을 동시에 실행하는 방법을 보여줍니다. BLE(Bluetooth Low Energy) 를 사용하는 Arduino UNO R4 WiFi 전용으로 설계되어 모니터, 채팅, 슬라이더, 조이스틱, 온도계, 플로터, 테이블, 아날로그 게이지, 로테이터를 하나의 강력한 스케치로 결합합니다. 모든 앱은 단일 BLE 연결을 공유하며 서로 상호 작용할 수 있습니다. 종합 대시보드, 복잡한 IoT 프로젝트, 여러 앱 유형을 한 번에 배우기에 적합합니다.

참고: Arduino UNO R4 WiFi는 BLE(Bluetooth Low Energy)만 지원합니다. 클래식 블루투스는 지원하지 않습니다. DIYables 블루투스 앱은 Android에서 BLE와 클래식 블루투스를 모두 지원하고, iOS에서는 BLE를 지원합니다. 이 보드는 BLE를 사용하므로 앱은 Android와 iOS 모두에서 작동합니다.

아두이노 우노 R4 와이파이 블루투스 다중 앱 예제 - 올인원 BLE 튜토리얼

기능

  • 하나의 스케치에서 9개의 앱: 모니터, 채팅, 슬라이더, 조이스틱, 온도계, 플로터, 테이블, 아날로그 게이지, 로테이터
  • 앱 간 상호 작용: 슬라이더 값이 게이지와 테이블을 업데이트하고, 조이스틱이 테이블을 업데이트하는 등
  • 단일 BLE 연결: 모든 앱이 하나의 연결을 효율적으로 공유
  • 실시간 업데이트: 각 앱이 자체 간격으로 업데이트
  • 종합 대시보드: 하나의 기기에서 모든 데이터 확인
  • Android 및 iOS에서 작동: BLE는 두 플랫폼 모두에서 지원
  • 페어링 불필요: BLE는 수동 페어링 없이 자동 연결

포함된 앱

설명 업데이트 간격
모니터(Monitor) 텍스트 기반 상태 표시 5초
채팅(Chat) 양방향 텍스트 메시지 요청 시
슬라이더(Slider) 값 제어(0-255) 변경 시
조이스틱(Joystick) 2D 위치 제어 변경 시
온도계(Temperature) 온도 게이지(-10~50°C) 2초
플로터(Plotter) 실시간 데이터 그래프 100ms
테이블(Table) 구조화된 데이터(10행) 5초
아날로그 게이지(Analog Gauge) 다이얼 스타일 게이지(0-100%) 3초
로테이터(Rotator) 각도 제어(연속) 변경 시

필요한 하드웨어

1×아두이노 우노 R4 와이파이 쿠팡 | 아마존
1×(또는) DIYables STEM V4 IoT 쿠팡 | 아마존
1×USB 케이블 타입-A to 타입-C (USB-A PC용) 쿠팡 | 아마존
1×USB 케이블 타입-C to 타입-C (USB-C PC용) 아마존
1×(추천) 아두이노 우노 R4용 스크루 터미널 블록 쉴드 쿠팡 | 아마존
1×(추천) Sensors/Servo Expansion Shield for Arduino UNO R4 아마존
1×(추천) 아두이노 우노 R4용 브레드보드 쉴드 쿠팡 | 아마존
1×(추천) 아두이노 우노 R4용 케이스 쿠팡 | 아마존
1×(추천) 아두이노 우노 R4용 전원 분배기 쿠팡 | 아마존
1×(추천) 아두이노 우노용 프로토타이핑 베이스 플레이트 & 브레드보드 키트 아마존
공개: 이 포스팅 에 제공된 일부 링크는 아마존 제휴 링크입니다. 이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.
Arduino Uno R4 WiFi Compatible Boards

Arduino UNO R4 WiFi 코드

빠른 단계

다음 단계를 순서대로 따라하세요:

  • Arduino UNO R4 WiFi를 처음 사용하는 경우 아두이노 우노 R4 - 소프트웨어 설치를 참조하세요.
  • USB 케이블을 사용하여 Arduino UNO R4 WiFi 보드를 컴퓨터에 연결합니다.
  • 컴퓨터에서 Arduino IDE를 실행합니다.
  • Arduino UNO R4 WiFi 보드와 적절한 COM 포트를 선택합니다.
  • Arduino IDE 왼쪽 바에서 Libraries 아이콘으로 이동합니다.
  • "DIYables Bluetooth"를 검색한 다음 DIYables의 DIYables Bluetooth 라이브러리를 찾습니다.
  • Install 버튼을 클릭하여 라이브러리를 설치합니다.
아두이노 우노 R4 diyaBLEs 블루투스 라이브러리
  • 다른 라이브러리 종속성 설치를 요청받습니다.
  • Install All 버튼을 클릭하여 모든 라이브러리 종속성을 설치합니다.
아두이노 우노 R4 diyaBLEs 블루투스 종속성

BLE 코드

  • Arduino IDE에서 File Examples DIYables Bluetooth ArduinoBLE_MultipleApps 예제로 이동하거나, 위의 코드를 복사하여 Arduino IDE 편집기에 붙여 넣습니다.
/* * DIYables Bluetooth Library - Multiple Apps Example (ArduinoBLE) * Works with DIYables Bluetooth STEM app on Android and iOS * * This example demonstrates how to use multiple Bluetooth apps simultaneously: * - Monitor: Real-time serial monitoring and logging * - Chat: Bi-directional text messaging * - Slider: Dual slider control (0-255 range) * - Joystick: Interactive joystick control (X, Y coordinates) * - Temperature: Temperature monitoring and display * - Plotter: Real-time data plotting (3 channels) * - Table: Two-column data table with real-time updates * - Analog Gauge: Circular gauge for sensor monitoring * - Rotator: Rotatable disc/knob control * - Pin Control: Digital pin control and monitoring * * Features: * - All apps run simultaneously on a single BLE connection * - Automatic message routing to appropriate app handlers * - Simplified callback system - no manual parsing needed * - All BLE protocol details handled by the library * - Compatible with DIYables Bluetooth Mobile App * * Compatible Boards: * - Arduino UNO R4 WiFi * - Arduino Nano 33 BLE / BLE Sense * - Arduino Nano 33 IoT * - Arduino MKR WiFi 1010 * - Arduino Nano RP2040 Connect * - Any board supporting the ArduinoBLE library * * Setup: * 1. Upload the sketch to your Arduino * 2. Open Serial Monitor (9600 baud) * 3. Open DIYables Bluetooth App on your phone * 4. Connect to "DIYables Multi-App" * 5. Navigate to different screens to test each app * * Tutorial: https://diyables.io/bluetooth-app * Author: DIYables */ #include <DIYables_BluetoothServer.h> #include <DIYables_BluetoothMonitor.h> #include <DIYables_BluetoothChat.h> #include <DIYables_BluetoothSlider.h> #include <DIYables_BluetoothJoystick.h> #include <DIYables_BluetoothTemperature.h> #include <DIYables_BluetoothPlotter.h> #include <DIYables_BluetoothTable.h> #include <DIYables_BluetoothAnalogGauge.h> #include <DIYables_BluetoothRotator.h> #include <platforms/DIYables_ArduinoBLE.h> // BLE Configuration const char* DEVICE_NAME = "DIYables Multi-App"; const char* SERVICE_UUID = "19B10000-E8F2-537E-4F6C-D104768A1214"; const char* TX_UUID = "19B10001-E8F2-537E-4F6C-D104768A1214"; const char* RX_UUID = "19B10002-E8F2-537E-4F6C-D104768A1214"; // Create Bluetooth instances DIYables_ArduinoBLE bluetooth(DEVICE_NAME, SERVICE_UUID, TX_UUID, RX_UUID); DIYables_BluetoothServer bluetoothServer(bluetooth); // Create app instances DIYables_BluetoothMonitor bluetoothMonitor; DIYables_BluetoothChat bluetoothChat; DIYables_BluetoothSlider bluetoothSlider(0, 255, 1); DIYables_BluetoothJoystick bluetoothJoystick(false, 5); DIYables_BluetoothTemperature bluetoothTemperature(-10.0, 50.0, "°C"); DIYables_BluetoothPlotter bluetoothPlotter; DIYables_BluetoothTable bluetoothTable; DIYables_BluetoothAnalogGauge bluetoothGauge(0.0, 100.0, "%"); DIYables_BluetoothRotator bluetoothRotator(ROTATOR_MODE_CONTINUOUS); // State variables int currentSlider1 = 128; int currentSlider2 = 64; int currentJoystickX = 0; int currentJoystickY = 0; float currentTemperature = 25.0; float currentGaugeValue = 50.0; float currentRotatorAngle = 0.0; int messageCount = 0; // Timing variables unsigned long lastMonitorUpdate = 0; unsigned long lastTempUpdate = 0; unsigned long lastPlotUpdate = 0; unsigned long lastTableUpdate = 0; unsigned long lastGaugeUpdate = 0; float plotPhase = 0; void setup() { Serial.begin(9600); delay(1000); Serial.println("DIYables Bluetooth - Multiple Apps Example"); // Initialize built-in LED pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); // Initialize Bluetooth server bluetoothServer.begin(); // Register all apps with the server bluetoothServer.addApp(&bluetoothMonitor); bluetoothServer.addApp(&bluetoothChat); bluetoothServer.addApp(&bluetoothSlider); bluetoothServer.addApp(&bluetoothJoystick); bluetoothServer.addApp(&bluetoothTemperature); bluetoothServer.addApp(&bluetoothPlotter); bluetoothServer.addApp(&bluetoothTable); bluetoothServer.addApp(&bluetoothGauge); bluetoothServer.addApp(&bluetoothRotator); Serial.print("Registered apps: "); Serial.println(bluetoothServer.getAppCount()); // Configure Plotter bluetoothPlotter.setPlotTitle("Sensor Data"); bluetoothPlotter.setAxisLabels("Time", "Value"); bluetoothPlotter.setYAxisRange(-1.5, 1.5); bluetoothPlotter.setMaxSamples(100); bluetoothPlotter.setLegendLabels("Sine", "Cosine", "Random"); // Configure Table rows bluetoothTable.addRow("Status"); bluetoothTable.addRow("Uptime"); bluetoothTable.addRow("Slider 1"); bluetoothTable.addRow("Slider 2"); bluetoothTable.addRow("Joystick X"); bluetoothTable.addRow("Joystick Y"); bluetoothTable.addRow("Temperature"); bluetoothTable.addRow("Gauge Value"); bluetoothTable.addRow("Rotator Angle"); bluetoothTable.addRow("Messages"); // Set up all callbacks setupCallbacks(); Serial.println("Waiting for Bluetooth connection..."); } void setupCallbacks() { // ---- Connection events ---- bluetoothServer.setOnConnected([]() { Serial.println("Bluetooth connected!"); digitalWrite(LED_BUILTIN, HIGH); bluetoothMonitor.send("=== DIYables Multi-App Connected ==="); bluetoothMonitor.send("All apps are ready!"); bluetoothChat.send("Hello! Arduino Multi-App is connected."); }); bluetoothServer.setOnDisconnected([]() { Serial.println("Bluetooth disconnected!"); digitalWrite(LED_BUILTIN, LOW); }); // ---- Monitor callbacks ---- bluetoothMonitor.onMonitorMessage([](const String& message) { Serial.println("Monitor cmd: " + message); if (message == "HELP") { bluetoothMonitor.send("Commands: STATUS, HELP, LED_ON, LED_OFF"); } else if (message == "STATUS") { bluetoothMonitor.send("Slider1=" + String(currentSlider1) + " Slider2=" + String(currentSlider2)); bluetoothMonitor.send("Joystick X=" + String(currentJoystickX) + " Y=" + String(currentJoystickY)); bluetoothMonitor.send("Temp=" + String(currentTemperature, 1) + "°C"); bluetoothMonitor.send("Gauge=" + String(currentGaugeValue, 1) + "%"); bluetoothMonitor.send("Rotator=" + String(currentRotatorAngle, 0) + "°"); } else if (message == "LED_ON") { digitalWrite(LED_BUILTIN, HIGH); bluetoothMonitor.send("LED turned ON"); } else if (message == "LED_OFF") { digitalWrite(LED_BUILTIN, LOW); bluetoothMonitor.send("LED turned OFF"); } else { bluetoothMonitor.send("Unknown: " + message + " (type HELP)"); } }); // ---- Chat callbacks ---- bluetoothChat.onChatMessage([](const String& message) { Serial.println("Chat: " + message); bluetoothChat.send("Echo: " + message); if (message.equalsIgnoreCase("ping")) { bluetoothChat.send("pong!"); } else if (message.equalsIgnoreCase("status")) { bluetoothChat.send("Uptime: " + String(millis() / 1000) + "s, Apps: " + String(bluetoothServer.getAppCount())); } }); // ---- Slider callbacks ---- bluetoothSlider.onSliderValue([](int slider1, int slider2) { currentSlider1 = slider1; currentSlider2 = slider2; Serial.print("Slider 1: "); Serial.print(slider1); Serial.print(", Slider 2: "); Serial.println(slider2); // Update gauge based on slider 1 currentGaugeValue = map(slider1, 0, 255, 0, 100); bluetoothGauge.send(currentGaugeValue); // Update table bluetoothTable.sendValueUpdate("Slider 1", String(slider1)); bluetoothTable.sendValueUpdate("Slider 2", String(slider2)); bluetoothTable.sendValueUpdate("Gauge Value", String(currentGaugeValue, 1) + "%"); }); bluetoothSlider.onGetConfig([]() { bluetoothSlider.send(currentSlider1, currentSlider2); }); // ---- Joystick callbacks ---- bluetoothJoystick.onJoystickValue([](int x, int y) { currentJoystickX = x; currentJoystickY = y; Serial.print("Joystick X: "); Serial.print(x); Serial.print(", Y: "); Serial.println(y); // Update table bluetoothTable.sendValueUpdate("Joystick X", String(x)); bluetoothTable.sendValueUpdate("Joystick Y", String(y)); }); bluetoothJoystick.onGetConfig([]() { bluetoothJoystick.send(currentJoystickX, currentJoystickY); }); // ---- Temperature callbacks ---- bluetoothTemperature.onTemperatureRequest([]() { bluetoothTemperature.send(currentTemperature); }); // ---- Plotter callbacks ---- bluetoothPlotter.onDataRequest([]() { Serial.println("Plotter data requested"); }); // ---- Table callbacks ---- bluetoothTable.onDataRequest([]() { Serial.println("Table data requested"); bluetoothTable.sendTableStructure(); updateAllTableValues(); }); // ---- Gauge callbacks ---- bluetoothGauge.onValueRequest([]() { bluetoothGauge.send(currentGaugeValue); }); // ---- Rotator callbacks ---- bluetoothRotator.onRotatorAngle([](float angle) { currentRotatorAngle = angle; Serial.print("Rotator: "); Serial.print(angle); Serial.println("°"); bluetoothTable.sendValueUpdate("Rotator Angle", String(angle, 0) + "°"); }); } void updateAllTableValues() { bluetoothTable.sendValueUpdate("Status", "Running"); unsigned long uptime = millis() / 1000; String uptimeStr; if (uptime >= 60) { uptimeStr = String(uptime / 60) + "m " + String(uptime % 60) + "s"; } else { uptimeStr = String(uptime) + "s"; } bluetoothTable.sendValueUpdate("Uptime", uptimeStr); bluetoothTable.sendValueUpdate("Slider 1", String(currentSlider1)); bluetoothTable.sendValueUpdate("Slider 2", String(currentSlider2)); bluetoothTable.sendValueUpdate("Joystick X", String(currentJoystickX)); bluetoothTable.sendValueUpdate("Joystick Y", String(currentJoystickY)); bluetoothTable.sendValueUpdate("Temperature", String(currentTemperature, 1) + " °C"); bluetoothTable.sendValueUpdate("Gauge Value", String(currentGaugeValue, 1) + "%"); bluetoothTable.sendValueUpdate("Rotator Angle", String(currentRotatorAngle, 0) + "°"); bluetoothTable.sendValueUpdate("Messages", String(messageCount)); } void loop() { bluetoothServer.loop(); if (!bluetooth.isConnected()) { delay(10); return; } // ---- Monitor: periodic status every 5 seconds ---- if (millis() - lastMonitorUpdate >= 5000) { lastMonitorUpdate = millis(); messageCount++; bluetoothMonitor.send("[INFO] Heartbeat #" + String(messageCount) + " - Uptime: " + String(millis() / 1000) + "s"); } // ---- Temperature: update every 2 seconds ---- if (millis() - lastTempUpdate >= 2000) { lastTempUpdate = millis(); // Simulate temperature with slight variation static float tempOffset = 0; tempOffset += random(-10, 11) / 10.0; if (tempOffset > 5.0) tempOffset = 5.0; if (tempOffset < -5.0) tempOffset = -5.0; currentTemperature = 25.0 + tempOffset; bluetoothTemperature.send(currentTemperature); bluetoothTable.sendValueUpdate("Temperature", String(currentTemperature, 1) + " °C"); } // ---- Plotter: update every 100ms ---- if (millis() - lastPlotUpdate >= 100) { lastPlotUpdate = millis(); float sine = sin(plotPhase); float cosine = cos(plotPhase); float noise = random(-50, 51) / 100.0; bluetoothPlotter.send(sine, cosine, noise); plotPhase += 0.1; if (plotPhase > 2 * PI) plotPhase = 0; } // ---- Table: update uptime every 5 seconds ---- if (millis() - lastTableUpdate >= 5000) { lastTableUpdate = millis(); unsigned long uptime = millis() / 1000; String uptimeStr; if (uptime >= 60) { uptimeStr = String(uptime / 60) + "m " + String(uptime % 60) + "s"; } else { uptimeStr = String(uptime) + "s"; } bluetoothTable.sendValueUpdate("Uptime", uptimeStr); bluetoothTable.sendValueUpdate("Messages", String(messageCount)); } // ---- Gauge: simulate sensor every 3 seconds ---- if (millis() - lastGaugeUpdate >= 3000) { lastGaugeUpdate = millis(); float sensorValue = 50.0 + 30.0 * sin(millis() / 10000.0); currentGaugeValue = sensorValue; bluetoothGauge.send(currentGaugeValue); bluetoothTable.sendValueUpdate("Gauge Value", String(currentGaugeValue, 1) + "%"); } delay(10); }
  • Arduino IDE에서 Upload 버튼을 클릭하여 코드를 Arduino UNO R4 WiFi에 업로드합니다.
  • 시리얼 모니터를 엽니다.
  • 시리얼 모니터에서 결과를 확인합니다. 아래와 같이 표시됩니다:
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno R4 WiFi
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno R4 WiFi' on 'COM15')
New Line
9600 baud
DIYables Bluetooth - Multiple Apps Example Waiting for Bluetooth connection...
Ln 11, Col 1
Arduino Uno R4 WiFi on COM15
2

모바일 앱

  • 스마트폰에 DIYables 블루투스 앱을 설치하세요: Android | iOS

참고: DIYables 블루투스 앱은 Android에서 BLE와 클래식 블루투스를 모두 지원하고, iOS에서는 BLE를 지원합니다. Arduino UNO R4 WiFi는 BLE를 사용하므로 앱은 Android와 iOS 모두에서 작동합니다. BLE에는 수동 페어링이 필요 없으며 스캔하고 연결하기만 하면 됩니다.

  • DIYables 블루투스 앱을 엽니다.
  • 처음 앱을 열면 권한을 요청합니다. 다음을 허용해 주세요:
    • 주변 기기(Nearby Devices) 권한(Android 12+) / 블루투스 권한(iOS) - 블루투스 기기를 스캔하고 연결하는 데 필요합니다.
    • 위치(Location) 권한(Android 11 이하만 해당) - 구형 Android 버전에서 BLE 기기를 스캔하는 데 필요합니다.
  • 휴대폰에서 블루투스가 켜져 있는지 확인합니다.
  • 홈 화면에서 Connect 버튼을 탭합니다. 앱이 BLE 기기를 스캔합니다.
diyaBLEs 블루투스 앱 - 스캔 버튼이 있는 홈 화면
  • 스캔 결과에서 "DIYables Multi-App"을 찾아 탭하여 연결합니다.
  • 연결되면 앱이 자동으로 홈 화면으로 돌아갑니다. 홈 화면에 사용 가능한 모든 앱이 표시됩니다. Arduino 코드에서 초기화된 9개의 앱이 응답하고 작동하며, 홈 화면의 다른 앱은 표시되지만 이 스케치와 함께 작동하지 않습니다.
diyaBLEs 블루투스 앱 - 다중 앱이 있는 홈 화면

참고: 홈 화면의 설정 아이콘을 탭하면 앱을 표시하거나 숨길 수 있습니다. 자세한 내용은 DIYables 블루투스 앱 사용 설명서를 참조하세요.

  • 다음 앱 중 일부를 탭하여 Arduino와 상호 작용하세요: 모니터, 채팅, 슬라이더, 조이스틱, 온도계, 플로터, 테이블, 아날로그 게이지, 로테이터
  • 앱 간을 자유롭게 전환하세요 - 모두 동일한 BLE 연결을 공유합니다.

이제 Arduino IDE의 시리얼 모니터를 다시 확인하세요. 다음과 같이 표시됩니다:

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno R4 WiFi
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno R4 WiFi' on 'COM15')
New Line
9600 baud
Bluetooth connected! Monitor: System running, uptime: 5s Chat message: Hello Slider value: 128 Joystick: X=0.50, Y=-0.30 Temperature: 22.50 °C
Ln 11, Col 1
Arduino Uno R4 WiFi on COM15
2

작동 원리

앱 초기화

각 앱은 자체 구성 및 콜백으로 생성됩니다:

// All apps share the same Bluetooth server DIYables_BluetoothServer bluetoothServer(bluetooth); // Create individual apps DIYables_BluetoothMonitor bluetoothMonitor(bluetoothServer); DIYables_BluetoothChat bluetoothChat(bluetoothServer); DIYables_BluetoothSlider bluetoothSlider(bluetoothServer, 0, 255, 1); DIYables_BluetoothJoystick bluetoothJoystick(bluetoothServer, false, 5); DIYables_BluetoothTemperature bluetoothTemp(bluetoothServer, -10.0, 50.0, "°C"); DIYables_BluetoothPlotter bluetoothPlotter(bluetoothServer); DIYables_BluetoothTable bluetoothTable(bluetoothServer); DIYables_BluetoothAnalogGauge bluetoothGauge(bluetoothServer, 0.0, 100.0, "%"); DIYables_BluetoothRotator bluetoothRotator(bluetoothServer, ROTATOR_MODE_CONTINUOUS);

앱 간 상호 작용

앱들이 서로 상호 작용할 수 있습니다 - 한 앱이 입력을 받으면 다른 앱을 업데이트할 수 있습니다:

// Slider updates gauge and table bluetoothSlider.onSliderValue([](int value) { float percent = value * 100.0 / 255.0; bluetoothGauge.send(percent); bluetoothTable.sendValueUpdate("Slider 1", String(value)); }); // Joystick updates table bluetoothJoystick.onJoystickValue([](float x, float y) { bluetoothTable.sendValueUpdate("Joystick X", String(x, 2)); bluetoothTable.sendValueUpdate("Joystick Y", String(y, 2)); }); // Rotator updates table bluetoothRotator.onRotatorAngle([](float angle) { bluetoothTable.sendValueUpdate("Rotator Angle", String(angle, 1) + "°"); });

업데이트 타이밍

각 앱에는 응답성과 대역폭의 균형을 맞추는 자체 업데이트 간격이 있습니다:

void loop() { bluetoothServer.loop(); unsigned long now = millis(); // Plotter: fastest updates (100ms) if (now - lastPlotterTime >= 100) { ... } // Temperature: every 2 seconds if (now - lastTempTime >= 2000) { ... } // Gauge: every 3 seconds if (now - lastGaugeTime >= 3000) { ... } // Monitor, Table: every 5 seconds if (now - lastMonitorTime >= 5000) { ... } if (now - lastTableTime >= 5000) { ... } }

테이블 구조

예제는 모든 앱의 데이터를 표시하는 10행 테이블을 생성합니다:

레이블 설명
0 상태(Status) 연결/실행 상태
1 가동 시간(Uptime) 부팅 이후 경과 시간
2 슬라이더 1(Slider 1) 현재 슬라이더 값
3 슬라이더 2(Slider 2) 두 번째 슬라이더 값
4 조이스틱 X(Joystick X) 조이스틱 X 위치
5 조이스틱 Y(Joystick Y) 조이스틱 Y 위치
6 온도(Temperature) 현재 온도
7 게이지 값(Gauge Value) 현재 게이지 퍼센트
8 로테이터 각도(Rotator Angle) 현재 회전 각도
9 메시지(Messages) 채팅 메시지 수

창의적인 커스터마이징 - 프로젝트에 맞게 코드 적용하기

앱 추가 또는 제거

9개의 앱이 모두 필요하지 않습니다. 필요한 앱만 포함하세요:

// Minimal setup: just Monitor and Slider DIYables_BluetoothMonitor bluetoothMonitor(bluetoothServer); DIYables_BluetoothSlider bluetoothSlider(bluetoothServer, 0, 100, 1); // That's it! The app will only show these two

사용자 지정 앱 간 로직

// Example: Temperature alarm via Monitor void checkTemperatureAlarm(float temp) { if (temp > 40.0) { bluetoothMonitor.send("⚠️ HIGH TEMP ALERT: " + String(temp, 1) + "°C"); bluetoothChat.send("Temperature alarm triggered!"); } }

문제 해결

일반적인 문제

1. 앱에서 기기를 찾을 수 없음

  • Arduino UNO R4 WiFi가 전원이 켜져 있고 스케치가 업로드되어 있는지 확인하세요.
  • 휴대폰의 블루투스가 활성화되어 있는지 확인하세요.
  • Android 11 이하에서는 위치 서비스도 활성화하세요.

2. 일부 앱이 메뉴에 표시되지 않음

  • 초기화된 모든 앱은 자동으로 표시됩니다.
  • 각 앱 객체가 올바르게 생성되었는지 확인하세요.
  • 앱은 Arduino에서 사용 가능한 앱을 검색합니다.

3. 업데이트가 느려 보임

  • 각 앱에는 서로 다른 업데이트 간격이 있습니다 - 이는 설계에 의한 것입니다.
  • BLE는 대역폭이 제한적이며, 너무 많은 빠른 업데이트는 혼잡을 유발할 수 있습니다.
  • 실시간 데이터가 필요하지 않은 앱의 업데이트 빈도를 줄이세요.

4. 앱 간 업데이트가 작동하지 않음

  • 콜백 함수가 올바르게 설정되어 있는지 확인하세요.
  • 테이블 행 이름이 정확히 일치하는지 확인하세요(대소문자 구분).
  • 대상 앱 객체가 콜백 범위 내에서 액세스 가능한지 확인하세요.

5. 메모리 문제 또는 충돌

  • 9개의 앱을 실행하면 상당한 메모리를 사용합니다.
  • 사용하지 않는 앱을 제거하여 리소스를 확보하세요.
  • 필요한 경우 테이블 행 수를 줄이세요.

6. 업로드 실패 또는 보드를 인식하지 못함

  • 보드 관리자를 통해 최신 Arduino UNO R4 보드 패키지를 설치하세요.
  • 다른 USB 케이블이나 포트를 사용해 보세요.

프로젝트 아이디어

  • 종합 IoT 대시보드
  • 로봇 제어판(조이스틱 + 모니터 + 슬라이더)
  • 기상 관측소(온도계 + 게이지 + 플로터 + 테이블)
  • 홈 자동화 허브(슬라이더 + 핀 + 모니터 + 채팅)
  • STEM 학습 플랫폼(모든 앱으로 실험)

다음 단계

다중 앱 예제를 마스터한 후, 더 깊이 이해하기 위해 개별 앱 튜토리얼을 탐색해 보세요:

  1. 블루투스 채팅 - 메시지 세부 사항
  2. 블루투스 슬라이더 - 값 제어 세부 사항
  3. 블루투스 플로터 - 데이터 시각화 세부 사항
  4. 블루투스 RTC - 시간 동기화(내장 하드웨어 RTC 사용)

지원

추가 도움이 필요하면:

  • API 레퍼런스 문서를 확인하세요.
  • DIYables 튜토리얼을 방문하세요.
  • Arduino 커뮤니티 포럼