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 Center および File ExchangeTest and Measurement についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by