HC-06 Bluetooth Module JP: 두 판 사이의 차이

아두위키 : Arduwiki
(새 문서: center|class=coders100 This is a module equipped with Bluetooth functionality. It uses Bluetooth 2.0, which may present issues when used with iOS (Apple products). Testing with an iPhone 13, it was found that while messages from the iPhone to the HC-06 were displayed on the Serial Monitor, the reverse was not true, indicating an issue with operation in that direction. There are models that can switch between Master and Slave roles and models...)
 
잔글편집 요약 없음
1번째 줄: 1번째 줄:
[[File:Hc06대표이미지1.jpg|center|class=coders100]]
[[File:Hc06대표이미지1.jpg|center|class=coders100]]
This is a module equipped with Bluetooth functionality.
Bluetooth機能を搭載したモジュールです。


It uses Bluetooth 2.0, which may present issues when used with iOS (Apple products).
Bluetooth 2.0を使用しており、iOS(Apple製品)との互換性に問題が生じる場合があります。


Testing with an iPhone 13, it was found that while messages from the iPhone to the HC-06 were displayed on the Serial Monitor, the reverse was not true, indicating an issue with operation in that direction.
iPhone 13でのテストでは、iPhoneからHC-06へのメッセージはシリアルモニターに表示されましたが、逆方向の通信は正常に動作しませんでした。


There are models that can switch between Master and Slave roles and models that are fixed as Slave. Note that the Slave fixed models cannot change between master and slave roles using AT commands.
マスター/スレーブ切り替え可能モデルとスレーブ固定モデルが存在します。スレーブ固定モデルはATコマンドで役割を変更できません。




== '''Specifications''' ==
== '''仕様''' ==
 
* 動作電圧: 3.3V ~ 5V
* Operating Voltage: 3.3V ~ 5V
* Bluetooth 2.0
* Bluetooth 2.0
* Default Settings:
* デフォルト設定:
* NAME: HC-06
* 名称: HC-06
* BAUD RATE: 9600
* ボーレート: 9600
* PINCODE: 1234 or 0000
* パスコード: 1234 または 0000


== '''Required Hardware''' ==


== '''必要なハードウェア''' ==
* HC-06
* HC-06
* Arduino UNO
* Arduino UNO
* UNO Cable
* UNOケーブル
* F-M Cable (4 pieces)
* F-Mケーブル(4本)


== '''Connection''' ==
 
