안녕하세요^^


이번시간엔 아두이노는 아두이노인데, 블루투스가 함께 내장된 아두이노인 블루노(Bluno), 그 중에서도 비틀(Beetle)에 대해 포스팅을 해보도록 하겠습니다.



(주말이라 교회 모임가기전에 간만에 카페에서 여유롭게 포스팅을...!ㅎㅎ)


먼저 블루노 비틀은 위와같이 생긴 칩이고, 블루투스가 되는 모듈도 있고, 안되는 모듈도 있으니 잘 확인하시고 구매하시기 바랍니다^^


우선 하드웨어 스펙부터 살펴볼게요


이 제품은 위키(wiki)가 정말 잘 되어있어서 여기만 보셔도 무난할 듯 하지마,

 처음부터 쭈욱 설명드리도록 하겠습니다!



먼저 메인 MPU로는 ATmega 328을 사용하고 있습니다. 때문에 기존 아두이노와 같이 사용이 가능하구요, 다만 물리적으로 핀이 좀 적게 나와있어서 불편할 수도 있지만, 복잡한 시스템을 만드실게 아니라면 충분하실 듯 하네요ㅎㅎ



그럼 한번 만들어 볼까요?


# 1


무선 정보 설정하기


먼저 블루노 비틀은 블루투스를 사용하기때문에, 컴퓨터나 핸드폰에서 장치를 찾을 수 있습니다.



저는 윈도우에서 확인했습니다만, 보시면 'Bluno'라는 이름이 보이시죠?

바로 기본적으로 세팅된 이름이 'bluno'로 되어있기 때문이랍니다.


사실 사용하는 목적에 따라 블루투스 이름을 바꿔주는게 사용하기도 편하겠죠?

그럼 어떻게 이름을 바꾸는지 알아봅시다.


먼저, 'AT-command'라는 몇몇 명령어들이 있습니다.

이를 이용하면 이름, 통신속도, 암호화방법, 등등 수많은 옵션들을 바꿀수 있답니다.



이름을 바꾸려면 먼저 비틀을 PC와 연결하고, 아두이노IDE를 실행합니다.



먼저 보드 세팅을 UNO로 맞춰주시고, (비틀은 UNO로 맞춰져있더라구요~)

포트를 맞춰서 잡아주세요ㅎㅎ


그 다음은 시리얼 모니터를 켜셔서 아래와 같이 

"No line ending"

을 선택해주시고, Baudrate도 115200으로 설정해주세요~!

그리고 +++를 입력하시고, 

아래처럼 'Enter AT Mode'라는 말이 뜨면 AT-command mode로 들어간겁니다.

만약에 안뜬다면, 설정을 다시 한번 확인해보세요^^



자 그럼 AT-command mode에 접속했으니, 명령이 잘 먹히는지 확인해봅시다.

AT-command를 사용할때는 line설정을 또 바꿔줘야합니다.

"Both NL & CR"

을 선택하셔야해요!!


그런 뒤 AT를 입력하면 아래처럼 OK라는 문구가 뜨면 성공!



이제 이름을 바꿔볼까요~?


이름은 

AT+NAME=원하는 이름

이렇게 설정하시면 됩니다.



그리고 세팅을 마치고나서는 AT-command mode를 나가야겠지요?


AT+EXIT을 입력해서 설정을 마칩니다.


그리고 PC나 폰에서 확인하시면 이름이 변경되어있을거에요~!

혹시나 변경이 안되어있으면, 블루노를 껐다 켜시거나, 

PC나 폰의 Bluetooth를 껐다 켜보시면 될겁니다.


그 외에 몇가지 설정해야할것들이 더 있는데, 보통의 블루투스는 페어링할때 암호를 필요로한답니다.

하지만 모드를 HID connection로 변경하면 암호를 입력하지 않아도 연결이 되요~!


이 외의 많은 명령어들이 있는데, 포스팅의 마지막에 둘테니 한번 참고하세요^^



# 2


아두이노에서 사용할 수 있는 기능들


자 이제 제대로 블루노를 사용해볼까요?


사실 함수는 대단한것들이 있지는 않아요~

Serial 함수를 통해 데이터를 보내면 자동으로 블루노 하드웨어에 있는 블루투스 칩으로 데이터가 전송이 되고, 

이 블루투스 칩에서 전달받은 데이터를 무선으로 쏴준답니다ㅎㅎ


참 쉽죠잉~!


# 3


스마트폰을 통한 무선 시리얼 모니터링



자 그럼 테스트를 한번 해볼까요?


먼저 아두이노에서 Serial통신을 세팅해서 1초에 2번 아날로그 데이터를 전송하도록 코딩을 합시다.


