MATLAB serial communication via Bluetooth SPP
조회 수: 7 (최근 30일)
이전 댓글 표시
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
답변 (3개)
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
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
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
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
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?
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!