MATLAB Answers

Why can't I connect to my hardware device from MATLAB?

20 views (last 30 days)
I am looking to connect my hardware device to MATLAB. If I run into any issues, what are some troubleshooting steps that I can use to narrow down the scope of the issue? What if everything I try doesn't help?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 Aug 2021
If you are using a hardware device for a Test and Measurement product, you will be using one of the following toolboxes:
  • Data Acquisition Toolbox
  • Image Acquisition Toolbox
  • Instrument Control Toolbox
  • OPC Toolbox
  • Vehicle Network Toolbox
The troubleshooting steps listed below will work for most hardware device setup configurations but may not apply to all. The workflows described below may also help with troubleshooting connection issues related to Arduinos, Raspberry Pis, webcams, and IP cameras. The information below does not include any methodology for troubleshooting any workflow-related issues you may be encountering.

Platform and Product Support

Make sure that you meet the necessary system and product requirements for each toolbox:
For more information about the Product Requirements and Platform Availability for each toolbox, please see the Useful Links section below.
  1. Even though MATLAB is listed as a required product for all toolboxes, Simulink is also required if you want to use the toolbox's blocks in Simulink.
  2. This information is accurate as of R2021a. Make sure to verify that your system and product requirements match the information for your specific version of MATLAB, as requirements may change from one release to another.

Device and Protocol Support

The next step is to determine if the device you are using is listed as a supported device or communicates via a supported interface. If your device is specifically listed as a device that is supported or supported via a support package, then all workflows that are listed in the documentation (that are also compatible with your device) should work as expected. If the toolbox supports connecting to your device through a specific protocol/interface, make sure that the device supports communication using that interface. This information can usually be found on the manufacturer's website in the device's data sheet.
Please see the Useful Links section below to learn more about each toolbox's supported features. Make sure to check for supported devices and protocols based on your specific version of MATLAB. The links below may not have all relevant information, and do not include workflows like creating custom adaptors or libraries to connect to your device.
If a support package is required to use your device, the support package generally must be installed before you can detect or connect to it.
If your device is not explicitly listed as a supported device, check if the device can communicate using a protocol that is supported. If not, the device may still work as expected, but this behavior is not guaranteed.

Hardware Setup

Ensure that your hardware device is set up according to your device's manual/instructions. If the device is not configured properly, MATLAB may not recognize it or may have difficulty interacting with it even if you can connect to it outside of MATLAB.
Basic Troubleshooting Steps

Test Outside of MATLAB

The first thing to check if you cannot detect or connect to your hardware device is to check if you can use an external program. For devices with physical connections, it will frequently show up in the Device Manager on a Windows machine. For the OPC Toolbox, you can try pinging your device from the Command Prompt.
A lot of vendors also provide a program for testing and using their hardware devices. Check if these 3rd party programs can detect the device of interest.
If the device cannot be detected or connected outside of MATLAB, then it will not work when trying to connect to MATLAB. Check the device's manual/datasheet for setup information to verify that the device works outside of MATLAB first, and you should reach out to your device's manufacturer for more troubleshooting steps.

Disconnecting and Reconnecting

It may sound cliché, but physically disconnecting and reconnecting your hardware device may allow you to connect to your device in MATLAB. For many hardware devices, it can only support one connection at a time. If your device is connected to another active program on your machine, MATLAB will likely not be able to connect to your device, and MATLAB may not even detect it. Similarly, MATLAB may not be able to detect or connect to your device if the device is also connected to and is being used by another computer. There are a few ways to rule this out:
  • (Preferred) Assuming the device is only connected to one computer, you can try restarting your computer. Restarting may also be necessary if you installed a support package or 3rd party driver, etc.
  • If you know what program the device may be connected to, try deleting the connection to the device from the program. You can also fully close out the program, which may remove the connection to the device.
  • Unplug the data transmission line from either the computer or device and plug it back in.
  • If applicable, try power-cycling your device. Another alternative (but may not be recommended by the manufacturer) is to disconnect power from your device and then reconnect.

Performing a Reset

Sometimes when installing or modifying MATLAB, any changes made may not immediately become apparent because these changes will be applied to MATLAB during startup. If a new driver was just installed, it might be the case that MATLAB does not acknowledge the new driver. Some installations will explicitly state that a restart is required, but if a new item was just installed and MATLAB does not recognize it, you may need to restart MATLAB and/or your computer.

Checking MATLAB GUIs

For some users, may be easier to try detecting and connecting to your instrument through a Graphical User Interface (GUI). These GUIs can potentially reveal more information about what might be going wrong. Not every toolbox has a GUI, but you can execute the following functions to launch the relevant GUI:
>> imaqtool
>> tmtool
>> opcDataAccessExplorer
>> canExplorer
>> canFDExplorer
The available GUIs and functionality within them may change from release to release, but all the of the apps available in your release can also be accessed from the "Apps" tab in the ribbon. The above list are the apps available in R2021a, and most of them are listed under the Test & Measurement section in the list of all available apps.
Contacting Support
If none of the above help with the detection/connection issue, or if you encountered any difficulties following the above suggestions, you can contact support. For more information about contacting support, please see this page. Before reaching out for technical support, execute one of the following commands based on your toolbox in the Command Window:\n\n
  • Data Acquisition Toolbox:
>> daqsupport
  • Image Acquisition Toolbox:
>> imaqsupport
  • Instrument Control Toolbox:
>> instrsupport
  • OPC Toolbox:
>> opcsupport(hostname)
  • Vehicle Network Toolbox:
>> canSupport
Each of these commands will create a .txt file with information including the devices MATLAB can detect and the connection status for each of the devices. Please include the .txt file when reaching out to support.

Requesting New Hardware Support

In the event that you have a hardware device that is not specifically supported for use with MATLAB or Simulink, you can request a new device/protocol be supported through the links found on this page .\n\n
Useful Links
Data Acquisition Toolbox:
Image Acquisition Toolbox:
Instrument Control Toolbox:
OPC Toolbox:
Vehicle Network Toolbox:

More Answers (0)

Community Treasure Hunt

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

Start Hunting!