MATLAB serial communication via Bluetooth SPP

조회 수: 13 (최근 30일)
Christopher
Christopher 2011년 6월 22일
댓글: Rubin Alejandro 2020년 10월 7일
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
Chirag Gupta
Chirag Gupta 2011년 6월 22일
Could you try and access the serial port from hyperterminal?

댓글을 달려면 로그인하십시오.

답변 (3개)

Eric Wetjen
Eric Wetjen 2011년 9월 14일
Hi Christopher,
Bluetooth SPP support was added to Instrument Control Toolbox in R2011b. See the documentation here for details.
Eric
  댓글 수: 1
Christopher
Christopher 2011년 9월 14일
Excellent! Good things come to those who wait.

댓글을 달려면 로그인하십시오.


Gerd
Gerd 2011년 6월 22일
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
Gerd
  댓글 수: 2
Christopher
Christopher 2011년 6월 22일
Gerd,
no, they are already visible in device manager before starting Matlab.
Chris
Alexander Slovak
Alexander Slovak 2012년 2월 22일
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.

댓글을 달려면 로그인하십시오.


Roberto
Roberto 2016년 6월 8일
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 =
'MY_DEVICE'
'OTHER_DEVICE1'
'OTHER_DEVICE2'
'OTHER_DEVICE3'
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
Rubin Alejandro
Rubin Alejandro 2020년 10월 7일
osea que desde simulink, no es posible, ??? no existe un bloque, una libreria, lo que sea que permita leer/escribir al puerto mediante bluetooth?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Test and Measurement에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by