File Exchange

image thumbnail

MATLAB Support Package for Arduino Hardware

Acquire inputs and send outputs on Arduino boards

3.43243
44 Ratings

2201 Downloads

Updated

Editor's Note: Popular File 2015 2016

MATLAB® Support Package for Arduino® Hardware enables you to use MATLAB to communicate with an Arduino board. You can read and write sensor data through the Arduino and immediately see the results in MATLAB without having to compile.

This support package is functional for R2014a and beyond.

To use Arduino hardware with MATLAB versions R2013b and earlier, see:

http://www.mathworks.com/matlabcentral/fileexchange/32374

Comments and Ratings (156)

Ignacio Prina

Hi, I tried to launch the IDE directly and I couldn't. So I thought could be a problem in the DEP 'Data execution prevention' protection on Windows and I disabled all the protection by cmd console using admin privilege, but the problem still persist. Maybe if somehow I could use another version of the Arduino IDE..
I submmitted this problem to service request anyway. Thanks for answer

Ignacio

Menghan

Hi Ignacio,

You can submit a service request here, https://www.mathworks.com/support/contact_us/
Go to the folder where arduinoio.IDERoot points at in MATLAB and see if you can launch the IDE from there. Please include this information in the request.

Menghan

Ignacio Prina

hi, yes of course I tried to reinstall the package multiple times before I asked the question, How can I contact with the Technical Support? thanks

Menghan

Hi Ignacio,

Try reinstalling the support package in 2017a MATLAB first. If it does not work, contact our Technical Support, we'd like to know more and help you fix it.

Thanks,

Menghan

Ignacio Prina

Hi, I'm having this problem "Arduino IDE at folder 'arduino-1.6.13' is corrupt" in matlab 2017 for win64 bis. I used to use this package on Matlab 2015a without any problem. Can you helpme?

Menghan

Hi Tim,

Arduino Micro should work with this support package. Just specify 'micro' as board type when you call arduino. You can find the list of supported boards here,

https://www.mathworks.com/hardware-support/arduino-matlab.html

Thanks,

Menghan

Tim meyer

Hi,
is there a way to get the arduino micro (which I happen to have) connected?

Cheers Tim

Menghan

Hi Gibin,

With the MATLAB Arduino Support Package, the communication or data transfer is initiated from MATLAB, meaning Arduino board will get data from MATLAB whenever MATLAB calls it. Feel free to take a look at some of the examples in our Documentation to see if it fits with what you are trying to accomplish.

https://www.mathworks.com/help/supportpkg/arduinoio/examples.html?s_cid=doc_ftr

Thanks,

Menghan - (MATLAB Hardware Team)

Please Help me.How can I use mathlab whenever arduino program calls it to give digital data from mathlab to arduino

I have a problem. I try to connect computer to Arduino by using Bluetooth module HC-06. For this task I implemented two methods.
Command arduinosetup doesn't work for library "MATLAB Support Package for Arduino Hardware version 16.2.1". I can't connect computer with Arduino via Bluetooth (HC-06).
When I try to use following commands:
instrhwinfo('Bluetooth','HC-06')
b = Bluetooth('HC-06',1)
fopen(b)
a=arduino('COM4','UNO')
I got following error:
Cannot program board Uno (COM4).
Please make sure the board is
supported and the port and board
type are correct.
Can anybody help me with this?

Husnu Avsar

I want to drive a stepper motor with the A4988 or drv8825. Can I find the sample Simulink file. If you can control, I want to simulink the 3d printer.

Thank you Thank you :D

Chien Khong

Hi,

May I know how to add a custom Arduino library to Matlab. For instance Arduino library for Hx711 weight sensor module ?

Tae-Hoon Yoo

i actually download arduino support package but when i write a=arduino

give this error,i tried to installed it many times and every time it installed successfully
what is the problem please help me

"You need the MATLAB Arduino support package before you can use this feature. Open Support Package Installer to install support for additional
MATLAB hardware."

Rouis Jihene

Hi, i installed matlab R2017a, and i need to use LSM303Exemple in order to read value from an accelerometer: first i write
a = arduino('COM5', 'Mega2560', 'Libraries', 'Pololu/LSM303')
and it's work well then i would like to Create LSM303 device object for LSM303D accelerometer
compass = addon(a, 'Pololu/LSM303')
but it doesn't work: i get this error message:
Cannot auto-detect the device type and SA0 pin state. If using an Arduino Due or an Arduino clone, specify both device
type and pin state
How can I do? please help me, it's very urgent and thanks

I have 9.2 Matlab (2017a) but i can install it because i get this message:
"The support package requires the following products to be installed:
MATLAB 9.2"
How can i solve this problem?? Thanks

pavan simha

Erix Tech

how i can fix Arduino IDE at folder 'arduino-1.6.13' is corrupt. Open Add‑On Explorer to reinstall
MATLAB Support Package for Arduino Hardware..
i was ready reinstall it 3 times, but still same. can anybody help me?

Menghan

Hi Dario,

Thanks for reporting the issue. However, there are various things that could have caused the installation failure. To better help you, could you create a Service Request to our Customer Support here https://www.mathworks.com/support/contact_us/? We'd be glad to help you find out a fix.

Menghan

(MATLAB Hardware Team - MathWorks)

Eric Thim, I am trying to install too, and it's the same think. Someone help us please. In all computers (20) 19 with 2016b and one with 2015a

Rajan Chalotra

Rajan Chalotra (view profile)

will this work on Arduino Due?

Eric Thim

For some reason, when I'm trying to install the package, the install stops when it it gets to "Downloading Third Party Packages." There is no error number given; I'm simply told to contact technical support. Is there a fix for this problem?

Sine Su

Could someone share Arduino Hardware Support for me. I cannot download it from the net. It is 0% for at least 3 hours.I cannot find a offline install package on the net. Thanks.784584308@qq.com

T sheldon

Can someone share the Arduino Hardware Support package for me ? I downloaded it from the official website can not run well. Always prompt an error :Arduino IDE at folder 'arduino-1.6.13' is inaccessible or corrupt. Thanks . zhouyangoo@foxmail.com

hi,
is it possible to give input to arduino thorough hand gestures.

Huda Makruf

Menghan

Hi Aditya,

Has it ever worked for you since the support package is installed? If not, could you try a reinstallation? If you are still getting the error after all, please contact our Technical Support for further troubleshoot.

Thanks,
Menghan

Aditya Joshi

