You can use this module to communicate between two microcontrollers like Arduino or communicate with any device with Bluetooth functionality like a Phone or Laptop. There are many android applications that are already available which makes this process a lot easier. We can also configure the default values of the module by using the command mode. So if you looking for a Wireless module that could transfer data from your computer or mobile phone to microcontroller or vice versa then this module might be the right choice for you. However do not expect this module to transfer multimedia like photos or songs; you might have to look into the CSR module for that. How to Use the HC Bluetooth module The HC has two operating modes, one is the Data mode in which it can send and receive data from other Bluetooth devices and the other is the AT Command mode where the default device settings can be changed.
|Published (Last):||11 June 2007|
|PDF File Size:||19.43 Mb|
|ePub File Size:||10.91 Mb|
|Price:||Free* [*Free Regsitration Required]|
If you plan on using the BC with the Arduino library we provide, you may still find it useful to read through this page. Operational Modes The BC has two operational modes: command mode and data mode. In data mode, any data arriving over the serial port will be directly piped out over the Bluetooth link, assuming that the module is connected to another device using the Serial Port Protocol.
Note that the parser expects only a carriage return; if the device sending commands appends both carriage return and newline e. If the newline character precedes the carriage return, the parser may not accept the command at all. If the carriage return comes first, the parser will interpret the newline as a start of another command string, which can cause unexpected error messages from the module.
Throughout the rest of this guide, I will be considering the carriage return at the end of the command to be implicit. Also, while commands are theoretically case-insensitive, commands will always be presented as all-caps and I suggest that you always send all-caps strings for commands, as it sometimes makes a difference.
Inserting spaces in command strings in unexpected locations will cause errors. More on this later, as we start to talk about specific commands. The module will respond with "OK" more on responses later , whether it is connected as an SPP device or not.
From that point on, data will be tranparently passed out via the SPP connection, if one is available. If not, it will simply be ignored--it is not buffered for later delivery when a connection is available. The length of that gap can be set by the user, but is, by default, ms at either end.
Without that gap in place, the string will be treated as data. That is a constraint of the firmware on the BC and may change in the future. Commands, Responses, and Configuration Parameters To interface with the BC in command mode, you need to be aware of three things: the specific commands it will accept, the responses of the module to those commands, and the various configuration parameters that the user has control over. Reminder--terminate your command strings with a carriage return only!
Extra newlines will cause an error. You can see in the screenshot above the expected response. Note that this does not restore the factory defaults. Returns OK when complete. This restoration is only temporary, and upon a RESET the module will revert to the currently stored settings. WRITE - Stores the current settings in non-volatile memory, to be used for configuration on next reset or power up.
Responses Any command will cause a response to be issued by the module. All characters in all response strings will be all caps, unless the repsonse string represents received data in some way.
The receipt of either of these indicates that the characters entered since the last carriage return have been parsed and the input buffer is empty.
For commands that take some time to execute for example, scanning for local advertising BLE devices , many other commands cannot be submitted and will cause an "ERROR" response if submitted before the "OK" response signaling the end of the extended command is received.
Below are some of the responses the module can send in response to actions taken by the remote unit; these are naturally in addition to the responses to locally issued commands that we covered above. Note that SPP is just an example; that parameter can be of any type of connection, and in the event of the remote device closing all connections, you will receive one message for each profile that was connected.
This can also mean that the remote device has moved out of range or been switched off. Not all devices will return all of these messages upon execution of a command. Configuration Parameters In addtion to the commands listed above, there are numerous configuration parameters which can be set or read back using the SET and GET commands. When entering multiple parameters, separate subsequent parameters to the first with a space.
Ther should be no whitespace between the parameter name, the equals sign, and the first value; whitespace in that region will cause an error. It is possible to read back the current state of all configuration parameters by entering the CONFIG command; many of these values will not be cover here. BC Profiles The BC supports several different "profiles", which are connection types specified in the Bluetooth standard.
These profiles determine the capabilities of the device and how the device responds to input. General Connection Information Connections between devices are managed differently when the connecting device is Bluetooth Classic or Bluetooth 4. Note that it is possible to disconnect a single profile connection but remain connected to a device with other profiles. Also note that, so long as the parameter passed is valid, this command will return OK, whether there is a connection with that link ID or not.
As you can see above, there are two responses from this command: OK, which indicates that the command was received locally successfully i. Requires an integer parameter between 1 and 48; that value determines the length of time the inquiry will last; the timeout will be equal to 1.
The response is as seen above. This six-digit value, the Class of Device value, is generally beyond the scope of this document. Anything above db is probably strong enough to make a good connection. Once the OK response string has been received, the inquiry process is complete.
LIST prints a list of all devices currently paired with this module, whether they are connected or not. The BC can store up to 8 devices in this list. Devices in this list persist through resets or power cycles even without a WRITE having been executed OPEN establishes a connection to a device at a given address of a given type.
Note that all of the letters in the address and connection type must be in all caps! The responses for this can vary. If there is an error in the command syntax i. Each link is given a reference ID, status, profile type, and address of connected device. These are parameters which are useful for Classic connections.
When value is 0, the BC will not attempt to connected to any previously paired devices at startup. This becomes important when connecting BC devices together for audio purposes; it determines which device sends audio and which receives.
The command of the same name controls the immediate discoverability of the module; this sets the default state on startup. The value of timeout determines how long it will remain in discoverable mode before going to power save mode, in milliseconds; set that value to 0 for infinite wait. Any attempt to change this will generate and error. Defaults to 2 times. Default is db. Bluetooth 4. The response is very similar to that for INQUIRY; the first field of the response is the address, the second field is the "short name" of the device, the third gives information about the device 0A indicates a general purpose dual-mode device; 02 would be a single mode device , and the fourth is the received signal strength.
There is only one parameter associated with Bluetooth 4. BLE can be disabled by setting this parameter to 0. In this mode, the device emulates a physical serial port, passing data and, potentially, handshaking signals across the ether as though it were a physical, wired connection.
SEND SPP string will cause string or whatever other data preceds the carriage return at the end of the command to be sent over the serial connection.
This allows data to be sent without entering data mode. Valid values are , , , , , , and ; modules default to when set to factory defaults. You can, however, have only an A2DP connection open. A2DP is a two-channel audio streaming protocol, which transfers data from a source to a sink. The source can be a cell phone, a media player, or the audio input on another BC or similar module. AVRCP allows the BC to send commands to the remote device which will cause the remote device to play, pause, stop, advance or reverse playback; some remote devices will transmit track meta data back to the BC via the AVRCP protocol.
If the device is a sink, the local volume will change, but no remote volume change will occur. If the device is a source, the volume at the remote device will change. This is important when attempting to make a connection between two BC modules, as it determines which module is expecting to send audio data and commands and which is expecting to receive.
Supports values between 0 and 15; the default value is reported as 16, although it is in fact HFP allows you to make and receive phone calls using a BC module. END hangs up an active call. This may cause the phone to drop the Bluetooth connection; that varies with phone model. Up Next: Usage Examples! This is what the serial output on the BC looks like during the pairing process. At this point, I can send commands back from the BC to the phone to start, stop, and pause tracks, or to advance or go back in the track list.
Furthermore, the BC will receive messages when playback is started or stopped at the phone end. This echo response may take some time to arrive at the BC module, but the command executes on the phone very rapidly.
BC417 Bluetooth to Serial [Arduino]
HC-31 Bluetooth 2.0 Module -BC417
Understanding the BC127 Bluetooth Module