Hi Guys
But for my project I need to be able to communicate with it in realtime in parallel with other measurements and controls of other devices. The communication of these other devices were implemented in Simulink.
So I am looking into the serial communication. I am on a win8.1 laptop and I can see the COM Port (COM5). I can open it via Matlab (serial() with baudrate 115200), but I do not seem to be able to send anything. Every write ends up in time out.
I read the code in the python and the c++ sources, but I do not see anything.
So can someone point to me what I am missing?
Thanks
jollo![Matlab Matlab](x-raw-image:///381bee64a729a6484e0dcaba7bb111877b174536915335ed05493b5429f54a6c)
![Bluetooth Serial Connection Matlab Student Bluetooth Serial Connection Matlab Student](x-raw-image:///df326e1dfc7fe22a4746faf1ffcf70046b5d3652299b2aaeb0855d82e253560c)
Use the Bluetooth interface to connect to devices over the Bluetooth interface and to transmit and receive ASCII and binary data. The toolbox supports the Bluetooth Serial Port Profile (SPP). You can identify any SPP Bluetooth device and establish a two-way connection with that device.
I received my BITalino device this week and everything works fine using the Open Signals software and bluetooth. But for my project I need to be able to communicate with it in realtime in parallel with other measurements and controls of other devices. The communication of these other devices were implemented in Simulink.
So I am looking into the serial communication. I am on a win8.1 laptop and I can see the COM Port (COM5). I can open it via Matlab (serial() with baudrate 115200), but I do not seem to be able to send anything. Every write ends up in time out.
I read the code in the python and the c++ sources, but I do not see anything.
So can someone point to me what I am missing?
Thanks
jollo
Active4 years, 6 months ago
I am sending accelerometer data via bluetooth into Matlab where I will process it and build a GUI.
I am currently working on getting the bluetooth data into Matlab. I'm using a dongle which gets data into port COM18. This is the code I'm using:
When I start from scratch (disconnect and connect bluetooth and dongle, reopen matlab etc) The port successfully opens and allows me to read data. However, if I close and then try to open, it will give me an error:
Error using serial/fopen (Line 72) Open failed: Port COM 18 is not available. Available ports: COM6, COM7, COM19. use INSTRFIND to determine if other instrument objects are connected to the requested device.
I know that my device isn't connected to anything else. So I then have to disconnect my bluetooth, dongle, and restart matlab.
Is there a more efficient way to do this?
Also, I am able to get values from my accelerometer into Matlab, but I don't know how to make them continuous. Each time 512 bytes are sent and if my ValuesReceived exceeds 12000, I once again have to restart my bluetooth device to get more values. I've tried flushoutput, but it hasn't worked. Any ideas on how to get continuous data into Matlab so I can process it in my GUI?
Ben Reich14.3k2 gold badges28 silver badges53 bronze badges
AzizelleAzizelle
1 Answer
I figured out the problem. In order to not get this error anymore I simply had to follow the sequence
and then when I do
I am no longer getting the error. It was just the order of operation to close the serial.
AzizelleAzizelle