Serial Port & Bluetooth
5 views (last 30 days)
Show older comments
Hello All,
My last question http://www.mathworks.com/matlabcentral/answers/9630-bluetooth-communication helped me a lot and I've made some progress in establishing a connection.
I've downloaded a Bluetooth driver for my USB dongle and now I can create a Serial Port for my Bluetooth connection. However, I've created only one COM port, is it possible to read and write to the same COM port?
The reason for this question, is that I'm currently not receiving anything on this COM port. I can write without errors, but I don't know how to check if it is received on my Bluetooth Device. Does anyone have any tips or ideas?
Greetings,
Hans
0 Comments
Accepted Answer
Chirag Gupta
on 7 Jul 2011
You can read/write on the same COM port. The trick to checking whether data is being sent or received by the serial port and your device is to use some sort of serial port monitor. Googling for it, should give you plenty of hits.
The serial port monitor can confirm whether the data is being sent to the device and vice-versa. Once you can confirm data is being sent and received, you would have to then check whether its the correct data (i.e: you are sending out the exact commands that your device expects)
2 Comments
More Answers (2)
Iman
on 14 Aug 2013
Edited: Iman
on 14 Aug 2013
Hi
I have this bluetooth device powered by an arduino which I can connect via COM port in a serial monitor such as putty. However I cannot do this in matlab.
I set this up as a normal com port as follows:
s = serial('COM6','BaudRate',9600,'DataBits',8,'StopBits',1,'Parity','None','FlowControl','None','ByteOrder','bigEndian','DataTerminalReady','off');
fopen(s);
I usually get an error at fopen like this:
Error using serial/fopen (line 72) Open failed: Cannot connect to the COM6 port. Possible reasons are another application is connected to the port or the port does not exist.
Error in arduino2matlab (line 13) fopen(s);
Or sometimes it states that port is not open and then lists that same port as an available port. I'm sure I've closed it in the serial monitor and nothing else should be using it. And when I use this code for hard-wire usb it works fine in matlab. I just don't understand why I cannot open the port in matlab but can in putty.
Thanks
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!