Clear Filters
Clear Filters

error using serialport(line116)

2 views (last 30 days)
nilay sogat
nilay sogat on 4 Apr 2022
I want to connect the matlab with arduino and send array to arduino from matlab. But whenever I write fopen(arduino) to my code matlab stops sensing arduino and give error as :
Error using serialport (line 116)
Unable to connect to the serialport device at port 'COM6'. Verify that a device is connected to the port, the port is not in use, and all
serialport input arguments and parameter values are supported by the device.
See related documentation for troubleshooting steps.
Error in untitled (line 1)
arduino=serialport('COM6',9600);
But If I don't use that function matlab senses arduino with no problem. Even delete(instrfind) function couldn't solve this problem.

Answers (1)

Sivapriya Srinivasan
Sivapriya Srinivasan on 4 Oct 2023
Hello Nilay,
I understand that you are encountering an issue when trying to connect MATLAB with Arduino using the fopen function. The error message suggests that MATLAB is unable to establish a connection with the Arduino device on port 'COM6'. Here are a few troubleshooting steps you can try:
  1. Make sure that your Arduino is properly connected to your computer via the USB cable. Check that the cable is securely plugged in and that the Arduino board is receiving power.
  2. Check port availability: Ensure that there are no other applications or programs currently using the 'COM6' port. If another program is using the port, close it and try again.
  3. Verify port number: Double-check that the port number 'COM6' is correct. You can check the correct port number by going to the Device Manager on your computer and looking under the 'Ports (COM & LPT)' section.
  4. Close existing connections: If you have previously opened a connection to the Arduino using MATLAB, make sure to close it before attempting to open a new connection. You can use the fclose function to close the serial port.
  5. Restart MATLAB: Sometimes, restarting MATLAB can help resolve connection issues. Close MATLAB, disconnect the Arduino, reconnect it, and then restart MATLAB.
  6. Update drivers: Ensure that you have the latest drivers installed for your Arduino board. Visit the official Arduino website and download/install the appropriate drivers for your operating system.
  7. Try a different USB port/cable: If possible, try connecting the Arduino to a different USB port on your computer. Additionally, try using a different USB cable to rule out any cable-related issues.
  8. Update MATLAB: Make sure you have the latest version of MATLAB installed. Updates often include bug fixes and improvements that might help resolve the issue.
By following these troubleshooting steps, you should be able to establish a successful connection between MATLAB and Arduino.
Hope this helps!

Categories

Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!