0

I have an Arduino board with Intel Edison on it. I have tried to read data in Arduino from MatLab through the serial port. I'm sure the Arduino board is working because when I use the serial monitor from Arduino, it shows the data read from the Arduino board. My command is like this in Arduino:

   reading = Wire.read();
   Serial.println(reading)

I got errors in Matlab when I tried to work with these piece of code:

   s=serial('COM4');
   set(s,'BaudRate',9600);
   fopen(s);

MatLab complains that "Port: COM4 is not available. No ports are available. Use INSTRFIND to determine if other instrument objects are connected to the requested device." I have tried with "instrfind()" in matlab and got this:

   Instrument Object Array

   Index:    Type:     Status:   Name:  
   1         serial    closed    Serial-COM4
   2         serial    closed    Serial-COM4
   3         serial    open      Serial-COM4
   4         serial    closed    Serial-COM4
   5         serial    closed    Serial-COM4

I still can't get any clue on this. Can anybody help me?

  • I'm not a fan of how Windows handles COM ports. I think the most successful applications scans all the COM ports and identifies with a connected device through proprietary means (for example, maybe the application is looking for the company's name as a response). I might try to reboot (its Windows after all) with out the Arduino plugged into the USB port, bring up the device manager and open the COM section and watch which COM becomes available when you do plug in the Arduino's USB cable. Then try connecting to that COM with matlab. Don't use anything else that may connect to that COM port. – st2000 Dec 4 '16 at 17:18
  • Hi, I can't believe I forget "reboot the system" for this. Your idea works. Thanks very much. – skyworld Dec 5 '16 at 13:49
  • Great news. In order to count this question as solved: I can copy the comment to the Answer box where, if you would be so kind, accept it. – st2000 Dec 5 '16 at 14:07
2

I might try to reboot with out the Arduino plugged into the USB port, bring up the device manager and open the COM section and watch which COM becomes available when you do plug in the Arduino's USB cable. Then try connecting to that COM with matlab. Don't use anything else that may connect to that COM port.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.