Preliminary study on HC-05

Source: Internet
Author: User

Catalogue

1 . Bluetooth Sniffer Grab bag 2 . HC05 Bluetooth module at mode setting 3. USB to serial port chip CH340

1. Bluetooth Sniffer Clutch

Sniffer packet for Bluetooth communication packet can not be directly used Wincap+wireshark grab packet, because we know that Wincap is for the wired network or WLAN, is essentially a mirror from the network card to go out and into the packet, but the Bluetooth protocol is not through the network card to send and receive packets, Instead, the data is sent and received via another peripheral (Bluetooth transceiver), so we need to install a specific driver for this Bluetooth peripheral to mirror the corresponding packet

Relevant Link:

2. Use of the HC05 Bluetooth module

Bluetooth HC05 is the master-slave Bluetooth serial module, simply said, when the Bluetooth device and Bluetooth device pairing connection is successful, we can ignore the Bluetooth internal communication protocol, directly to Bluetooth as a serial port. When the connection is established, the two devices together use one channel, namely the same serial port, one device sends the data to the channel, and the other device can receive the data in the channel. Of course, for the establishment of this channel connection is a certain condition, that is, the Bluetooth set up to be able to connect the at mode

0x0:softwareserial Library

The existing Arduino hardware supports pin 0 and 1 (connected to the computer via USB) for serial communication. The serial is carried out via a hardware called UART (chip built-in). This hardware allows the Atmega chip to receive serial communication, even if the chip is doing other work, as long as there is 64 bytes of serial buffer storage space can be
Using the software's copy function (hence called "softwareserial"), the existing Softwareserial library to allow serial communication of other Arduino digital pins, which may have multiple software serial speeds up to 115200bps. A parameter that reverses the signal that requires the Protocol's device
The library has the following known limitations

On the 2560 , not all pins support interrupts, and the pins that are allowed for Rx include:ten   all in all.  the

0x1: General Bluetooth serial module PIN

1 . RXD: Receive Side 2. TXD: Send side 3. At: Set operating     mode 1) operating mode: Automatic connection (automatic connection), also known as the transmission mode () is also referred to as the penetration mode (transparent communication)     2) at instruction Setup mode: Command response (order-4. VCC: module power supply Positive (5V)5. GND: module power supply negative

0x2: There are three types of Bluetooth modules used in general

1 . Bluetooth pairing    from device to PC 1 computer    with bluetooth 2) computer without Bluetooth, requires Bluetooth adapter 2. Bluetooth pairing from device to phone 3. Bluetooth pairing connection from device to Bluetooth master device

0X3:HC05 Bluetooth module at Mode setting method

Usually used in the "Automatic connection" mode is only the RXD pin incoming data, turn into Bluetooth wireless signal transmission out, or will receive the wireless signal, from Txd called to Arduino, the module itself will not interpret the data, also uncontrolled
The instructions for manipulating the Bluetooth module are collectively the AT command, where the AT command is not transmitted via Bluetooth, but is communicated via the module's TXD and rxd pins and the Arduino Rx and TX connections, and the Bluetooth module receives the AT command only at the at mode.

1 . Default Settings 2 . Set with USB to UART module 3. Set up the main controller serial program with Bluetooth settings

1. Main default settings

1 . Module work role: Slave mode 2. Serial Port parameter:38400bits/s stop bit 1 bit no check bit 312344. Device Name: BC5. Connection mode: Any Bluetooth device connection mode

In this mode, the Bluetooth module does not need any USB, serial wiring, directly through the Bluetooth channel and other Bluetooth device pairing communication

2. Set up Bluetooth (USB to TTL sequence) with USB to UART module

Bluetooth module on the USB interface, directly and the host computer serial and conversion communication, in fact, Arduino is acting as a middleman role, Arduino in the middle of the PC usb-serial port-and port-serial-hc-05, itself is superfluous, The only advantage is that the control logic can be added to the Arduino programming, and the detailed content we put in the third section in-depth study

After conversion via the USB to TTL conversion chip, we send the AT command directly to the HC-05 at a 38400 baud rate

3. Use Arduino to configure Bluetooth at command (Bluetooth module and Arduino connection, Arduino acts as host computer)