On Mac OS X El Capitan 10.11.6 (15G1217) using R2016B

a = arduino('/dev/cu.usbmodem1411','uno', 'traceon', true)
Updating server code on board Uno (/dev/cu.usbmodem1411). Please wait.
First input can not be empty. Expected a non-empty character vector or
a valid file-id.

I am not even getting trace. Please advice how to fix this.

Thank you.

hi i am trying to install hardware support packages it takes too long and stops. i quit this and retried but it gives me error now. can anyone please help will be very greatful.
Error: The application encountered an unexpected error and needs to close. You may want to try re-installing your product(s). More information can be found at C:\Users\Muhammad\AppData\Local\Temp\mathworks_Muhammad.log

Menghan

Hi Jessi,

It should be fixed for 16.1.1. If it's still not working for you, create a ticket to our Technical Support with the exact error and we shall be able to help you find out the root cause.

Menghan

Jessie Swan

Menghan, I've also run into an issue with the Adafruit motor shield during install, the latest version from Mathworks appears to be 16.1.1. Can you confirm what version fixes the Adafruit motor shield issue?

Menghan

The Adafruit motor shield library download issue is resolved now. Please try re-installing the support package. Feel free to contact our Technical Support if you are still facing the issue.

Thanks,

Menghan

Menghan

Hi Omar,

We've noticed the Adafruit motor shield library download issue starting just today. We've actively looking into it now and I will update here once the issue is fixed.

Thanks,

Menghan

(MATLAB Hardware Team - Arduino)

Omar Crypps

I had a problem when installing the Arduino support package
the error says

Error installing third party software adafruit motor shield v2 Library

Do you have any idea how i can solve this problem ?

alperen kara

okey I made. I reinstalled again again....and ıt gave me to com5 port.probably,I am lucky

***Undefined variable "ide" or class "ide.internal.getArduinoIDERootDir".***

R2016a
I have this problem. I tried everything. I serched solution many hour. but I didnt do.javier has Same problem.and I dowloaded add-ons in Matlab. please Help.

I have Matlab R2016a, I have installed MATLAB Support Package for Arduino Hardware version 16.1.1

I got this message when trying to connect to my Arduino UNO R3:

Undefined variable "ide" or class "ide.internal.getArduinoIDERootDir"

Any hint to solve this?
Thanks
javier

matlab

matlab (view profile)

JANAK TRIVEDI

Error: The application could not connect to MathWorks.
For more information on resolving this issue, see this Support Article

I need Arduino® Hardware for matlab 2013a.
Please provide link.

i installed the aurdino simulink software package after completion if i open the simulink library means in shows only the old command not new(ardino io etc.,).it doesn't shows ew commands for ardino

Cem BIÇAKCI

Stuart Brand

With regard to the 01 October 2016 entry by Félix González:

ArduinoServer.ino:11:23: fatal error: MWArduino.h: No such file or directory compilation terminated.

I was getting this, and fixed it by uninstalling the Arduino environment at C:\Program Files\Arduino, followed by uninstalling the MATLAB for Arduino package. After this I reinstalled the MATLAB for Arduino package, and started the Arduino environment from C:\MATLAB\SupportPackages\R2016A\ardiono-1.6.1\. In the Arduino Preferences, set this as the sketchbook location.

Apparently there can be only one installation of the Arduino environment on the computer without getting all the Arduino path information screwed up.

I am consistently getting this error when I try to install the Arduino support package:

Download Failed: sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Any advice or workarounds?

Thank you for these useful files!
Could you please tell me how I can set the resolution and sampling rate of the analog inputs, please?
Thank you.

dhaba india

Reading the Troubleshooting in MATLAB Support Package for Arduino Hardware, in the topic Arduino Connection Failure I found this instructions: a = arduino('COM4','Uno','Trace',true). I typed it and I got this:

Vendor returned error messages:
Utilizando biblioteca Firmata en carpeta: C:\Users\ricar_000\Documents\Arduino\libraries\Firmata
Utilizando biblioteca MWArduino en carpeta: C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\MWArduino (legacy)
Utilizando biblioteca Wire en carpeta: C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
Utilizando biblioteca SPI en carpeta: C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
Utilizando biblioteca Servo en carpeta: C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\Servo

C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions
-ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601
-DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\cores\arduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\variants\standard
-IC:\Users\ricar_000\Documents\Arduino\libraries\Firmata
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\MWArduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\Servo\src
C:\Users\RICAR_~1\AppData\Local\Temp\ArduinoServer\MW\ArduinoServer.cpp -o
C:\Users\RICAR_~1\AppData\Local\Temp\ArduinoServer\MW\ArduinoServer.cpp.o
C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions
-ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601
-DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\cores\arduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\variants\standard
-IC:\Users\ricar_000\Documents\Arduino\libraries\Firmata
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\MWArduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\Servo\src
-IC:\Users\ricar_000\Documents\Arduino\libraries\Firmata\utility
C:\Users\ricar_000\Documents\Arduino\libraries\Firmata\Firmata.cpp -o
C:\Users\RICAR_~1\AppData\Local\Temp\ArduinoServer\MW\Firmata\Firmata.cpp.o
C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions
-ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601
-DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\cores\arduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\variants\standard
-IC:\Users\ricar_000\Documents\Arduino\libraries\Firmata
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\MWArduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\Servo\src
-IC:\Users\ricar_000\Documents\Arduino\libraries\Firmata\utility
C:\Users\ricar_000\Documents\Arduino\libraries\Firmata\utility\BLEStream.cpp -o
C:\Users\RICAR_~1\AppData\Local\Temp\ArduinoServer\MW\Firmata\utility\BLEStream.cpp.o
C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions
-ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601
-DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\cores\arduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\variants\standard
-IC:\Users\ricar_000\Documents\Arduino\libraries\Firmata
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\MWArduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\Servo\src
-IC:\Users\ricar_000\Documents\Arduino\libraries\Firmata\utility
C:\Users\ricar_000\Documents\Arduino\libraries\Firmata\utility\EthernetClientStream.cpp -o
C:\Users\RICAR_~1\AppData\Local\Temp\ArduinoServer\MW\Firmata\utility\EthernetClientStream.cpp.o
C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions
-ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601
-DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\cores\arduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\variants\standard
-IC:\Users\ricar_000\Documents\Arduino\libraries\Firmata
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\MWArduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\Servo\src
-IC:\Users\ricar_000\Documents\Arduino\libraries\Firmata\utility
C:\Users\ricar_000\Documents\Arduino\libraries\Firmata\utility\SerialFirmata.cpp -o
C:\Users\RICAR_~1\AppData\Local\Temp\ArduinoServer\MW\Firmata\utility\SerialFirmata.cpp.o
In file included from C:\Users\ricar_000\Documents\Arduino\libraries\Firmata\utility\SerialFirmata.cpp:20:0:
C:\Users\ricar_000\Documents\Arduino\libraries\Firmata\utility\SerialFirmata.h:30:28: fatal error: SoftwareSerial.h: No
such file or directory
#include <SoftwareSerial.h>
^
compilation terminated.
Error de compilaci¾n

