Troubleshooting Bluetooth Low Energy

If you are having issues connecting to your Bluetooth® Low Energy peripheral device from MATLAB® or are unable to read or write data, you can try some of the following troubleshooting tips.

For more information about the Bluetooth Low Energy interface, see:

Supported Platforms

The Bluetooth Low Energy interface is supported on these platforms:

  • macOS 10.13 High Sierra or later

  • Windows® 10, version 1709 or later

Before trying other troubleshooting steps, make sure your computer is running one of these platforms.

Device Discovery and Connection

If MATLAB does not detect your built-in or external Bluetooth adapter when you call blelist, try the following:

  • Make sure the adapter supports Bluetooth 4.0 and higher.

  • Restart Bluetooth services on your computer.

  • Update to the latest device drivers for your adapter.

  • Reboot your computer.

If your device does not appear in the blelist output, make sure that you have done the following:

  • Power on your peripheral device.

  • Bring your peripheral device within range of your computer.

  • Disconnect your peripheral device from any other devices or applications first. The output from blelist shows you only nearby devices that are currently advertising data. If your device is already connected in another application or in MATLAB, it might not appear in the output.

  • Try a larger value for the Timeout parameter in blelist. This increases the amount of time MATLAB scans for nearby devices. For example, blelist("Timeout",20) searches for nearby peripheral devices for 20 seconds. The default timeout value is three seconds. If your device transmits advertisement data less often than once every three seconds, MATLAB might not capture it.

If your peripheral device powers off or disconnects, the UUID might change when it powers on again or reconnects. However, the name remains the same in the blelist output. If you are trying to create a new ble object for the same device, specify the new UUID instead of the name.

On Windows, if a peripheral device has already been paired but the firmware that defines characteristics and descriptors is changed, ble might fail to connect the device to your computer. To fix this, disconnect and then reconnect your device to Windows.

If you are unable to create a characteristic object for your Bluetooth Low Energy device on Windows 10, try pairing your device on Windows before using ble to connect to it in MATLAB. You can pair to a device in Windows Settings > Devices > Add Bluetooth or other device.

Read and Write Data

Using read(c,'latest') or read(c) inside a callback function for a characteristic with a high rate can throw an error or block MATLAB for a long time. Instead, use read(c,'oldest') in a callback function. For an example, see Read Characteristic Data from a Bluetooth Low Energy Peripheral Device Using a Callback Function.

On macOS, some device characteristics require authentication to read or write for the first time. After you create a ble object, run read or write. Follow the prompts that appear on your computer to pair your peripheral device.

See Also

| | |

Related Topics