MATLAB Answers

How to connect matlab with Bluetooth HC 05

226 views (last 30 days)
wildan on 16 Mar 2012
Commented: puneet yadav on 24 Apr 2018
Hi, iam wildan. im a mechatronics student. wanti to know about how to connect Matlab (simulink) with bluetooth device in microcontroller. So, i can control microcontroller use matlab wireless. the bluetooth model is HC 05. thanks for your answer.


Alexander Slovak
Alexander Slovak on 6 Apr 2012
I'm trying to do this for two months!!!
But get only errors:
Error evaluating registered method 'Start' of MATLAB S-Function 'sserialcb' in 'bttest/Serial Configuration'.
Open failed: Port: COM4 is not available. Available ports: COM4.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.
Model with one block 'Serial Configuration' connect correctly, but when I add serial send or serial recieve block - I get an error again.
Adel Djellal
Adel Djellal on 20 Apr 2017
I think you used inadequate 0 you must configure as follows:
>> B = Bluetooth('HC-05', 1);
>> fopen(B);

Sign in to comment.

Answers (3)

Lu on 15 Nov 2012
Hi guys,
Here's the solution:
HC-05 is actually a bluetooth SPP device, so we cannot use traditional serial function in matlab, because its only support "real" COM port.
However, matlab give us a similar lib named "bluetooth" :
You can apply ccde as below to access the HC-05:
1. first make sure you havn't change the device name of you HC-05, default is "HC-05", you can check it at your bluetooth Properities menu at Control Panel.
2. Code
%creat a bluetooth object
%HC-05 channel default is 1
b = Bluetooth('HC-05',1);
%write and read function
%close and clear
3. try and enjoy


Show 2 older comments
spike on 10 Oct 2017
hi lu,My bluetooth device is connected correctly, but matble can't find it. >>instrhwinfo('Bluetooth') ans =
HardwareInfo (具有属性):
RemoteNames: []
RemoteIDs: []
BluecoveVersion: 'BlueCove-2.1.1-SNAPSHOT'
JarFileVersion: 'Version 3.9'
Access to your hardware may be provided by a support package. Go to the Support Package Installer to learn more.
I was puzzled for a long time, thanks for your answer.
George Hoo
George Hoo on 16 Mar 2018
I meet the same question,have this problem been solved?

Sign in to comment.

Hung BV
Hung BV on 28 Oct 2013
Hi guys,I'm trying to do this use lib "bluetooth" but it not work I used command instrhwinfo('bluetooth') to check the bluetooth device in my laptop, and it return the resuls the name is 'HC-05' so i sure that the device name of my Blutooth device is 'HC-05'. Then i use the command: b = Bluetooth('HC-05',1); fopen(b);
There is an error, it say that the device already in use, but i sure that no device is connected to my HC05
Anyone can help me!
Thanks for your answer!


Jose andres Ardilla
Jose andres Ardilla on 21 Oct 2016
cierre el programa de arduino y mire que este bien escrito el nombre del bluetooh como aparece en (instrhwinfo('Bluetooth','HC-05'))
espero te sirva
Borja Roca Romero
Borja Roca Romero on 5 Apr 2018
Hi, I tried this but I still have the same issue as Hung BV, fopen(b) does not work for me. I'm sure nobody else nor my applications r using the device.

Sign in to comment.

liang kai-min
liang kai-min on 15 May 2017
My Bluetooth device type is HC-05. If I use bluetooth function, it is necessary to set the baudrate?

Community Treasure Hunt

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

Start Hunting!

Translated by