Introduction: Bluetooth - Serial Port Redirection Using Matlab/simulink

Picture of Bluetooth - Serial Port Redirection Using Matlab/simulink

Ooh ...!!
I have a project must done within 2 months ,
my project Requires the " HC-05 " Serial Bluetooth module , which i don't have , So I was thinking of using the built-in Bluetooth in my laptop.
so I tried many programs without any results.

finally: I succeeded by using the simulink.

to simplify this idea , I will explain it in a small example.

Step 1: Android Mobile With Arduino Example

Picture of Android Mobile With Arduino Example

Bluetooth-based Android Controller for Arduino ,


 *  Breadboard wiring and electronics skills.
 *  Arduno Uno.
 *  Laptop include Bluetooth or USB Bluetooth adapter  .
 *  Matlab program on PC.
 *  Android Bluetooth terminal like:
      - TerminalBT :

Step 2: Preparation of Simulink

Picture of Preparation of Simulink

Open MATLAB program and run the simulink.
- Make a new model
- select " Instrument Control Toolbox "  from Library  / Or search for "Serial"
- drag and drop the blocks: serial send and serial receive , like in the photo.
- Double click on the block to configure the source block parameters and select ports for Arduino and Bluetooth
- Save it

Step 3: Preparation the Arduino

Picture of Preparation the Arduino

This is a small code to test the example:_

int ledPin=13;
int value;

void setup ()



pinMode(ledPin,OUTPUT); }

void loop ()

{ value =; if (value == '1') {digitalWrite(ledPin,HIGH);}

else if (value == '0') {digitalWrite(ledPin,LOW);}



When you send number " 1 " from your serial terminal , the Pin 13 will be 1 (5V) so the LED will turns ON.
and when you send number " 0 " , the Pin 13 will be 0 (0V) so the LED will turns OFF.

Step 4: Test..!

Picture of Test..!

Close all programs and disconnect the Arduino (to avoid some problems).

* Re connect the Arduino with PC and run MATLAB / simulink.

* Open the saved simulink file and press the play button.

Run Terminal App on a smart phone and connect it with PC Bluetooth.

send "1" and "0" to make sure that the connection works well


Malek Hamdan


VamsheethV (author)2016-11-21

plz upload the code of matlab to connect to bluettoth of arduino

no use of phone....

Thanks in advance...

mayur1432 (author)2016-09-30

superb dude....need help to communicate with HC05 by matlab

JonathanC166 (author)2016-06-16


FrAnKeStEiNM (author)2015-01-29

Thanks ,

please can i do the same thing by using a ble (bluetooth low energy) : by developping a module in simulink to receive informations by ble from a beacon

techbitar (author)2014-04-18

Thank you. Very original and very useful.

hamdanoid (author)techbitar2014-04-18

Thanks Mr. bitar

About This Instructable



Bio: Geek
More by hamdanoid:Bluetooth - Serial port redirection using matlab/simulink
Add instructable to: