File Exchange

image thumbnail

Arduino Serial Data Acquisition

version (522 KB) by Ye Cheng
Use serial communication to monitor live data from Arduino in MATLAB/Simulink


Updated 28 Nov 2016

View License

Do you want to monitor live data from Arduino® in MATLAB® and Simulink®?
-You can do so easily with Simulink External Mode if you use Arduino Mega 2560 and Arduino Due (and Arduino Uno if you have R2016b or later).
What if you use Arduino Uno?
-This File Exchange download will help you do exactly that.

This submission contains three files:
-serialRunOnArduino.slx: Download this model onto your Arduino board so that it sends data to serial port
-serialRunOnPC.slx: Run this model locally on your PC to collect and plot serial data in Simulink
-readArduinoSerial.m: Run this script to read and plot serial data in MATLAB

Cite As

Ye Cheng (2020). Arduino Serial Data Acquisition (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (41)

Jen Kong

Very nice and simple! I was just wondering, what does the gain block do between the analogue input and the serial port?

Hamza Khan

i can log xbee rssi data being printed on the serial monitor of arduino ide in matlab. works like a charm

The code run slowly: a optimization on the computationla time is required in my opinion.

samio roi


Very good.
Can I use this model to acquire 3- 6 sensors data from Arduino uno R3 into MATLAB for real time analysis? How?

Son Tran

Wow, this's so good

I'm facing this error [ Download Failed: Received fatal alert: protocol_version ] every time i'm trying to install or download [ Arduino Support Package for MATLAB R2014b ] .is there any possible way to solve this problem ? ,i appreciate your help.
Thanks in advance


pretty good!! i use arduino uno .it works well! thank you!

Works well !!! Grate!!

Nice Submission, now no need of logging data via SD card shield.

Jacky Chan

Hi, I want to output the data from IMU. However, as you know, there are several types of data generating from the IMU, what should I do if I want to specially output a type of data, let's say acceleration. Thank you very much.

Ahh...... Thanks it worked..... really thanks GOD bless you

Question: In order to run this Math Arduino DAQ, do I need always MathLab running under Windows and Arduino connect it to Lap Top or PC? If the answer is YES, LOL. We need some small foot print DAQ for embedded applications...



work with lenardo. Thanks

cris ponce




Works perfectly

hi, at first thanks for your tutorial, it works, but with no results! I'm using GP2D120 IR-range-finder sensor and i don't know to connect the output signal sensor to witch pin in Arduino board.
thanks again for share this tutorial.

when i try to run the serialRunOnArduino via run on Target Hardware on my Arduino Uno, i get
"Call to the function 'getTflTableList' failed."
I am using R2012b



I use R2015b and yun Arduino and the sample does not work out. Just out symbols like . It will be some limitation of Arduino Yun? The R2015b is the one that support ...

OK, now I understand that it is because uint8 can represent a maximum value of 2^8 = 256, hence the 1/4 gain block in the Simulink model. It has nothing to do with sample time.

My sensor output is in the range of 600-850 but the values read in are sample time dependent - when I used the default one (0.02s) the output was extraordinarily high (1e30 etc.) and when I used a sample time of 1s the output was lower (about 80). Any suggestions for getting the exact value in Simulink?

Great...!!! works

Thanks a lot

kaveh dehno


It works on my Leonardo, but gives me none sense data. I'm able to get the right data from Arduino serial monitor as well as the Mac Terminal.


Graham Lee

Worked with my UNO, and has an easy-to-follow setup guide. Great work, thanks!


Very helpful - got me up and running immediately. Thanks for sharing.


It was only thanks to this submission that I understood data transmission on Arduino!

When trying this on the arduino uno, I get the following error when I try to run on target hardware: CRL: “None” cannot be found in the registry.


The program shows 'catch err' error on line number 9.That's the only error that comes up.Please help me fix this.Thank you.


Minor link update in description. No change in file.

Updated license

Minor trademark adjustment.

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: LiveSerialPlot