본문 바로가기

RaspberryPi/RaspberryPi PicoW

Raspberry Pi Pico W - Bluetooth BT Serial SPP 테스트

Raspberry Pi Pico W Bluetooth 는 BLE 및 Classic Bluetooth 기능를 제공하고 시리얼 기능이 있는 SPP를 테스트 해보자.

SPP는 기존 시리얼 통신 프로그램 기반 프로그램을 별다른 변경없이 무선으로 바꿀수 있다.

 

테스트 코드는 시리얼 포트로 송수신되는 데이터를 Bluetooth SPP로 주고 받을 수 있는 간단한 코드 이다.

#include <SerialBT.h>
#define SerialDebug Serial1

void setup() {
  SerialBT.begin();
  SerialDebug.begin(115200);

  SerialDebug.println("Pico W BT Serial Test.");
  pinMode(LED_BUILTIN,OUTPUT);
}

void loop() {
  byte c;
  
  while (SerialBT) {
    
    while (SerialBT.available()) 
    {
      c = SerialBT.read();
      SerialDebug.print(c); 
    }
    

    while (SerialDebug.available()) 
    {
      c = SerialDebug.read();
      SerialBT.print(c);  
    }

  }
}

 

시리얼 터미널 앱에서 PicoW Serial로 인식되는 것을 확인 할 수 있다.

 

터미널 창에서 데이터 송수신 되는것을 확인 할수 있다.

 


데스크탑 PC에서는 BLE 동글 장치를 이용해서 기존 시리얼 통신 프로그램을  무선으로 변경 가능하다.

Bluetooth 장치를 검색하면 장치 검색된 장치를 연결할 수 있다.

 

COM 포트를 추가 하고 할당된 포트로 통신 할 수 있다.

 

 

기존 시리얼 통신 프로그램으로 무선으로 시리얼 데이터가 송수신 되는것을 확인 할 수 있다.

시리얼  Bluetooth Serial Bridge장치를 만드면 좋을것 같다.

반응형