Can someone help me with this?

Thanks.
Ricardo

Tri Vu

Tri Vu (view profile)

=.= I'm sr for my mistake =.=! Nếu được thì kết bạn trao đổi cho dễ :D :D

Uyen Nguyen

"add one more"...Sorry, i don't understand clearly. " Cam on ban Tri Vu" =)

Tri Vu

Tri Vu (view profile)

You should move folder ArduinoIO to desktop, and change path or add one more :D , i tried and done! Try it! Have luck!

Uyen Nguyen

I have run file adioes.pde before. I have submitted my error for technical service and waiting their answer. Thanks Tri Vu

Tri Vu

Tri Vu (view profile)

oh you should found folder pde and run file *.pde in folder adios before run code from MATLAB :D

Uyen Nguyen

please helps me!!!
my problem is: "Cannot program board Uno (COM3). Please make sure the board is supported and the port and board type are correct."
i tried many ways ex: run as adminstration, check COM in device and printer..

Uyen Nguyen

Uyen Nguyen

Hi. I can't seem to connect matlab with my arduino Uno, I have already installed the support package. It gives me this error:

>> a=arduino()
Updating server code on board Uno (COM5). Please wait.
Cannot program board Uno (COM5). Please make sure the board is supported and the port and board type are correct.

Then i type this:
>> a = arduino('COM5', 'Uno', 'Trace', true)

And get this:

Updating server code on board Uno (COM5). Please wait.
Vendor returned error messages:
Utilizando biblioteca Firmata en carpeta: C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\Firmata
Utilizando biblioteca Wire en carpeta: C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\Wire

C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions
-ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601
-DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\cores\arduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\variants\standard
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\Firmata\src
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
C:\Users\FLIX~1\AppData\Local\Temp\ArduinoServer\MW\ArduinoServer.cpp -o
C:\Users\FLIX~1\AppData\Local\Temp\ArduinoServer\MW\ArduinoServer.cpp.o
ArduinoServer.ino:11:23: fatal error: MWArduino.h: No such file or directory
compilation terminated.
Error de compilaci¾n

Any help is appreciated

Menghan

Hi Stella,

Can you check if you have this folder on your computer and it is on MATLAB path? Note if you are not on Windows, the support package install path will be different.

C:\MATLAB\SupportPackages\R2015b\arduinoide\toolbox\realtime\targets\arduinoide

If you add it to the MATLAB path manually, make sure you run "rehash toolboxcache".

Menghan

(MATLAB Hardware Team - MathWorks)

Stella SU

Hi i really need this help.I have problems on connecting matlab and arduino. I have checked everything, the info on board and port, the device manager, and i even installed a new arduino. But it always show me like:
delete(instrfindall);
a = arduino('COM3','Mega2560','TraceOn', true) ;

Updating server code on board Mega2560 (COM3). Please wait.
Undefined variable "ide" or class "ide.internal.getArduinoIDERootDir".

Could anyone help me on this?

BTW, matlab is R2015b,and the arduino board is connecting a small robot. I try to control the steer by matlab

Menghan

Hi Derek,

If you are getting the same error, it is probably not related to the Firmata version issue. To help you better and faster, please contact our Technical Support team by following instructions on this page,

http://www.mathworks.com/support/contact_us/?s_tid=sp_ban_cs

Menghan

Derek

Derek (view profile)

Hi Menghan,

Thanks for your reply. Well, I did try re-installing the package and even used a different system. However the same problem persists. I somehow think that it is linked to the firmata. Any tips on how to downgrade the board's firmata to an older version?

Thank you.

Menghan

Hi Derek,

Can you try reinstalling the support package and see if it resolves it?

Thanks,

Menghan

(MATLAB Hardware Team - MathWorks)

Derek

Derek (view profile)

I am using Matlab 2015b and Arduino UNO. I have downloaded the support package. Whenever i run the command:

a = arduino('com3', 'uno')

I get the following error message,

Updating server code on board Uno (COM3). Please wait.
Error using ar2 (line 2)
Undefined variable "ide" or class
"ide.internal.getArduinoIDERootDir".

Any idea how do I rectify this? Thanks.

Allan Prince

By the way, I'm using matlab 2016a with Arduino support package. My arduino is the 2560.

Please help me
I am using MATLAB13b, I istalled arduino support package. Its working fine with simulink. But when I tried GUI its giving error. So I typed
a = arduino() on command window its displaying error as follow: Undefined function or variable 'arduino'

Menghan

Hi Nicolas,

Can you please show us the trace by running the following code and send us the MATLAB output texts,

a = arduino('/dev/tty.usbmodemFD131','Uno','traceon',true)

Thanks,

Menghan

I trying to use my Arduino/Genuino UNO with Matlab in my MAC (OS X El Capitan) but cannot connect with the Arduino Board.

Fist I've tried:
a = arduino();
Cannot detect Arduino hardware. Make sure original Arduino hardware is properly plugged in. Otherwise, please specify both port and board
type. For more information, see arduino function reference page.

Then:
a=arduino('/dev/tty.usbmodemFD131','Uno')
Updating server code on board Uno (/dev/tty.usbmodemFD131). Please wait.
Cannot program board Uno (/dev/tty.usbmodemFD131). Please make sure the board is supported and the port and board type are correct.

How can I resolve this issue?

Bets regards,

Nicolas

Hi Haritha,

Are you still running into a problem programming your Arduino board?

Run the following code in the MATLAB command line to obtain a trace. If that does not give you an indication of what's going wrong, share the trace in the comments, so we can follow up with you.

a = arduino('com3','uno', 'forcebuild', true, 'traceon', true)

Also, use the Arduino IDE and/or the control panel to make sure that your Arduino board is indeed on COM port 3 and that the board type is indeed "Uno".

