질문게시판 > 아두이노 나노33 IOT 의 BLE 연결 문제

TODAY440 TOTAL2,592,961
사이트 이용안내
Login▼/회원가입
최신글보기 질문게시판 기술자료 동영상강좌

아두이노 센서 ATMEGA128 PWM LED 초음파 AVR 블루투스 LCD UART 모터 적외선


BASIC4MCU | 질문게시판 | 아두이노 나노33 IOT 의 BLE 연결 문제

페이지 정보

작성자 가루밀 작성일2023-02-24 09:53 조회95회 댓글0건

본문

	

아두이노 나노33 iot 의 ble 연결 때문에 고민하고 있습니다.

pc에 아두이노 스케치 프로그램 띄우고 보드와 USB로 연결한 상태로는 스마트폰과 BLE 연결 잘 됩니다.

스마트폰에는 "라이트블루"  앱이 깔려 있습니다.

 

자세히 설명하면 

1. 스케치 프로그램의 시리얼 모니터를 실행하기 전에는 스마트폰 앱에서 보드를 검색하지 못합니다

2. 시리얼모니터를 실행하면 스마트폰의 앱에서 보드 검색 됩니다.

3. 앱과 BLE 연결하여 기능을 확인 가능합니다

 

화면 캡처해서 정리 했습니다

574637a0ff9161c7904afd232533a9f7_1677201527_2945.png
 

 

PC  에서는 이렇게 BLE 연결 되는데, 문제는 PC연결이 아니고 외부전원 사용할 때입니다.

어댑터(5V1A )를 전원으로 보드에 연결해서 앱에서 검색을 시도하면, PC연결에서 시리얼모니터 실행전 상황처럼 스마트폰 앱에서 검색이 안됩니다

아두이노 보드의 리셋 버튼 눌러도 안됩니다.

 

 웹에서 이것저것 검색해도 저의 짧은 지식으로는 어렵네요.

이후에 배터리를 전원으로 연결해서 사용할 예정인데, 난감 합니다.

 

사용 코드는 스케치 프로그램의 BLE 샘플코드로 테스트 하고 있습니다.

=================================

/*
  LED

  This example creates a Bluetooth® Low Energy peripheral with service that contains a
  characteristic to control an LED.

  The circuit:
  - Arduino MKR WiFi 1010, Arduino Uno WiFi Rev2 board, Arduino Nano 33 IoT,
    Arduino Nano 33 BLE, or Arduino Nano 33 BLE Sense board.

  You can use a generic Bluetooth® Low Energy central app, like LightBlue (iOS and Android) or
  nRF Connect (Android), to interact with the services and characteristics
  created in this sketch.

  This example code is in the public domain.
*/

#include

BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // Bluetooth® Low Energy LED Service

// Bluetooth® Low Energy LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);

const int ledPin = LED_BUILTIN; // pin to use for the LED

void setup() {
  Serial.begin(9600);
  while (!Serial);

  // set LED pin to output mode
  pinMode(ledPin, OUTPUT);

  // begin initialization
  if (!BLE.begin()) {
    Serial.println("starting Bluetooth® Low Energy module failed!");

    while (1);
  }

  // set advertised local name and service UUID:
  BLE.setLocalName("LED");
  BLE.setAdvertisedService(ledService);

  // add the characteristic to the service
  ledService.addCharacteristic(switchCharacteristic);

  // add service
  BLE.addService(ledService);

  // set the initial value for the characeristic:
  switchCharacteristic.writeValue(0);

  // start advertising
  BLE.advertise();

  Serial.println("BLE LED Peripheral");
}

void loop() {
  // listen for Bluetooth® Low Energy peripherals to connect:
  BLEDevice central = BLE.central();

  // if a central is connected to peripheral:
  if (central) {
    Serial.print("Connected to central: ");
    // print the central's MAC address:
    Serial.println(central.address());

    // while the central is still connected to peripheral:
    while (central.connected()) {
      // if the remote device wrote to the characteristic,
      // use the value to control the LED:
      if (switchCharacteristic.written()) {
        if (switchCharacteristic.value()) {   // any value other than 0
          Serial.println("LED on");
          digitalWrite(ledPin, HIGH);         // will turn the LED on
        } else {                              // a 0 value
          Serial.println(F("LED off"));
          digitalWrite(ledPin, LOW);          // will turn the LED off
        }
      }
    }

    // when the central disconnects, print it out:
    Serial.print(F("Disconnected from central: "));
    Serial.println(central.address());
  }
}


 

  • BASIC4MCU 작성글 SNS에 공유하기
  • 페이스북으로 보내기
  • 트위터로 보내기
  • 구글플러스로 보내기

