Using "serial" to connect to an Arduino
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Thomas Ibbotson
el 4 de En. de 2012
Respondida: Bagus Tris Atmaja
el 7 de Feb. de 2015
I got an Arduino for xmas, and I'm trying to talk to it from MATLAB (R2012a prerelease) via the serial interface. I'm not having any luck at the moment, I can talk to it from python no problem. Here's what I've got:
>> s = serial('/dev/ttyACM0', 'BaudRate', 9600);
>> fopen(s)
Error using serial/fopen (line 72)
Open failed: Port: /dev/ttyACM0 is not available. Available ports: /dev/ttyS0.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.
But in ipython:
In [1]: import serial
In [2]: s = serial.Serial('/dev/ttyACM0', 9600)
In [3]: s.readline()
Out[3]: '408\r\n'
I've tried '/dev/ttyS0' and made sure I closed old connections, but I still get this error. I've run out of ideas, anyone have suggestions?
Respuesta aceptada
Más respuestas (4)
Walter Roberson
el 4 de En. de 2012
Is ttyACM0 a virtual USB port? If so then the device needs to be connected when you start MATLAB, as MATLAB only scans the device table once.
Jan
el 19 de Abr. de 2012
i got the same problem. using ubuntu 11.10 and matlab 2010b with arduino ide 1.0
in which folder do i have to put the java.opts file?
/usr/local/MATLAB/R2010b/ ?
2 comentarios
Bagus Tris Atmaja
el 7 de Feb. de 2015
I have same problem with Matlab 2013 in Ubuntu 14.04. When I try fnd info from serial port, it is live,
>> instrhwinfo('serial')
ans =
AvailableSerialPorts: {'/dev/ttyS101'}
JarFileVersion: 'Version 3.3'
ObjectConstructorName: {'serial('/dev/ttyS101');'}
SerialPorts: {'/dev/ttyS101'}
but, when I connect it with arduino (using ArduinoIO package),
>> a=arduino('/dev/ttyS101');
Attempting connection .............
Warning: Unsuccessful read: A timeout occurred before the Terminator was reached.
Error using arduino (line 104)
Connection unsuccessful, please make sure that the board is powered on, running a
sketch provided with the package, and connected to the indicated serial port. You
might also try to unplug and re-plug the USB cable before attempting a
reconnection.
Any idea? I guess the error from ArduioIO package
0 comentarios
Ver también
Categorías
Más información sobre MATLAB Support Package for Arduino Hardware en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!