Documentation

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.

Troubleshooting Bluetooth Interface

The Instrument Control Toolbox™ Bluetooth® interface lets you connect to devices over the Bluetooth interface and to transmit and receive ASCII and binary data. Instrument Control Toolbox supports the Bluetooth Serial Port Profile (SPP). You can identify any SPP Bluetooth device and establish a two-way connection with that device.

Bluetooth is an open wireless technology standard for exchanging data over short distances using short wavelength radio transmissions from fixed and mobile devices over a packet-based protocol. Bluetooth provides a secure way to connect and exchange information between devices such as Lego Mindstorm NXT robots, USB Bluetooth adaptors (dongles), wireless sensors, mobile phones, faxes, laptops, computers, printers, GPS receivers, etc.

Supported Platforms

The Bluetooth interface is supported on these platforms:

  • macOS

  • Microsoft® Windows® 64-bit

Adaptor Requirements

Instrument Control Toolbox supports the Bluetooth Serial Port Profile (SPP). You can identify any SPP Bluetooth device and establish a two-way connection with that 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 Instrument Control Toolbox this friendly name is the Bluetooth RemoteName property.

On Windows 7 64-bit platforms, you can use only one Bluetooth adaptor at a time. If you connect another adaptor, it will fail with a “Device Driver Installation Failed” error.

Some adaptors support multiple devices:

  • The Bluetooth adaptor that comes with the LEGO Mindstorm kit (Abe – Model: UB22S) supports connection to only one Bluetooth device at a time.

  • IO Gear – Models GBU421 and GBU311 support communication with multiple Bluetooth devices.

  • Targus – Model ACB10US supports communication with multiple Bluetooth devices.

  • Motorola – Model SYN1244B supports communication with multiple Bluetooth devices.

  • D-Link – Model DBT-120 supports communication with multiple Bluetooth devices.

If a Bluetooth adaptor is removed and a different one plugged in, all Bluetooth devices have to be paired again with your PC. If the same adaptor is removed and plugged back in, then you do not need to pair the devices again. If another adaptor of the same vendor is plugged in, then the devices which had been cached when that adaptor was used are seen in the cache.

Configuration and Connection

  1. Make sure that you have the correct instrument driver installed for your device. Refer to your device’s documentation and the vendor’s web site.

  2. Make sure your device is supported in Instrument Control Toolbox. See Is My Hardware Supported?.

  3. Make sure that the Bluetooth service on the device is turned on.

  4. Instrument Control Toolbox can communicate with Bluetooth devices via an adaptor, either a USB Bluetooth adaptor that is plugged into the computer, or a built in adaptor in the device. See Adaptor Requirements.

    Make sure you have performed the pairing between the device and the computer running MATLAB® by using either a USB adaptor or a built-in adaptor.

  5. You can verify that MATLAB can see your device by using the instrhwinfo function with the Bluetooth interface name.

    In this example, 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 appear in the list.

    If a device shows an empty character vector for RemoteName, then 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 display in the same order as the RemoteNames, so in this case, 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.

    You can verify that MATLAB can see your device by using the instrhwinfo function with the RemoteName property. In this example, C3PO is the remote name of the NXT robot and is shown in the output.

    instrhwinfo('Bluetooth','C3PO')

    The Instrument Control Toolbox displays the device information.

  6. Make sure you can create the Bluetooth object. You must provide two arguments to create the object, either the RemoteName or the RemoteID, and a channel number. You can get the channel number from your device’s documentation or from looking at the Bluetooth node in the Test & Measurement Tool. For example, create a Bluetooth object called bt using channel 1 of the NXT device.

    bt = Bluetooth('C3PO', 1);

    If you do not get an error, the object was created successfully.

  7. Make sure you can connect to the device, using the fopen function with the object name.

    fopen(bt)

    If you do not get an error, the connection was made successfully. If you do get an error, follow the steps in the error message and/or check the previous steps listed here.

  8. When you have connected, you can communicate with your device. See in Transmitting Data Over the Bluetooth Interface for an example of communicating with a device. See Other Troubleshooting Tips for Bluetooth for tips about communication issues after initial connection.

Other Troubleshooting Tips for Bluetooth

These tips may be relevant to your use of this feature.

Remove or change adaptors

If a Bluetooth adaptor is removed and a different one plugged in, all Bluetooth devices have to be paired again with your PC. If the same adaptor is removed and plugged back in, then you do not need to pair the devices again. If another adaptor of the same vendor is plugged in, then the devices which had been cached when that adaptor was used are seen in the cache.

Use of instrhwinfo

If a Bluetooth device is already cached, but it is OFF when MATLAB is started, and if instrhwinfo is called on this device, then ObjectConstructorName and Channel are returned as a null character vector.

If a Bluetooth device is already cached and is ON when MATLAB is started, and it is later switched OFF, if instrhwinfo is called on this device, then ObjectConstructorName and Channel return the correct values.

Device out of range

If you create a Bluetooth object for any Bluetooth device and the connection is open, and then the device goes out of range, the status of the object would still be open. When the device comes into range again, you need to fclose the object and fopen it again for communication to continue.

Change batteries on device

If you create a Bluetooth object, for a Lego Mindstorm NXT robot for example, and the connection is open, and then the batteries of robot run out, then the status of the object would still be open. If you then replace the batteries, you need to fclose the object and fopen it again for communication to continue.

Restart device after scan in Test & Measurement Tool

When using the Bluetooth support in the Test & Measurement Tool, please note that you may need to restart your device after you have done the scan. For any Lego Mindstorm robot to be identified correctly, it has to be restarted after scanning. You may also have to restart other Bluetooth devices after the scan as well.

Troubleshoot Bluetooth Interface in Test & Measurement Tool

To use the Bluetooth support in the Test & Measurement Tool, select the Bluetooth node in the instrument tree and right-click Scan for bluetooth devices.

Note

When using the Bluetooth support in the Test & Measurement Tool, please note that you may need to restart your device after you have done the scan. For any Lego Mindstorm robot to be identified correctly, it has to be restarted after scanning. You may also have to restart other Bluetooth devices after the scan as well.

If you are having trouble using the Bluetooth interface in the Test & Measurement Tool, try these steps.

  • Check that the Bluetooth device supports the Serial Port Profile (SPP). We do not support other Bluetooth profiles such as File Transfer Profile (FTP).

  • Make sure that the Bluetooth service on the device is turned on.

  • Make sure that the Bluetooth device is paired with your computer.

  • If you are using a Lego Mindstorm NXT brick, note that the NXT brick has to be restarted after scanning for Bluetooth devices from the Test & Measurement Tool.

  • If you still cannot connect to the Bluetooth device, try unplugging and replugging the Bluetooth adaptor.

Was this topic helpful?