TXD and RXD are connected to any desired Digital pins on the UNO board.
== '''接続''' ==
TXD/RXDはUNOボードの任意のデジタルピンに接続します。
{| class="wikitable"
{| class="wikitable"
|+
|+
46번째 줄: 46번째 줄:
[[File:Hc06 회로.png|center|class=coders100]]
[[File:Hc06 회로.png|center|class=coders100]]


== '''Library''' ==
== '''ライブラリ''' ==
* SoftwareSerial (default library)


* SoftwareSerial (default library)


== '''AT command''' ==
== '''ATコマンド''' ==


* Connection status can be checked using AT commands.
* ATコマンドで接続状態を確認可能
* AT commands can be sent via the Serial Monitor.
* シリアルモニター経由でATコマンド送信可能
* AT commands will not work if the HC-06 module is connected to another device.
* HC-06が他デバイスと接続中はATコマンドが動作しません


[[File:AT commands.png|center|class=coders100]]
[[File:AT commands.png|center|class=coders100]]


== '''Example Code''' ==
 
== '''サンプルコード''' ==
<syntaxhighlight lang="c++" line="1">
<syntaxhighlight lang="c++" line="1">
#include <SoftwareSerial.h>
#include <SoftwareSerial.h>
// Using pins 6 and 7
// ピン6と7を使用
SoftwareSerial BTSerial(6, 7);
SoftwareSerial BTSerial(6, 7);


67번째 줄: 68번째 줄:
{
{
     Serial.begin(9600);
     Serial.begin(9600);
     // Start communication with the Bluetooth module at 9600 baud rate (default)
     // ボーレート9600(デフォルト)で通信開始
     BTSerial.begin(9600);
     BTSerial.begin(9600);
     Serial.println("Serial start");
     Serial.println("Serial start");
74번째 줄: 75번째 줄:
void loop()
void loop()
{
{
     // If there is data from the Bluetooth serial, write it to the Serial Monitor.
     // Bluetoothシリアルからデータ受信時、シリアルモニターに表示
     if (BTSerial.available())
     if (BTSerial.available())
     {
     {
80번째 줄: 81번째 줄:
     }
     }


     // If there is data from the Serial Monitor, write it to the Bluetooth serial.
     // シリアルモニターからデータ入力時、Bluetoothシリアルに送信
     if (Serial.available())
     if (Serial.available())
     {
     {
89번째 줄: 90번째 줄:
</syntaxhighlight>
</syntaxhighlight>


=== Operation Check ===
After uploading the code, enter AT in the Serial Monitor to test the operation.


If OK is displayed, it indicates that the module is functioning correctly.
=== 動作確認 ===
コードアップロード後、シリアルモニターで「AT」入力
「OK」表示されれば正常動作
[[File:AT result.png|center|class=coders100]]
[[File:AT result.png|center|class=coders100]]




=== Bluetooth Terminal Application Test ===
=== Bluetoothターミナルアプリテスト ===
 
# スマートフォンにBluetoothターミナルアプリをインストール
# Install a Bluetooth terminal application on your smartphone. The type of application does not matter.
# アプリ内でHC-06モジュールと接続
# Connect to the HC-06 Bluetooth module within the application.
# アプリの入力はシリアルモニターに、シリアルモニターの入力はアプリに表示
# Messages entered in the app will be displayed on the Serial Monitor, and conversely, messages entered in the Serial Monitor will be displayed in the app.


[[File:Hc06 앱테스트.png|center|class=coders100]]
[[File:Hc06 앱테스트.png|center|class=coders100]]

2025년 3월 20일 (목) 15:25 판

Bluetooth機能を搭載したモジュールです。

Bluetooth 2.0を使用しており、iOS(Apple製品)との互換性に問題が生じる場合があります。

iPhone 13でのテストでは、iPhoneからHC-06へのメッセージはシリアルモニターに表示されましたが、逆方向の通信は正常に動作しませんでした。

マスター/スレーブ切り替え可能モデルとスレーブ固定モデルが存在します。スレーブ固定モデルはATコマンドで役割を変更できません。


仕様

  • 動作電圧: 3.3V ~ 5V
  • Bluetooth 2.0
  • デフォルト設定:
  • 名称: HC-06
  • ボーレート: 9600
  • パスコード: 1234 または 0000


必要なハードウェア

  • HC-06
  • Arduino UNO
  • UNOケーブル
  • F-Mケーブル(4本)


接続

TXD/RXDはUNOボードの任意のデジタルピンに接続します。

HC-06 Arduino UNO
RXD D7
TXD D6
GND GND
VCC 5V

ライブラリ

  • SoftwareSerial (default library)


ATコマンド

  • ATコマンドで接続状態を確認可能
  • シリアルモニター経由でATコマンド送信可能
  • HC-06が他デバイスと接続中はATコマンドが動作しません


サンプルコード

#include <SoftwareSerial.h>
// ピン6と7を使用
SoftwareSerial BTSerial(6, 7);

void setup()
{
    Serial.begin(9600);
    // ボーレート9600(デフォルト)で通信開始
    BTSerial.begin(9600);
    Serial.println("Serial start");
}

void loop()
{
    // Bluetoothシリアルからデータ受信時、シリアルモニターに表示
    if (BTSerial.available())
    {
        Serial.write(BTSerial.read());
    }

    // シリアルモニターからデータ入力時、Bluetoothシリアルに送信 
    if (Serial.available())
    {
        BTSerial.write(Serial.read());
    }
}


動作確認

コードアップロード後、シリアルモニターで「AT」入力 「OK」表示されれば正常動作


Bluetoothターミナルアプリテスト

  1. スマートフォンにBluetoothターミナルアプリをインストール
  2. アプリ内でHC-06モジュールと接続
  3. アプリの入力はシリアルモニターに、シリアルモニターの入力はアプリに表示