Clear Filters
Clear Filters

MATLAB serial communication via Bluetooth SPP

5 views (last 30 days)
I have some sensors with Bluetooth SPP connections. I cannot seem to get MATLAB Serial IO to work with them. The 'Standard Serial over Bluetooth link' COM port entries are available in Device Manager, the port settings (in Device Manager and the MATLAB serial function call) are correct. On using fopen() the error seen is that the requested com port is not available. This is confirmed using instrhwinfo('serial') as the requested COM port is not in the list.
I know the Bluetooth SPP is working because the only way I could get the devices working with MATLAB was to use a third party com2tcp forwarder, then use MATLAB's tcpip function to access the port. However, this is not ideal since the com2tcp forwarder is not that reliable. I'd rather be using MATLAB's serial io.
Could this be an issue with the java version being used? version('-java') gives 'Java 1.6.0_24-b07 with Sun Microsystems Inc. Java HotSpot™ 64-Bit Server VM mixed mode'.
My set up is Windows 7 Enterprise 64-bit, MATLAB 7.11.0 (R2010b) 64-bit.
  1 Comment
Chirag Gupta
Chirag Gupta on 22 Jun 2011
Could you try and access the serial port from hyperterminal?

Sign in to comment.

Answers (3)

Eric Wetjen
Eric Wetjen on 14 Sep 2011
Hi Christopher,
Bluetooth SPP support was added to Instrument Control Toolbox in R2011b. See the documentation here for details.

Gerd on 22 Jun 2011
HI Christopher,
did you connect the sensors after Matlab is running. It is always a problem for Matlab to show the correct Serial Ports if they were connected after starting Matlab
Christopher on 22 Jun 2011
no, they are already visible in device manager before starting Matlab.
Alexander Slovak
Alexander Slovak on 22 Feb 2012
Did you solve this problem? I have the same.
Using bluetooth object isn`t suitable for me because I use Simulink model. But there is no block with bluetooth support.

Sign in to comment.

Roberto on 8 Jun 2016
I have some problems running Bluetooth with matlab
I´m trying to use the SSP port as a COM port, so when I try to connect, then the bluetooth port freezes and I need to turn off and on the bluetooth module...
So after trying a lot to use COM port itself(because sometimes the connection works) so i change my aproach and use the Bluetooth interface
follow this and be happy
1) Finding the Bluetooth
>> mydevices = instrhwinfo('Bluetooth')
mydevices =
HardwareInfo with properties:
RemoteNames: {4x1 cell}
RemoteIDs: {4x1 cell}
BluecoveVersion: 'BlueCove-2.1.1-SNAPSHOT'
JarFileVersion: 'Version 3.7'
2) If you have more than one Bluetooth paired, they will show something weird in de RemoteName with the number of devices ... you can list all doing:
>> mydevices.RemoteName
myDevices =
3) So you can discover the Channels to connect
>> instrhwinfo('Bluetooth', 'MY_DEVICE')
myDevices =
HardwareInfo with properties:
RemoteName: 'MY_DEVICE'
RemoteID: 'btspp://201603085239'
ObjectConstructorName: {'Bluetooth('MY_DEVICE', 1);'}
Channels: {'1'}
4) Now start a link... but the status still "closed"
>> b = Bluetooth('BASE_IA',1)
Bluetooth Object : Bluetooth-MY_DEVICE:1
Communication Settings
RemoteName: MY_DEVICE
RemoteID: btspp://201603085239
Channel: 1
Terminator: 'LF'
Communication State
Status: closed
RecordStatus: off
Read/Write State
TransferStatus: idle
BytesAvailable: 0
ValuesReceived: 0
ValuesSent: 0
5) Now open the connection
>> fopen(b)
6) Send data
>> fwrite(b, 'Text to send')
7) Close
>> fclose(b)
  1 Comment
Rubin Alejandro
Rubin Alejandro on 7 Oct 2020
osea que desde simulink, no es posible, ??? no existe un bloque, una libreria, lo que sea que permita leer/escribir al puerto mediante bluetooth?

Sign in to comment.


Find more on Test and Measurement in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!