2016년 1월 12일 화요일

HC-05 Manual



@#$%



I refered to this blog below
http://phillipecantin.blogspot.ca/search/label/HC-05
전부해석하면 너무 길어서 필요한 부분만 해석했습니다.
댓글 달아주세요


HC-05 BlueTooth link with zero code


필요한것들 ▼
For this, you will need:

  • 1 Arduino (I'm using UNO)
  • 2 HC-05 modules
  • 1 breadboard
  • Wires
  • Arduino IDE (i'm using version 1.0.5-r2)
Step 1 - Code and Wires
To bind the two HC-05s, we will need to input AT commands manually which can be done using this simple code.



    Upload the simple code above
    and carefully connect the wires like below.


    WIRING

    • HC-05 GND --- Arduino GND PIN
    • HC-05 VCC(5V) --- Arduino 5V
    • HC-05 TX --- Arduino Pin 10 (Soft RX)
    • HC-05 RX --- Arduino Pin 11 (Soft TX)
    • HC-05 Key (Pin34) --- Arduino PIN 9


    >>
    Configure the Slave


    2.1 Make sure the power wire (5.0v) is disconnecteded from the HC-05
    2.2 Make sure the Key wire is connected to pin9
    2.3 In the Arduino IDE, goto the Tools\Serial Monitor menu
    2.4 The two following settings are correctly set (at the bottom right of the window):

    2.4.1 Line ending should be set to "Both NL & CR"
    맨 끝라인은 반드시 Both NL & CR 로 마무리지어야한다.

    2.4.2 Baud speed should be set to "9600 baud"

    Note: If you had to modify those settings, I suggest to close and re-open the Serial Monitor dialog


    2.5 When the Arduino is reseted (opening the Serial Monitor dialog will force a reset) you should see the following text "Enter AT commands:" in the Serial Monitor dialog.
    아두이노가 리셋됬을때, 메세지를 볼수있다. "Enter AT commands:"를


    2.7 Connect the power wire(5.0v) on HC-05. You should see the red light slowly blinking (once every ~2 seconds)

    2.8 In the Serial Monitor, type AT and press Enter (or click the Send button).
    The module should return OK right away
    시리얼모니터에서 AT를 타이핑해서 OK가 뜨는지 확인한다.

    2.9 In the Serial Monitor, type AT+ROLE=0 and press Enter.
    This will set the module in Slave mode.
    You can verify that it worked by typing AT+ROLE? (It should return +ROLE:0)
    AT+ROLE=0은 슬레이브모드이다.


    2.10 In the Serial Monitor, type AT+BIND= and press Enter.
    This will remove any existing binding.
    You can verify that it worked by typing AT+BIND? (It should return +BIND:0:0:0)
    바인딩을 제거하고자 할때는 AT+BIND= 를 타이핑하고 Enter를 누른다.

    2.11 In the Serial Monitor, type AT+ADDR? and press Enter.
    This will return the MAC address of this HC-05 module.
    For example: my module's address is 00:13:03:19:14:07
    and the command is returning + ADDR:13:3:191407.
    As you can see the zeros are stripped out and the formatting is a bit different but,
    as you will soon see, this will not be a problem.
    Write down on a piece of paper this MAC address.
    보다시피 the 0들은 잘려나간다. and 포멧팅이 약간 다르다. but 이건 문제가되지않는다.


    2.12 Disconnect the power wire from the HC-05 and remove this HC-05 from the breadboard.
    It is now ready to act as the Slave module.
    Note: Don't disturb the wiring since you will use it to configure the second module.
    와이어를 제거하진 말아라 since 곧 두번째 모듈을 configure할꺼기 때문이다.


    >>
    Configure the Master

    *Start by installing the second HC-05 on the breadboard.
    Exactly where the first module was plugged.
    방금 Slave module연결한 곳에 Master module을 연결한다.

    3.1 Make sure the power wire(5.0)v is disconnected from the HC-05
    3.2 Make sure the Key wire is connected to pin 9
    3.3 In the Arduino IDE, goto the Tools\Serial Monitor menu
    3.4 The two following settings are correctly set (at the buttom right of the window):
    3.4.1 Line ending should be set to "Both NL & CR"
    맨 끝라인은 반드시 Both NL & CR 로 마무리지어야한다.
    3.4.2 Baud speed should be set to "9600 baud"
    Note: If you had to modify those settings,
    I suggest to close and re-open the Serial Monitor dialog

    3.5 When the Arduino is reseted
    (opening the Serial Monitor dialog will force a reset)
    you should see the following text "Enter AT commands." in the Serial Monitor dialog.

    3.7 Connect the power wire(5.0v) on the HC-05.
    You should see the red light slowly blinking (once every ~2 seconds)

    3.8 In the Serial Monitor, type AT and press Enter (or click the Send button).
    The module should return OK right away.

    3.9 In the Serial Monitor, type AT+ROLE=1 and press Enter.
    This will set the module in Master mode.
    You can verify that it worked by typing AT+ROLE? (It should return +ROLE:1)

    3.10 In the Serial Monitor,
    type AT+BIND=13,3,191407 and press Enter (of course here you should be using your MAC address that you have noted on step 2.12).
    This will force the Master module to automatically link (bind) to the Slave.
    You can verify that it worked by typing AT+BIND?
    (It should return +BIND:13:3:191407)
    3.11 Disconnect the power wire from the HC-05 and remove this HC-05 from the breadboard.
    It is now ready to act as the Master module.



    ▼▼▼▼▼
    #include

    SoftwareSerial BTSerial(10, 11); // RX | TX

    void setup()
    {
      pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
      digitalWrite(9, HIGH);
      Serial.begin(9600);
      Serial.println("Enter AT commands:");
      BTSerial.begin(38400);  // HC-05 default speed in AT command more
    }

    void loop()
    {

      // Keep reading from HC-05 and send to Arduino Serial Monitor
      if (BTSerial.available())
        Serial.write(BTSerial.read());

      // Keep reading from Arduino Serial Monitor and send to HC-05
      if (Serial.available())
        BTSerial.write(Serial.read());
    }













    @#$%

    댓글 없음:

    댓글 쓰기