댓글 0

조회수 95

등록된 댓글이 없습니다.

질문게시판HOME > 질문게시판 목록

MCU, AVR, 아두이노 등 전자공학에 관련된 질문을 무료회원가입 후 작성해주시면 전문가가 답변해드립니다.
ATMEGA128PWMLED초음파
아두이노AVR블루투스LCD
UART모터적외선ATMEGA
전체 스위치 센서
질문게시판 목록
제목 작성자 작성일 조회
공지 MCU, AVR, 아두이노 등 전자공학에 관련된 질문은 질문게시판에서만 작성 가능합니다. 스태프 19-01-15 17377
공지 사이트 이용 안내댓글[28] master 17-10-29 33600
질문 아두이노 코딩 질문댓글[2] 이미지새글첨부파일 pmh11 23-04-01 20
질문 라즈베리 파이 질문댓글[1] 새글 rasp 23-03-31 21
질문 아두이노 코드관련 질문댓글[1] 새글 왕초봉 23-03-31 22
질문 아두이노 led 부저 스위치 김똘 23-03-30 28
답변 답변글 답변 : 아두이노 led 부저 스위치댓글[4] master 23-03-30 39
질문 아두이노 근접센서 2개 연결 질문댓글[1] 김민종 23-03-29 29
질문 아두이노 코딩 에러 질문댓글[1] 이미지첨부파일 박무농 23-03-25 60
질문 아두이노를 이용한 타이머, 태양전지 제어댓글[2] 박무농 23-03-25 61
질문 sd카드 이미지 전송댓글[2] 던지기마스터 23-03-24 39
질문 초음파센서를 이용한 모터제어 질문있습니다.댓글[3] 이미지첨부파일 뉴비에오 23-03-24 81
질문 부품 관련 문의댓글[1] 타코 23-03-23 42
질문 모터 작동 시, 일부 모듈이 꺼지는 현상에 대해 질문드립니다. 이미지 그렇찌 23-03-22 56
답변 답변글 답변 : 모터 작동 시, 일부 모듈이 꺼지는 현상에 대해 질문드립니다. 이미지 master 23-03-23 37
질문 ESP로 원격 모터제어를 할 수 있나용?댓글[1] 비차 23-03-22 45
질문 HC06을 마스터로 설정하면 HC06끼리만 통신되나요?댓글[4] 비차 23-03-21 58
질문 아두이노 제어하기댓글[3] 매드닥터 23-03-19 75
질문 atmega128 압력센서 관련 질문입니다댓글[1] 공린이 23-03-19 96
질문 아두이노 스텝모터 각도제어 질문댓글[3] master 23-03-17 94
질문 아두이노와 파이썬(중점좌표) 시리얼 통신 질문드립니다.댓글[1] 이미지첨부파일 아두이노어렵잖아 23-03-16 62
질문 아두이노 3LED 버튼 관련 질문댓글[1] 이츤 23-03-16 70
질문 ATmega328p로 pca9685를 이용하여 서보모터(mg996r, mg90s)를 pwm로 제어 중 떨림댓글[1] 이미지첨부파일 토비 23-03-15 71
질문 hm-10 다중연결 질문있습니다.댓글[1] 첨부파일 뉴비에오 23-03-14 62
질문 while loop 실행 속도댓글[1] 412904 23-03-12 91
질문 AND 연산 질문드립니다.댓글[1] 412904 23-03-11 92
질문 아두이노 테트리스 게임댓글[1] 첨부파일 지욱애 23-03-02 189
질문 아두이노우노 블루투스 2개 연결댓글[1] dsfadfs 23-02-28 151
질문 스텝모터 코딩 질문입니다..댓글[2] 무야더싱 23-02-25 167
현재글 아두이노 나노33 IOT 의 BLE 연결 문제 이미지 가루밀 23-02-24 96
게시물 검색

2022년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2021년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2020년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2019년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2018년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
Privacy Policy
MCU BASIC ⓒ 2020
모바일버전으로보기