0

I'm trying to follow this guide on sending data from an arduino to a MATLAB program. I have every piece of code exactly matching the code in the example. However, whenever I attempt to start up the MATLAB program, I get the error message:

Error using serial/fopen (line 72) Open failed: Port: COM3 is not available. Available ports: COM1. Use INSTRFIND to determine if other instrument objects are connected to the requested device.

Error in Untitled8 (line 2) fopen(arduino)

Can anyone help me figure out how to get this working?

EDIT: My arduino is printing to COM3, so if I want MATLAB to hear it, it also needs to be COM3.

7
  • you want to use COM3 and the only available port for MATLAB is COM1. check that. Commented Apr 20, 2014 at 23:00
  • But my arduino is talking to COM 3, so shouldn't I have to have MATLAB do the same? Commented Apr 20, 2014 at 23:11
  • it depends if on your computer you have a COM3 at all. And there is no other program using or blocking that. Commented Apr 20, 2014 at 23:14
  • I have about 16 serial ports on my computer. COM1 is an RS232 serial port, and the rest are USB. and the arduino is talking to COM3 which is causing the block. If i unplug the arduino the matlab code runs but times out (obviously). but that defeats the whole point if I can't have the arduino running while the matlab code is running, since I'm trying to get the matlab code to read what the arduino is saying. Commented Apr 20, 2014 at 23:15
  • I do have COM 3.... thats the port I use to program my arduino with. Edit: proof (i.imgur.com/YBg5xMh.png) Commented Apr 20, 2014 at 23:18

1 Answer 1

1

If I understand correctly you are using the Arduino IDE/Monitor to communicate with your Arduino on COM3. You want to have Matlab connect to the Arduino.

Since RS-232 is a point to point methology, you can only have one program/device on each end unless you add a bunch of hijinks.

When you have the Arduino IDE/Monitor open it uses the com port and other programs are denied access.

I think you need to close the Arduino monitor program to release Com port 3 and then the Matlab program should be able to open the port.

Sign up to request clarification or add additional context in comments.

1 Comment

I have tested this using a terminal. Obviously the port needs to be open for the terminal to receive the arduino's prints. The terminal DOES open when I have the arduino ide open, but it DOES NOT open when the arduino's COM terminal is open. So theoretically, MATLAB shouldn't be having a problem when just the IDE is open. Hence my problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.