There are two types of hc-05 modules in the market: the en foot, the other is the key foot, and the difference between them is the method of entering at mode.
En foot:

Key foot:

Let the HC-05 module enter at mode, need to put the key pin (34 feet of the Bluetooth module itself) to high potential (usually 3.3v, but 5v is OK) before powering on, if, as long as a Bluetooth module is plugged into the at mode

The LEDs on the HC-05 board will blink 1 times per second before pairing with other Bluetooth devices. If you enter at mode, the LEDs will blink once every two seconds, and the HC-05 at command is transmitted at a rate of 38400bps.
The author buys the HC-05 board above has a key, according to the manufacturer to provide the circuit, this key is connected in the Bluetooth module 34 feet, therefore first presses the key switch on the board, then the power, can let this Bluetooth module enter at mode (after the power-up can release the switch). If you press the key do not put, power up, you can use the SOFTWARE "Get module information", read out all the information

We experimented with hc-05 EN foot hc-05, to the Arduino download program, the code logic of the program to set the Bluetooth module as the slave mode, and set the discovery service name, before the experiment, first clear a few concepts

1 . We need to use two sets of    serial port transmission 1 ) Serial (9600bps): USB analog serial port transmission for PC and Arduino, for transmitting at command of input and echo    of Bluetooth module 2) softwareserial (hc-05  : 38400bps): Serial transmission of Arduino and Bluetooth module, Arduino as middleman converts the at instruction sent by PC to serial sequence sent to Bluetooth module 2. HC-05 Bluetooth module requirements of the Bluetooth module baud rate is 38400, so softwareserial analog serial communication must be 38400, and the PC and Arduino serial communication baud rate as long as the two sides agree, and there is no hard rules

#include <SoftwareSerial.h>/** RX is the digital pin 8 (TX connected to the Bluetooth module) * TX is the digital PIN 9 (RX connected to the Bluetooth module)*/softwareserial btserial (8,9);//RX | TX#defineAt 2#defineLED 7voidSetup () {//set at to high to enable the Bluetooth module to enter at ModePinmode (At,output); Pinmode (Led,output);
  //This step is equivalent to holding down the key button on the Bluetooth module floor, but the USB cannot produce the corresponding frequency of the set level, so it is recommended to use the hand to hold the key key when the experiment is not put and then power up, so that the power of the instant key pin is high level Digitalwrite (At,high); Digitalwrite (Led,high); //set and PC serial communication baud rate, on both sides of the agreement canSerial.begin (9600); while(!Serial) { ; //wait for the serial connection. Needed for Leonardo only} serial.println ("Enter at commands:"); //HC-05 default speed on command moreBtserial.begin (38400); while(!btserial) { ; //wait for the serial connection. Needed for Leonardo only} delay ( +); Digitalwrite (Led,low);}voidLoop () {
  Keep reading from the Arduino Serial Monitor and send to HC-05
If (Serial.available ()) {
Digitalwrite (Led,high);
Btserial.write (Serial.read ());
} //Keep reading from HC-05 and send to Arduino Serial Monitor if(Btserial.available ()) {digitalwrite (Led,high); Serial.write (Btserial.read ()); } Digitalwrite (Led,low); /*serial.println ("at"); Delay (100); Serial.println ("At+name=openjumper-bluetooth");//Name Module name delay (100); Serial.println ("at+role=0");//Set master/Slave mode: 0 slave, 1 host delay (100); Serial.println ("at+pswd=1234");//Set a pairing password, such as 1234 delay (100); Serial.println ("at+uart=9600,0,0");//Set baud rate 9600, stop bit 1, check bit no delay (100); Serial.println ("At+rmaad");//Clear the pairing list*/}

The above is the Code section, the experiment should be noted that the HC-05 need to pass the key on the floor to enable the key to switch on the circuit, and at the same time high potential to enter at mode, the operation process is as follows

1. After the Arduino and PC are connected, useTX, RX docking with hc-05 Rx, TX, and Arduino to connect the GND to 2. Before 5v power is switched on, First press the key button of the Bluetooth module and switch on circuit 3. Then switch on the 5v power supply, this time, the key can be set to high potential, then the Bluetooth module into the at mode

The circuit is connected as follows