Regards,
Wael
(MATLAB Hardware Team - MathWorks)

Xue Ni Law

My problem solved! Thanks to Menghan's answer to Max. I changed my the Folder name from Arduino to A. Then again call the arduino in matlab. Now it was connected.

Xue Ni Law

I have MATLAB 2016a and installed hardware support for Arduino. However, I got the error as below.
"Cannot program Arduino board Uno (COM3). Please make sure the board is supported and the port and board type are correct"

When I tried the trace the error msg. I got it as below.
* I am using Matlab in German language.
[Verwende die Bibliothek Firmata im Ordner: = 'Use the libraries Firmata in Folder: ]

Please give me some idea what wrong with me. I have been stucked for this problem by the whole day.

>> a = arduino('COM5', 'Uno', 'Trace', true)
Updating server code on board Uno (COM5). Please wait.
Vendor returned error messages:
Verwende die Bibliothek Firmata im Ordner: C:\Users\xn\Documents\Arduino\libraries\Firmata
Verwende die Bibliothek MWArduino im Ordner: C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\MWArduino (legacy)
Verwende die Bibliothek Wire im Ordner: C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
Verwende die Bibliothek SPI im Ordner: C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
Verwende die Bibliothek Servo im Ordner: C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\Servo

C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections
-fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\cores\arduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\variants\standard -IC:\Users\xn\Documents\Arduino\libraries\Firmata
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\MWArduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\Servo\src C:\Users\xn\AppData\Local\Temp\ArduinoServer\MW\ArduinoServer.cpp -o
C:\Users\xn\AppData\Local\Temp\ArduinoServer\MW\ArduinoServer.cpp.o
C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections
-fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\cores\arduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\variants\standard -IC:\Users\xn\Documents\Arduino\libraries\Firmata
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\MWArduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\Servo\src -IC:\Users\xn\Documents\Arduino\libraries\Firmata\utility
C:\Users\xn\Documents\Arduino\libraries\Firmata\Firmata.cpp -o C:\Users\xn\AppData\Local\Temp\ArduinoServer\MW\Firmata\Firmata.cpp.o
C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections
-fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\cores\arduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\variants\standard -IC:\Users\xn\Documents\Arduino\libraries\Firmata
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\MWArduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\Servo\src -IC:\Users\xn\Documents\Arduino\libraries\Firmata\utility
C:\Users\xn\Documents\Arduino\libraries\Firmata\utility\EthernetClientStream.cpp -o
C:\Users\xn\AppData\Local\Temp\ArduinoServer\MW\Firmata\utility\EthernetClientStream.cpp.o
C:\MATLAB\SupportPackages\R2016a\arduino-1.6.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections
-fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\cores\arduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\variants\standard -IC:\Users\xn\Documents\Arduino\libraries\Firmata
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\MWArduino
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
-IC:\MATLAB\SupportPackages\R2016a\arduino-1.6.1\libraries\Servo\src -IC:\Users\xn\Documents\Arduino\libraries\Firmata\utility
C:\Users\xn\Documents\Arduino\libraries\Firmata\utility\SerialFirmata.cpp -o
C:\Users\xn\AppData\Local\Temp\ArduinoServer\MW\Firmata\utility\SerialFirmata.cpp.o
In file included from C:\Users\xn\Documents\Arduino\libraries\Firmata\utility\SerialFirmata.cpp:20:0:
C:\Users\xn\Documents\Arduino\libraries\Firmata\utility\SerialFirmata.h:30:28: fatal error: SoftwareSerial.h: No such file or directory
#include <SoftwareSerial.h>
^
compilation terminated.
Fehler beim Kompilieren.

haritha c

i have MATLAB 2014a and installed hardware support for Arduino.
when i type
a = arduino
a = arduino(port,board)

or

a = arduino
a = arduino('com2','uno')

in matlab ,it shows

Cannot program Arduino board Uno (COM3). Please make sure the board is supported and the port and board type are
correct.

please give some suggession. i am using windows7

Thank you, Menghan, for your feedback. After two minor changes, I have managed to get this working. First, I made sure that Java was updated, and then installed the Java 6 SE Runtime (legacy) to match my Arduino configuration. I can't verify that the Java update was the only trick, because I also installed the Raspberry Pi Matlab support package in between all of this. Finally, by calling the direct address (as you mention), I was able to connect to the board. Another computer without these changes was still receiving the same error. Although it's possible that everything was Java related, my superstitions forced me to install the Raspberry Pi toolkit in the same order for the other machines. I did not systematically test this, but now everything is working. I hope this helps other users in the same boat!
Again, thanks for your help!

Menghan

Hi Phillip,

To find out the correct serial port for the board, type "ls /dev/tty*" in a terminal and look for the usbmodem item. The exact string shall be what you input to arduino.

Once you have that, specify both port and board to create the arduino object.

If you are still getting the error, contact Technical Support and we'd like to help you better.

Thanks,

Menghan

(MATLAB Hardware Team - MathWorks)

I receive the same error as Yusef, below: “Failed to open serial port /dev/tty.usbmodemfa431 to communicate with board Uno. Make sure there is no other MATLAB arduino object for this board. For troubleshooting, see Arduino Hardware Troubleshooting.” I’ve now tried this on three machines (all Mac OS X), with Matlab versions 2015b and 2016a. When trying to access the device using the serial command, I receive the following error: Error using serial/fopen (line 72)
Open failed: Port: /dev/tty.usbmodenfa431 is not available. Available
ports: /dev/tty.Bluetooth-Incoming-Port,
/dev/cu.Bluetooth-Incoming-Port, /dev/tty.usbmodemFA431,
/dev/cu.usbmodemFA431.
Use INSTRFIND to determine if other instrument objects are connected
to the requested device.

I’ve searched extensively for a solution to this problem, and found that it has been persistent for at least a year. For example, there are several unresolved submissions at Matlab Answers about this very issue:

http://www.mathworks.com/matlabcentral/answers/176704-matlab-can-t-find-arduino-mac

http://www.mathworks.com/matlabcentral/answers/230953-how-to-connect-an-arduino-to-matlab-run-on-a-mac-error-using-serial-fopen-line-72

The solution on the following page did not work for me:

http://www.mathworks.com/matlabcentral/answers/159997-accessing-arduino-uno-through-matlab

I also found the following description of other users attempting to resolve this:

http://www.ugrad.physics.mcgill.ca/wiki/index.php/MATLAB_and_Arduino

Using the “java.opts” fix described in that document also did not resolve the issue. I’m at a loss here, and would really love to access the Arduino (again…it worked before the switch to the support package when I used to run 2014a). Any advice would be certainly appreciated by many!

Menghan

Hi Yusef,

Can you try the following and see if it works? Otherwise, what is the error?

>>s = serial('/dev/tty.usbmodemfa131');fopen(s);

Thanks,

Menghan

Failed to open serial port /dev/tty.usbmodemfa131 to communicate with board Mega2560. Make sure there is no other MATLAB arduino object for this board. how do i fix?

Cannot install MATLAB Support Package for Arduino® Hardware while download Arduino IDE. I try to download directly from googlecode It seems like stop download this file at 80 percent.

How can I fix it ?

Menghan

Hi Yuxuan,

It seems that you are using the Simulink Arduino Support Package with the "Deploy to Hardware" button. To get an accurate and quick response, please contact our Technical Support.

Thanks,

Menghan

Luo Yuxuan

Hi Menghan,

I am having the same problem with the others. I am using Arduino Due and running MATLAB 2014a on a Win10 PC. My Arduino board works with IDE. Yet, when I try to "Deploy to Hardware", it says "arm-none-eabi-gcc.exe has stopped working". I wonder if there is some path conflicts or so.

When I use "getenv('PATH')" command, it returns:
ans =
C:\ProgramData\Oracle\Java\javapath;C:\Windows\System32;C:\WINDOWS;C:\WINDOWS\system32\wbem;E:\Altium Designer\System;C:\WINDOWS\system32;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Symantec\VIP Access Client\;E:\MATLAB\runtime\win64;E:\MATLAB\bin;E:\MATLAB\polyspace\bin;E:\Cadence\SPB\openaccess\bin\win32\opt;E:\Cadence\SPB\tools\capture;E:\Cadence\SPB\tools\pspice;E:\Cadence\SPB\tools\specctra\bin;E:\Cadence\SPB\tools\fet\bin;E:\Cadence\SPB\tools\libutil\bin;E:\Cadence\SPB\tools\bin;E:\Cadence\SPB\tools\pcb\bin;E:\ModelSim\win64

Could you please kindly help me out? Thank you!

Menghan

Hi Aghil,

If you are using the Image Acquisition Toolbox Support Package for Kinect For Windows Runtime, please post your question here,

http://www.mathworks.com/matlabcentral/fileexchange/40445-image-acquisition-toolbox-support-package-for-kinect-for-windows-runtime

For faster and better response, contact MathWorks Technical Support here,

http://www.mathworks.com/support/contact_us/

Thanks,

Menghan

(MATLAB Hardware Team - MathWorks)

i have problem in installing kinect run time software package,currently i am using matlab2013a.
when i try to download that support package,downloading of the software doesnot completes(its in half way),even when i kept for hours
please help me out

Rajan Chalotra

Rajan Chalotra (view profile)

mamu

mamu (view profile)

Hi Menghan,

thank you, it works!!

Max

Menghan

Hi Max,

The Firmata library you installed or downloaded in C:\Users\Max\Documents\Arduino\libraries\ is taking precedence over the default shipping Firmata library in C:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\libraries.

Can you move the first Firmata library to another location or rename it temporarily and then try to call arduino again?

Menghan

mamu

mamu (view profile)

Hi Menghan,
thanks for your response.
Unfortunately none of the troubleahooting advices could help me.

Here is the result of the "need more held" section:
Vendor returned error messages:
Verwende die Bibliothek Firmata im Ordner: C:\Users\Max\Documents\Arduino\libraries\Firmata
Verwende die Bibliothek MWArduino im Ordner:
C:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\libraries\MWArduino (legacy)
Verwende die Bibliothek Wire im Ordner:
C:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
Verwende die Bibliothek SPI im Ordner:
C:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
Verwende die Bibliothek Servo im Ordner:
C:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\libraries\Servo

C:\MATLAB\SupportPackages\R2015b\arduino-1.6.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -w
-fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
-mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\cores\arduino
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\variants\standard
-IC:\Users\Max\Documents\Arduino\libraries\Firmata
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\libraries\MWArduino
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\libraries\Servo\src
C:\Users\Max\AppData\Local\Temp\ArduinoServer\MW\ArduinoServer.cpp -o
C:\Users\Max\AppData\Local\Temp\ArduinoServer\MW\ArduinoServer.cpp.o
C:\MATLAB\SupportPackages\R2015b\arduino-1.6.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -w
-fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
-mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\cores\arduino
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\variants\standard
-IC:\Users\Max\Documents\Arduino\libraries\Firmata
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\libraries\MWArduino
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\libraries\Servo\src
-IC:\Users\Max\Documents\Arduino\libraries\Firmata\utility
C:\Users\Max\Documents\Arduino\libraries\Firmata\Firmata.cpp -o
C:\Users\Max\AppData\Local\Temp\ArduinoServer\MW\Firmata\Firmata.cpp.o
C:\MATLAB\SupportPackages\R2015b\arduino-1.6.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -w
-fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
-mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\cores\arduino
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\variants\standard
-IC:\Users\Max\Documents\Arduino\libraries\Firmata
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\libraries\MWArduino
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\libraries\Servo\src
-IC:\Users\Max\Documents\Arduino\libraries\Firmata\utility
C:\Users\Max\Documents\Arduino\libraries\Firmata\utility\EthernetClientStream.cpp -o
C:\Users\Max\AppData\Local\Temp\ArduinoServer\MW\Firmata\utility\EthernetClientStream.cpp.o
C:\MATLAB\SupportPackages\R2015b\arduino-1.6.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -w
-fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
-mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\cores\arduino
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\variants\standard
-IC:\Users\Max\Documents\Arduino\libraries\Firmata
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\libraries\MWArduino
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\libraries\Wire
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\hardware\arduino\avr\libraries\SPI
-IC:\MATLAB\SupportPackages\R2015b\arduino-1.6.1\libraries\Servo\src
-IC:\Users\Max\Documents\Arduino\libraries\Firmata\utility
C:\Users\Max\Documents\Arduino\libraries\Firmata\utility\SerialFirmata.cpp -o
C:\Users\Max\AppData\Local\Temp\ArduinoServer\MW\Firmata\utility\SerialFirmata.cpp.o
In file included from
C:\Users\Max\Documents\Arduino\libraries\Firmata\utility\SerialFirmata.cpp:20:0:
C:\Users\Max\Documents\Arduino\libraries\Firmata\utility\SerialFirmata.h:30:28: fatal error:
SoftwareSerial.h: No such file or directory
#include <SoftwareSerial.h>
^
compilation terminated.
Fehler beim Kompilieren.

mamu

Menghan

Hi mamu,

Have you tried looking at the troubleshooting documentation page here,

http://www.mathworks.com/help/supportpkg/arduinoio/troubleshooting-in-matlab-support-package-for-arduino-hardware.html

If none of them works for you, please look at the 'Need More Help' section and post your trace output.

Menghan
(MATLAB Hardware Team - MathWorks)

mamu

mamu (view profile)

Hello Menghan,
when I try to connect Matlab to my arduino i get this:
"Cannot program board Uno (COM4). Please make sure the
board is supported and the port and board type are
correct."
Can you help me?

Menghan

Hi Tom,

Thanks for reporting this issue. This happens due to a source file change from Adafruit about a month ago. The solution mentioned in the link should work for all releases. Meanwhile, we are working on updating the support package to fix it.

Menghan

bram verhelst

Dear Menghan,

Thanks for the help but just found the solution to my problem!

For the people who are experiencing the same problem like I did please visit this link: http://www.mathworks.com/matlabcentral/answers/268379-i-can-t-connect-my-adafruit-motorshield-v2-3-with-matlab2014a#comment_343753

all the best!
Tom

bram verhelst

Dear Menghan,

this is what I got:

In file included from C:/Users/Tom/AppData/Local/Temp/ArduinoServer/Dynamic.cpp:1,
from C:/MATLAB/SupportPackages/R2015a/arduinoio/toolbox/matlab/hardware/supportpackages/arduinoio/src/MWArduino.cpp:488:
C:/MATLAB/SupportPackages/R2015a/arduinoio/toolbox/matlab/hardware/supportpackages/arduinoio/+arduinoioaddons/+adafruit/src/MotorShieldV2Base.h:7:37:
error: Adafruit_PWMServoDriver.h: No such file or directory
make: *** [C:/Users/Tom/AppData/Local/Temp/ArduinoServer/MWArduino.cpp.o] Error 1

But then I got a solution which was posted here and changed that filename in the files described: http://www.mathworks.com/matlabcentral/answers/268379-i-can-t-connect-my-adafruit-motorshield-v2-3-with-matlab2014a#comment_343753

But now it gets stuck somewhere else when I run your command sadly enough:
C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/libraries/Adafruit_MotorShield/Adafruit_MotorShield.cpp -o
C:/Users/Tom/AppData/Local/Temp/ArduinoServer/Adafruit_MotorShield.cpp.o
make: *** No rule to make target `C:/Users/Tom/AppData/Local/Temp/ArduinoServer/Adafruit_PWMServoDriver.cpp.o', needed by
`C:/Users/Tom/AppData/Local/Temp/ArduinoServer/ArduinoServer.elf'. Stop.

Thank you for looking at this!

best wishes

Menghan

Hi Tom,

Can you run this command to turn on the trace?

a = arduino('COM3','Uno','Libraries','Adafruit/MotorShieldV2', 'TraceOn', true)

You shall see a lot more messages at the command prompt. Can you send me the errors that you see?

Menghan
(MATLAB Hardware Team - MathWorks)

Andrea Libri

Excellent!

bram verhelst

Dear Menghan,

looks like you know a lot on this, maybe you could help me too?
I am unable to update the motorshieldv2 library to the arduino. However with the arduino IDE it works fine.

When I connect to the Arduino just by a=arduino() it works, also with specifying the com and board type. Moreover it still works if I include the 'servo' library... but when I try uploading the adafruit/motorshieldv2 library it gives me an error: Cannot program board Uno (COM3). Please make sure the board is supported and the port and board type are correct. (by the way the workspace was cleared before launching the last command in the picture below)

I am using Matlab R2015a with windows10 and the hardware support package for arduino is installed.
thanks
Tom

Menghan

Hi Rahul,

What error are you seeing? Which operating system do you use?

Menghan
(MATLAB Hardware Team - MathWorks)

Rahul Mahadik

can anyone please upload the folder? I am unable to install it automatically. Some error is always encountering. It will be a great help. thanks

Menghan

Hi Jarubula,

The support package can only be installed through the support package installer.

May I know what kind of download error you are getting?

Menghan
(MATLAB Hardware Team - MathWorks)

Hi Menghan,

I tried to install arduino support package. Due to some reasons download is getting failed. So i manually downloaded the Arduino-1.6.1-windows.zip IDE file. So I want to know how to install manually with that IDE.

Menghan

Hi reiner,

This support package is introduced in MATLAB in R2014a and onwards. Please upgrade your MATLAB or you can try the legacy support here,

http://www.mathworks.com/matlabcentral/fileexchange/47522-matlab-support-package-for-arduino%C2%AE-hardware

Please note that questions regarding the legacy support shall be asked at its own page.

Hope this helps.

Menghan
(MATLAB Hardware Team - MathWorks)

i am using Matlab2013a and it says "Matlab support package for arduino hardware is not available for the release MATLAB " how can i solve this problem?

Menghan

Hi Dinesh,

Please ask Simulink Arduino support package related questions here,

http://www.mathworks.com/matlabcentral/fileexchange/40312-simulink-support-package-for-arduino-hardware

Menghan
(MATLAB Hardware Team - MathWorks)

Hello. Can someone please help me with "WiFi ThingSpeak Write" simulink block? I have already installed support package for arduino but I am not getting this block. I am using matlab 2013b.

ponnuswamy s

lays25

lays25 (view profile)

Wow, I'm amazed! I uninstalled WinAVR and manually removed the two entries from Windows path. Now I can flawlessly connect to my Arduino just by typing "a = arduino" in the Matlab command prompt.

You're a real lifesaver, cheers! :)

Menghan

These two paths look suspicious to me: C:\WinAVR-20100110\bin;C:\WinAVR-20100110\utils\bin;

Can you try uninstalling WinAVR(if not used) or remove them from your system path temporarily and then execute the same command in MATLAB?

Menghan

lays25

lays25 (view profile)

Hi Menghan,

here is the output of the first command:

>> system('C:\MATLAB\SupportPackages\R2015a\arduino-1.5.6-r2\hardware\tools\g++_arm_none_eabi\bin\cs-make -f C:\Users\maciej\AppData\Local\Temp\ArduinoServer\ArduinoServer.mk')

C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/tools/g++_arm_none_eabi/bin/arm-none-eabi-gcc -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/system/libsam" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/system/CMSIS/CMSIS/Include" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/system/CMSIS/Device/ATMEL" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/cores/arduino" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/cores/arduino/USB" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/variants/arduino_due_x" -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000 -DARDUINO=156 -D__SAM3X8E__ -mthumb -DUSBCON -DARDUINO_ARCH_SAM C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/cores/arduino/WInterrupts.c -o C:/Users/maciej/AppData/Local/Temp/ArduinoServer/WInterrupts.c.o
In file included from C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/cores/arduino/WInterrupts.h:22,
from C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/cores/arduino/WInterrupts.c:19:
C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/cores/arduino/Arduino.h:31: fatal error: avr/pgmspace.h: No such file or directory
compilation terminated.
cs-make: *** [C:/Users/maciej/AppData/Local/Temp/ArduinoServer/WInterrupts.c.o] Error 1

ans =

2

As far as I can tell, it seems to return exactly the same error as before.

Here is the second one:

>> getenv('PATH')

ans =

C:\Perl\site\bin;C:\Perl\bin;C:\Program Files (x86)\M1 Licensing;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Common Files\ArchestrA\;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\EAGLE-6.5.0\lbr\com;C:\WinAVR-20100110\bin;C:\WinAVR-20100110\utils\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files (x86)\Common Files\Ulead Systems\MPEG;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;D:\programy\MATLAB\R2015a\runtime\win64;D:\programy\MATLAB\R2015a\bin;D:\programy\MATLAB\R2013b\runtime\win64;D:\programy\MATLAB\R2013b\bin;C:\Program Files\OpenVPN\bin;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files (x86)\Skype\Phone\X;D:\programy\Proficy iFIX;D:\programy\MATLAB\R2013b\polyspace\bin;D:\programy\MATLAB\R2015a\polyspace\bin;C:\Program Files (x86)\Skype\Phone\;

Can you see if there's anything essential missing from the path?

Menghan

Hi lays25,

Can you also try this command in MATLAB?
system('C:\MATLAB\SupportPackages\R2015a\arduino-1.5.6-r2\hardware\tools\g++_arm_none_eabi\bin\cs-make -f C:\Users\maciej\AppData\Local\Temp\ArduinoServer\ArduinoServer.mk')

Besides, what does getenv('PATH') return in MATLAB?

Menghan

lays25

lays25 (view profile)

Hi Menghan,

I tried running the command from the Windows command prompt and got no output, no error either, so I figure it compiled with no problems. I also used the "system" command from within Matlab with the same result (got "ans = 0"), no errors.

Which path variable could be causing this discrepancy?

Menghan

Hi lays25, something may be conflicting with your path, either system path or MATLAB path. Can you execute the same command in a Windows shell?(from right after Vendor returned error messages to WInterrupts.c.o and make sure it is in one line).

Also, try executing the same command in MATLAB using system function.

Let me know the results.

lays25

lays25 (view profile)

Hi Menghan,

Here is the trace you requested.

>> a = arduino('COM14','Due','TraceOn', true)
Updating server code on board Due (COM14). Please wait.
Vendor returned error messages:
C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/tools/g++_arm_none_eabi/bin/arm-none-eabi-gcc
-I"C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/system/libsam"
-I"C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/system/CMSIS/CMSIS/Include"
-I"C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/system/CMSIS/Device/ATMEL"
-I"C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/cores/arduino"
-I"C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/cores/arduino/USB"
-I"C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/variants/arduino_due_x" -c -g -Os -w
-ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -mcpu=cortex-m3
-DF_CPU=84000000 -DARDUINO=156 -D__SAM3X8E__ -mthumb -DUSBCON -DARDUINO_ARCH_SAM
C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/cores/arduino/WInterrupts.c -o
C:/Users/maciej/AppData/Local/Temp/ArduinoServer/WInterrupts.c.o
In file included from
C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/cores/arduino/WInterrupts.h:22,
from
C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/cores/arduino/WInterrupts.c:19:
C:/MATLAB/SupportPackages/R2015a/arduino-1.5.6-r2/hardware/arduino/sam/cores/arduino/Arduino.h:31:
fatal error: avr/pgmspace.h: No such file or directory
compilation terminated.
cs-make: *** [C:/Users/maciej/AppData/Local/Temp/ArduinoServer/WInterrupts.c.o] Error 1

This doesn't make much sense to me since I can clearly see that the file "avr/pgmspace.h" is there and the permissions are alright (Matlab is run as administrator).

Menghan

Hi lays25,

Can you try the following command and send me the log including all texts print out in the command prompt?
a = arduino('COM11','Due','TraceOn', true)

Menghan,
(MATLAB Hardware Team - MathWorks)

lays25

lays25 (view profile)

Hi Wael,

yes, the board works from the Arduino IDE. The USB cable is plugged into the Programming port. I tried downloading Arduino software and updating the drivers but they were supposedly already up to date however I did update the so-called Bossa Program Port after plugging the USB cable into the Native port of the Due.

Nevertheless, it's not working in Matlab, even though I can deploy Simulink models to the board, of course using the Programming port.

Hi lays25,

Does your Arduino Due board work from the Arduino IDE?

Make sure you connect your USB cable to the programming port on the Arduino Due (closest to the DC jack).

If it's still not working, you can try updating the drivers.
http://www.mathworks.com/help/supportpkg/arduinoio/ug/cannot-auto-detect-arduino-device.html

Let me know if that helps.

Regards,
Wael
(MATLAB Hardware Team - MathWorks)

Ankit Desai

Ankit Desai (view profile)

lays25

lays25 (view profile)

Hi, I am using Matlab 2015a and Arduino Due. I have installed all available Arduino support packages and I can successfully connect to the board through Simulink using External mode.

However, when I try to connect from the Matlab command window by entering "a = arduino('com11', 'due')", I get the following message:

Updating server code on board Due (COM11). Please wait.
Cannot program board Due (COM11). Please make sure the board is supported and the port and board type are correct.

Now I know for sure that the port is correct and the board is not faulty since my professor was able to connect to it on his laptop with Matlab 2015b, both through Simulink and Matlab command window.

What can I do to solve this problem?

Dennis

Dennis (view profile)

Excellent!

This package is awesome because you can either use the Arduinos as in-/output for Simulink sketches or directly run the Simulink sketches on the Arduino (external mode only with Arduino MEGA and DUE). It is just a button to press to achieve all of that, which is essential for Students and other newbies. Also: You don't need MATLAB coder, which is expensive and not available for standard student versions.

(I am using MATLAB 2015a and both external mode on the Mega and DUE worked.)

Help!!! I get this error "The specified key is not present in this container." when I try to install or re-install support package.

I like to know more to work with matlab and arduino interface development

William

I am having the exact same issue as Youbin Kim on OSX Yosemite. The latest version of this code looks like it might be corrupted---the zip file cannot unpack. I was able to successfully manually install by downloading a mirror of an older version from here:
http://blog.spitzenpfeil.org/arduino/mirror_released/

Youbin Kim

I keep getting an error during install. It says it can't unzip the "arduino-1.5.6-r2-macosx.zip" file. I have tried manually unzipping it as well and it doesn't work. I've tried downloading the package and installing separately as well. Help would be appreciated.

Hello,

I can't install the support packet. I get always the message that I have to log on, when I try to log on, I get always the message "An error has occurred", although the email and the password are correct, do you have any idea what is the reason and what I can do?

Hi Renato,

Were you able to install the package successfully? We have not seen this issue before. Can you give us a little more information with MATLAB release number? Also, do you have any other support packages installed? Is this during a reinstall or a fresh install?

If you still have the issue, it will also greatly help if you come through MathWorks technical support for us to better help with your problem.

Thanks
Shankar
(MATLAB Hardware Team - MathWorks)

I am trying to install MATLAB Support Package for Arduino but always at the end the following error messages appear:

C:\Users\Renato\AppData\Local\Temp\tp1f22b9b0_c576_4425_b860_3d4e2aeb8a06\simulink could not be removed.
C:\Users\Renato\AppData\Local\Temp\tp1f22b9b0_c576_4425_b860_3d4e2aeb8a06 could not be removed.

I manually remove the files and try again the installation but the error message appears again.

Has someone any idea about what I am suppose to do?

Thanks

Sergei P.

Sergei P.

Hsin Nan Lin

I can't download.
It pops up the error "Expected input to be nonempty."

Please help me out.

Menghan

Hi Noufal,

Do you see this error consistently? Sometimes, the Arduino server may not be available, you may try to download the support package at a different time if you have not done so.
If the above does not help, can you please let us know more information including your MATLAB version, your region(which may affect server access and download speed).

Thanks,
Menghan Jin
Software Engineer
MathWorks

John Gatlin

When I first installed this package, a very useful documentation help file popped up. However, I cannot seem to locate it again. How can I access the help file?

Hi
When I try to install, the following dialog comes:-

Download Failed: Server returned HTTP response code: 503 for URL: http://downloads.arduino.cc/arduino-1.5.6-r2-windows.zip?

Plz help.

Hi
The MATLAB Support Package for Arduino® Hardware still can't Installed on my computer(2014a)
and support package For Total Phase Aardvark can't downloud.( http://cn.mathworks.com/hardware-support/i2c-interface.html )

Menghan

Hi,

The support package cannot be obtained through a regular browser. It can only be downloaded through the Support Package Installer in MATLAB and the installer needs Internet access.

If you have another computer at home or your personal laptop on which MATLAB does have Internet access, you can download the support package there using "Download From Internet" option in the installer. Then, copy the downloaded files into your university's computer, choose "Install From Folder" option and use the path of the folder which contains the files.

Hope this helps.

Menghan Jin
Software Engineer
MathWorks

already

Very annoying that this package can only be obtained through Matlab application itself. I'm trying to work with Arduinos and Matlab in my university but Matlab is not allowed to make connection to internet (not allowed by university guidelines), so I have no idea how to get this support package.

Is there any solution to get this package through a standarf browser?

already

John Hedengren

John Hedengren (view profile)

We used MATLAB and an Arduino UNO (Ruggediuno) for our process control lab starting in 2013. We were able to build 40 lab kits for ~$50 each and distribute them to students. Below is a link to our source code for the lab.

https://www.mathworks.com/matlabcentral/fileexchange/48016-arduino-matlab-process-control-lab

The lab is featured in the December issue of CACHE news. The article includes a number of lessons learned with regards to improving student experience. It was a positive experience the second year (2014) after we worked out some important details.

http://apmonitor.com/che436/uploads/Main/Hands_on_Process_Control_CACHE.pdf

We're interested in continuing to improve the Arduino lab. Please contact me with any suggestions on additional modules related to Process Dynamics and Control: john.hedengren@byu.edu.

Kenan

Kenan (view profile)

Hey Jason,

Same problem here for me too. I can't properly see a 50 Hz sine wave with this package or with the other ArduinoIO Package(Simulink).
It's really annoying that a capable microprocessor card can't see the waves that has greater frequency than 25 Hz.

You found any solutions to this problem ?
Thanks

Eduardo

Whenever I try to connect it to the arduino I receive the following message:

EDU>> a = arduino();
Updating server code on Arduino Uno (COM5). Please wait.
Cannot program Arduino board Uno (COM5). Please make sure the board is supported and the port and board type are correct.

Any suggestions?

James

James (view profile)

Works well. Had no issues installing.

Neil

Neil (view profile)

Also getting a 403 error, does not appear to be fixed yet

Mat

Mat (view profile)

Getting a 403 error now.

Menghan

The download issue is caused by the fact that Arduino team has changed their download link for the version of IDE we use. The issue has been fixed already. Please try installing the support package again.
Please also feel free to contact our Technical Support for any other technical questions you may have with the support package.

Thanks.

Daniel

Daniel (view profile)

Any fix for download fail error?

Wolfgang

The installer hangs upon trying to download the arduino software.
ERROR: Download failed : Server returned HTTP response code: 404 for URL: http://download.arduino.cc/arduino-1.5-6-r2-windows.zip.
Apparently, the support package installer tries to download a zip file for the 1.5.6-r2 beta release. However, the current beta release is 1.5.8 (11/10/2014), and the arduino download server denies access to earlier betas.

Jason Chen

Mathworks states that the Matlab support package is not real time and the loop time can't be less than 40 ms (25 Hz). I'm using an Arduino for a real time application and like to transfer data to the computer to display later. I hope the serial data buffer can catch the data at faster rate.

I tried the Simulink Arduino support package. It doesn't work well in external mode either, especially for Due.

How can the default baud rate change?

Patreze

Updates

Updated file for initial release.

MATLAB Release
MATLAB 8.3 (R2014a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video