This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Configuring Bluetooth Communication

Discovering Your Device

Instrument Control Toolbox™ can communicate with Bluetooth® devices via an adaptor. In this example, a USB Bluetooth adaptor is plugged into the computer. It can identify Bluetooth devices within range when queried. In order to communicate with instruments, you need to perform a pairing in the adaptor software. Note that some devices, such as many laptop computers, do not need to use an adaptor since they have one built in.

The following shows the software interface of an adaptor where two of the devices in range have been paired – a smart phone with Bluetooth enabled, and a Lego Mindstorm NXT robot. As you can see, the “friendly name” or display name of the smart phone is simply iPhone and the name of the NXT robot is C3PO. In the Instrument Control Toolbox this friendly name is the Bluetooth RemoteName property.

To see the devices in the Instrument Control Toolbox, use the instrhwinfo function on the Bluetooth interface, called Bluetooth.

instrhwinfo returned a cell array of five Bluetooth devices that are in the range of the adaptor on the computer running Instrument Control Toolbox. Then indexing into the RemoteNames property shows the five devices. You can see that iPhone and C3PO are shown in the list.

Notice that one of the other devices shows an empty character vector for RemoteName. That means that device does not have a friendly name associated with it. To communicate with that device, you need to use the RemoteID property.

The RemoteIDs are shown in the same order as the RemoteNames, so the fourth ID in the list, '0021BA74F3DD', could be used for the device that shows no RemoteName. You can use either RemoteName or RemoteID to communicate with a device.

Examples of communicating with a device are in Transmitting Data Over the Bluetooth Interface.

Viewing Bluetooth Device Properties

This example looks at the NXT robot discovered in the previous section. Using the instrhwinfo function on the specific device using RemoteName shows this:

If you use the instrhwinfo function on the specific device using the RemoteID, it shows the following:

In the case using the RemoteID, you can see that the ObjectConstructorName is actually the device’s Uniform Resource Identifier (URI).

Whether you use the RemoteName or the RemoteID to see the device’s properties, you can see that the device has only one channel. Create a Bluetooth object bt using the RemoteName and Channel. Then display the state of that object using the disp function.

The status is closed because you have not yet opened the connection to the object.

Use the get function to see the device properties.

The BLUETOOTH specific properties section shows properties that are specific to the Bluetooth interface. You can see it is using channel 1. The profile is SPP, which is the Serial Port Profile – that is the Bluetooth profile that Instrument Control Toolbox supports.

The RemoteName and RemoteID properties are the names that are used to communicate with the device, as shown previously.

The ReadAsyncMode and Terminator properties are the same as the Serial Port properties of the same name. For details, see the properties documentation.


To get a list of options you can use on a function, press the Tab key after entering a function on the MATLAB® command line. The list expands, and you can scroll to choose a property or value. For information about using this advanced tab completion feature, see Using Tab Completion for Functions.

Was this topic helpful?