state:led lamp (idle) Rxd:recibir datos: Receiving end (Arduino TX pin9) Txd:transmitir Dato: Send side (Arduino RX  pin8) Gnd:gndvcc:5ven : Enable/

Lamp status

Flashing: Normal mode flashes every 2 seconds: at mode does not blink: connected

Press the Arduino reset button to let the program run once, when it is found that the on-board L lamp 500ms flashes, it indicates that it has been set successfully

Once setup is complete, press the Arduino reset key to restart the Bluetooth module to be recognized by other devices for the renamed Bluetooth

Specifications of 0X4:HC05

To purchase HC-05, try to select a module that leads to the "command response mode" PIN to facilitate the execution at command
different Bluetooth module PIN and firmware may not be the same, when you buy, be sure to ask the manufacturer for data Sheet (specification, at command manual, circuit diagram of the backplane) 0x5:hc-05 circuit Diagram

Relevant Link:

http//www.tmirun.com/arduino-hc-05-%E6%A8%A1%E5%9D%97%E6%95%99%E7%A8%8B1%E8%BF%9B%E5%85%A5at%E6%A8%A1%E5%BC%8F/ http//www.tmirun.com/arduino-hc-05-%E6%A8%A1%E5%9D%97%E6%95%99%E7%A8%8B2%E8%BF%9E%E6%8E%A5/http//www.arduino.cn/thread-1183-1-1.htmlhttp//www.arduino.cn/thread-2961-1-1.htmlhttp//wiki.geek-workshop.com/doku.php?id=arduino:libraries:softwareserialhttp//swf.com.tw/?p=712Https//detail.tmall.com/item.htm?id=524860055508Https//Www.youtube.com/watch?v=fkS1elBSzgshttp//www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/http//www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/step2/ the-arduino-code-for-hc-05-command-mode/http//cdn.instructables.com/fm8/w4a2/hkzavrt9/fm8w4a2hkzavrt9.medium.jpghttp//www.instructables.com/id/Cheap-2-Way-Bluetooth-Connection-Between-Arduino-a/http//www.instructables.com/id/Andruino-A-Simple-2-Way-Bluetooth-based-Android-C/http//swf.com.tw/?p=693&cpage=1#comment-954236http//swf.com.tw/?p=705http//swf.com.tw/?p=335http//Wenku.baidu.com/link?url=eylmw27b2m6vqzfwgjrg_5cp4noc15gkluxb4sdgibeuuvflg_b19wvqmikdha03fttpy-hami_ VU2YWCJVRM_LGWPPFNVVWGYGIC5ZI7TKhttp//www.icourses.cn/jpk/changeforVideo.action?resId=401015&courseId=4265&firstShowFlag=32

3. USB to serial port chip CH340

0x1: Overview

H340 is a USB bus adapter chip for USB to serial port, USB to IrDA infrared or USB to print port. In the serial port mode, CH340 provides common modem contact signal, which is used to extend the asynchronous serial port for the computer, or to upgrade the common serial device directly to the USB bus.

0x2: Features

1. Full speed USB Device interface, compatible with USB V2.0, peripheral components require only crystals and capacitors2. Emulation standard serial port for upgrading the original serial peripheral device or adding additional serial port via USB3the serial port application under the computer-side Windows operating system is fully compatible without modification4hardware Full-duplex serial, built-in transceiver buffer, support communication baud rate 50bps~2mbps5Support Common modem contact signals RTS, DTR, DCD, RI, DSR, CTS6RS232, RS485, RS422 and other interfaces via an external level-shifting device7. Support IrDA specification Sir Infrared communication, support baud rate 2400bps to 115200bps8software compatible with CH341, you can use the CH341 driver directly9support 5V supply voltage and 3.3V supply voltageTen. Available in SSOP-20 and SOP-16 lead-free packages, RoHS compliant

0X3: Package

0x4: Pin

Relevant Link:

http://wenku.baidu.com/link?url=dkcwlxptpfybm5kpg7efktmadpfuhl2a79oz6me0mu_ Sh1gxqgm5qzl9jlhvj-6i7hymyrbpaxiz_wraxb_yalen2jdm_hqwyvxkltuay37

Copyright (c) Littlehann All rights reserved

Preliminary study on HC-05

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.