Interface Arduino with MATLAB

Interface Arduino with MATLAB

The MATLAB Support Packages for Arduino Hardware lets you use MATLAB to communicate with your board through USB cable. The support packages are available for 32-bit and 64-bit Windows, 64-bit Mac OS and 64-bit Linux.

How Arduino MATLAB Interface Works?

We normally use Arduino IDE to write and upload programs (or Sketches) to Arduino. This is fine for regular use but if you want to plot the data obtained from sensors, then the programming becomes a time consuming task.

MATLAB addresses several such problems in Arduino Programming with the help of two types of processes:

  • Reading, writing and analyzing data from Sensors
  • Developing Algorithms that run as standalone program on Arduino

In order to achieve this, we need an extra package for MATLAB called MATLAB Support Package for Arduino. This is officially released by MATLAB and is available for free in their website (you need to have an account to download this package).

Installing Packages

You can easily install packages through your MATLAB.

First, start MATLAB and click the Add-Ons drop down menu. In the drop-down menu click Get Hardware Support Packages. It will start the package installer window.

In the next window you will see all the available packages for MATLAB and Simulink. Select the Arduino package, then check all the packages displayed and click Next to continue installation.





Next, the installer will ask you to log in to your MathWorks account. If you don’t have an account, you can create one during installation. Accept the license agreement on the next screen and continue to download the packages. Now you have to wait for MATLAB  to download and install all the required packages.

TESTING

Once the packages are installed, connect your Arduino to your PC and type the following command in MATLAB command window,

a=arduino()

if you have more than one Arduino connected to your PC, you have to specify the board type you will be communicating with:

a = arduino(‘com3’, ‘uno’)

MATLAB will then attempt to communicate with your board. If successful, MATLAB will display the properties of the Arduino board connected to your PC as shown below:

We hope this tutorial helped you in learning how to interface Arduino with MATLAB. You may also want to take a look at our tutorial on Control an LED using MATLAB.

If you liked this article, then please subscribe to our YouTube Channel for MATLAB & Simulink’s Video Tutorials. You can also find us on Twitter and Facebook .


Senior undergraduate student from Shri Mata Vaishno Devi Unversity, Katra.

Leave a Reply