HC-06 Bluetooth Module

아두위키 : Arduwiki
ArduWiki (토론 | 기여)님의 2024년 3월 23일 (토) 16:52 판 (Created page with "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...")
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

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 that are fixed as Slave. Note that the Slave fixed models cannot change between master and slave roles using AT commands.


Specifications

  • Operating Voltage: 3.3V ~ 5V
  • Bluetooth 2.0
  • Default Settings:
  • NAME: HC-06
  • BAUD RATE: 9600
  • PINCODE: 1234 or 0000

Required Hardware

  • HC-06
  • Arduino UNO
  • UNO Cable
  • F-M Cable (4 pieces)

Connection

TXD and RXD are connected to any desired Digital pins on the UNO board.

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

Library

  • SoftwareSerial (default library)

AT command

  • Connection status can be checked using AT commands.
  • AT commands can be sent via the Serial Monitor.
  • AT commands will not work if the HC-06 module is connected to another device.

Example Code

#include <SoftwareSerial.h>
// Using pins 6 and 7
SoftwareSerial BTSerial(6, 7);

void setup()
{
    Serial.begin(9600);
    // Start communication with the Bluetooth module at 9600 baud rate (default)
    BTSerial.begin(9600);
    Serial.println("Serial start");
}

void loop()
{
    // If there is data from the Bluetooth serial, write it to the Serial Monitor.
    if (BTSerial.available())
    {
        Serial.write(BTSerial.read());
    }

    // If there is data from the Serial Monitor, write it to the Bluetooth serial.
    if (Serial.available())
    {
        BTSerial.write(Serial.read());
    }
}

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.


Bluetooth Terminal Application Test

  1. Install a Bluetooth terminal application on your smartphone. The type of application does not matter.
  2. Connect to the HC-06 Bluetooth module within the application.
  3. 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.