void setup() {

  // put your setup code here, to run once:

  Serial.begin(115200);

}


void loop() {

  // put your main code here, to run repeatedly:

  Serial.println(analogRead(A0));

  delay(500);

}


위 코드를 업로드 하고, 폰에서 앱을 다운받습니다.


안드로이드나 아두이노나 Bluno를 검색하면 앱이 나올거에요~^^

저는 아이폰이라서 앱스토어에서 검색하니 Bluno terminal이라는 앱이 있더라구요



앱을 다운받아 실행하고, 따로 페어링이나 옵션을 설정안해도 자동으로 연결이 된답니다. (신기신기..)



그리고 이 블루투스로 전송되는 신호는 PC에서도 모니터링이 된답니다.



Debug 세팅이 ON이 되어있다면 가능한거구요, 이 설정을 끄면 PC에서는 모니터링이 안됩니다.

아래 AT 명령어에서 11번을 참고하세요^^


이상으로 테스트는 끝!



# 4


블루노를 위한 AT 명령어들 (AT-command sets)



1. "AT+FSM" change the working mode

AT+FSM=FSM_TRANS_USB_COM_BLE<CR+LF>USB-UART BLE transparent mode
AT+FSM=FSM_HID_USB_COM_BLE_AT<CR+LF>USB-UART BLE HID mode
AT+FSM=?<CR+LF>Request the working mode (default: FSM_TRANS_USB_COM_BLE)

여기서 Transparent mode블루노  <ㅡ>  블루노 의 통신을 할때를 의미합니다.

이때는 블루노 하나는 Central로, 또 다른 하나는 Peripheral로 설정을 해야한답니다. (11번 설정 참고!)

HID mode는 블루노 <ㅡ> 스마트폰. PC등과 연결할때 필요한 설정입니다^^


1*. "AT+KEY" to simulate pressing some buttons in HID mode, read FAQ 16 below for How to use HID mode.
AT+KEY=keyValue0<CR+LF>To simulate one button was pressed
AT+KEY=keyValue0+keyValue1<CR+LF>To simulate two buttons was pressed
AT+KEY=keyValue0+keyValue1+keyValue2<CR+LF>To simulate three buttons was pressed


2. "AT+ROLE" change the CENTRAL-PERIPHERAL configuration

AT+ROLE=ROLE_CENTRAL<CR+LF>BLE CENTRAL mode
AT+ROLE=ROLE_PERIPHERAL<CR+LF>BLE PERIPHERAL mode
AT+ROLE=?<CR+LF>Request the CENTRAL-PERIPHERAL configuration (default: ROLE_PERIPHERAL)


3. "AT+MIN_INTERVAL" change the minimum connection interval

AT+MIN_INTERVAL=10<CR+LF>Recommended minimum connection interval (10ms) for PC and Android
AT+MIN_INTERVAL=20<CR+LF>Recommended minimum connection interval (20ms) for IOS
AT+MIN_INTERVAL=?<CR+LF>Request the minimum connection interval (default: 10)


4. "AT+MAX_INTERVAL" change the maximum connection interval

AT+MAX_INTERVAL=10<CR+LF>Recommended maximum connection interval (10ms) for PC and Android
AT+MAX_INTERVAL=40<CR+LF>Recommended maximum connection interval (40ms) for IOS
AT+MAX_INTERVAL=?<CR+LF>Request the maximum connection interval (default: 10)


5. "AT+UART" change the baud rate of UART

AT+UART=115200<CR+LF>Set the baud rate to 115200
AT+UART=?<CR+LF>Request the baud rate of UART (default: 115200,8,N,1)


6. "AT+BIND" bind another BLE chip. BLE can only connect to the BLE chip with this MAC address

AT+BIND=0x0017ea9397e1<CR+LF>Set the BLE binding (destination) MAC address to 0x0017ea9397e1
AT+BIND=?<CR+LF>Request the binding (destination) MAC address (default: 0x8A6D3B8A6D3B)


7. "AT+CMODE" set whether the connection of BLE is binding or arbitrary

AT+CMODE=UNIQUE<CR+LF>BLE can only connect to the BLE chip with binding(destination) MAC address (see "AT+BIND" command)
AT+CMODE=ANYONE<CR+LF>BLE can connect to any other BLE chips
AT+CMODE=?<CR+LF>Request the binding connection mode(default:ANYONE)


8. "AT+MAC" Request MAC address

AT+MAC=?<CR+LF>Request MAC address of the BLE


9. "AT+NAME" Set the name

AT+NAME=DFBLEduinoV1.0<CR+LF>Set the name of BLE to "DFBLEduinoV1.0".The length is limited to 13 Bytes or below
AT+NAME=?<CR+LF>Request the name of the BLE (default: DFBLEduinoV1.0)


