Arduino Due USBSerial and MATLAB

Hi all,

I recently switched from the Arduino Duemilanove to the Arduino Due. My Duemilanove setup was able to send data to MATLAB over the serial port. I'm now trying to do the same thing with the Due using the native USB port. In the Arduino code I changed "serial" to "serialUSB", and when I look at the data in the serial monitor it looks perfectly fine. BUT... MATLAB is not able to read the data although I'm using exactly the same MATLAB code.

Does anyone know what I'm missing? Thanks in advance!

...
SerialUSB.begin(115200);
while(!SerialUSB);
...
SerialUSB.println((char)'S'); // Send capital S
SerialUSB.println(sampleTime,DEC);
SerialUSB.println(adcValue,DEC);
...
...
% Configure serial communication
s1 = serial('/dev/ttyACM0');
s1.BaudRate = 115200;
set(s1,'terminator','LF');
fopen(s1);
...
while fscanf(s1,'%s') ~= 'S' end % Wait for capital S
time(sampleNr,1) = fscanf(s1,'%f')/1000; % Float
signal(sampleNr,1) = fscanf(s1,'%i'); % Int
...

So after a while I found the solution…

Arduino, STM32 Nucleo boards and so on create a /dev/ttyACM0 in linux, so to connect to it using serial(‘/dev/ttyACM0′) you need to tell matlab that this is another serial port. In your home directory (or whatever working directory matlab starts in) create java.opts file with:

-Dgnu.io.rxtx.SerialPorts=/dev/ttyS0:/dev/ttyS1:/dev/USB0:/dev/ttyACM0

Hey, lotte1990!
Can I have your full code,
trying to do the same))

Thanks in advance!