Main Content

Bluetooth Communication

Read from and write to Bluetooth® devices

Bluetooth is a wireless communication protocol for exchanging data over short distances using short wavelength radio transmissions. Common devices with Bluetooth capabilities include laptops, phones, and wireless sensors.

Use the Bluetooth interface in MATLAB® to transmit and receive ASCII and binary data. This interface uses the Bluetooth Serial Port Profile (SPP). You can identify any Bluetooth SPP device and establish a two-way connection with that device from MATLAB.

To communicate with a Bluetooth device, your computer needs to have a built-in or external Bluetooth adapter. For more information, see Configure Bluetooth Communication Settings.

To simulate, analyze, and test Bluetooth communications systems, see Bluetooth Toolbox.

Functions

expand all

bluetoothlistScan nearby Bluetooth Classic devices (Since R2020b)
bluetoothConnect to Bluetooth Classic device (Since R2020b)
configureTerminatorSet terminator for ASCII string communication with Bluetooth device (Since R2020b)
configureCallbackSet callback function and trigger condition for communication with Bluetooth device (Since R2020b)
readRead data from Bluetooth device (Since R2020b)
readlineRead line of ASCII string data from Bluetooth device (Since R2020b)
writeWrite data to Bluetooth device (Since R2020b)
writelineWrite line of ASCII data to Bluetooth device (Since R2020b)
flushClear Bluetooth device buffers (Since R2020b)

Topics

Troubleshooting

Troubleshooting Bluetooth Communication

Troubleshoot the Bluetooth interface.

Resolve Bluetooth Connection Errors

Troubleshoot connecting to a Bluetooth device.

Resolve Bluetooth Warning: Unable to Read Any Data

Troubleshoot when you receive no data and you get the warning message: Bluetooth unable to read any data.

Resolve Bluetooth Warning: Unable to Read All Data

Troubleshoot when you receive some data and you get the warning message: Bluetooth unable to read all requested data.

Featured Examples