10. "AT+RESTART" restart the BLE

AT+RESTART<CR+LF>Restart the BLE chip


11. "AT+SETTING" change the default setting (new in BLE firmware 1.6)

AT+SETTING=DEFAULT<CR+LF>Restore the default settings, same as PERIPHERAL mode
AT+SETTING=DEFPERIPHERAL<CR+LF>Restore the default settings for PERIPHERAL mode
AT+SETTING=DEFCENTRAL<CR+LF>Restore the default settings for CENTRAL mode
AT+SETTING=?<CR+LF>Request the setting mode (default: DEFPERIPHERAL). If the settings are changed by AT command, "UNKNOWN" will be replied.



12. "AT+BLUNODEBUG" When Bluetooth is connected and BLE chip(CC2540) received the UART message from MCU(ATMEGA328), send the UART message not only to the Bluetooth, but also to the USB port. So that when Bluetooth is connected, we can use the serial monitor to get the UART message. (new in BLE firmware 1.6)

AT+BLUNODEBUG=ON<CR+LF>Turn on the BLUNO DEBUG so that when Bluetooth is connected, we can use the serial monitor to get the UART message.
AT+BLUNODEBUG=OFF<CR+LF>Turn off the BLUNO DEBUG so that wireless programming will be more stable.
AT+BLUNODEBUG=?<CR+LF>Request the BLUNO DEBUG state (default: ON)

여기서 이 Debug function을 활성화 시키면, 블루투스로 전송하는 신호를 시리얼 모니터를 통해 어떤 신호가 나가는지를 모니터링(디버깅)할 수 있게 도와주는 설정이랍니다.

크게 필요한 경우가 아니라면, 안정적인 데이터 전송을 위해 꺼주세요~! 왜냐하면 블루투스 하나로 보낼 신호를 USB포트를 통해서 한번 더 보내주기 때문에 신호가 꼬이거나, 왜곡되는 현상이 발생할 수 있답니다!


13. "AT+USBDEBUG" When Bluetooth is connected and BLE chip(CC2540) received the Bluetooth message from IOS or Android device, send the data not only to the UART, but also to the USB port. So that when Bluetooth is connected, we can use the serial monitor to directly get the Bluetooth message. (new in BLE firmware 1.6)

AT+USBDEBUG=ON<CR+LF>Turn on the BLUNO DEBUG So that when Bluetooth is connected, we can use the serial monitor to directly get the Bluetooth message from IOS or Android device.
AT+USBDEBUG=OFF<CR+LF>Turn off the USB DEBUG so that wireless programming will be more stable.
AT+USBDEBUG=?<CR+LF>Request the USB DEBUG state (default: OFF)


14. "AT+TXPOWER" Change the Transmitted Power which will change the signal range. (new in BLE firmware 1.6)

AT+TXPOWER=0<CR+LF>Change the Transmitted Power to fit the iBeacon calibration. (4, 0, -6 -23 is acceptable)
AT+TXPOWER=?<CR+LF>Request the Transmitted Power (default: 0)


15. "AT+IBEACONS" Enable the iBeacons feature(new in BLE firmware 1.6)

AT+IBEACONS=ON<CR+LF>Enable the iBeacons feature.
AT+IBEACONS=OFF<CR+LF>Disable the iBeacons feature.
AT+IBEACONS=?<CR+LF>Request whether the iBeacons feature is enabled. (default: ON)


16. "AT+VERSION" the version of the firmware(new in BLE firmware 1.6)

AT+VERSION=?<CR+LF>Request the version of the firmware.


17. "AT+RSSI" Request the RSSI of the BLE (new in BLE firmware 1.6)

AT+RSSI=?<CR+LF>Request the RSSI of the BLE(if there is no connection, "-000" will be returned)


18. "AT+MAJOR" Set the major number of the iBeacons (new in BLE firmware 1.6)

AT+MAJOR=0<CR+LF>Set the major number of the iBeacons to "0". (0 to 65535 is acceptable)
AT+MAJOR=?<CR+LF>Request the major number of the iBeacons.(default "0")


19. "AT+MINOR" Set the minor number of the iBeacons (new in BLE firmware 1.6)

AT+MINOR=0<CR+LF>Set the minor number of the iBeacons to "0". (0 to 65535 is acceptable)
AT+MINOR=?<CR+LF>Request the minor number of the iBeacons.(default "0")


20. "AT+EXIT" Exit the AT Command Mode (new in BLE firmware 1.8 ),

AT+EXIT<CR+LF>

Exit the AT Command Mode.

네 이제 진짜 끝!ㅎㅎ

+ Recent posts