Arduino IDE not connecting to microcontroller
I get this error when trying to connect to an Arduino through a USB serial connection. I'm using the Arduino IDE 1.0.1 and the 64bit version of Ubuntu 12.04. This has been a reoccurring problem since 10.04 and happens to a few other programs that use a serial connection too. I have no problem getting serial data from the Arduino using Python or Screen. The Arduino IDE seems to work just fine otherwise.
processing.app.SerialException: Error opening serial port '/dev/ttyACM0'.
at processing.app.Serial.<init>(Serial.java:178)
at processing.app.Serial.<init>(Serial.java:92)
at processing.app.SerialMonitor.openSerialPort(SerialMonitor.java:207)
at processing.app.Editor.handleSerial(Editor.java:2447)
at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:353)
at java.awt.Component.processMouseEvent(Component.java:6386)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3268)
at java.awt.Component.processEvent(Component.java:6154)
at java.awt.Container.processEvent(Container.java:2045)
at java.awt.Component.dispatchEventImpl(Component.java:4750)
at java.awt.Container.dispatchEventImpl(Container.java:2103)
at java.awt.Component.dispatchEvent(Component.java:4576)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4633)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4294)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4227)
at java.awt.Container.dispatchEventImpl(Container.java:2089)
at java.awt.Window.dispatchEventImpl(Window.java:2518)
at java.awt.Component.dispatchEvent(Component.java:4576)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:672)
at java.awt.EventQueue.access$400(EventQueue.java:96)
at java.awt.EventQueue$2.run(EventQueue.java:631)
at java.awt.EventQueue$2.run(EventQueue.java:629)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116)
at java.awt.EventQueue$3.run(EventQueue.java:645)
at java.awt.EventQueue$3.run(EventQueue.java:643)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:642)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
Caused by: gnu.io.UnsupportedCommOperationException: Invalid Parameter
at gnu.io.RXTXPort.setSerialPortParams(RXTXPort.java:171)
at processing.app.Serial.<init>(Serial.java:163)
... 35 more
I had this problem too, it turns out it was caused by the Serial Monitor being set to speed 14400. Since you can't change the setting without having a working serial port, the only way to do it is to exit the Arduino UI and edit the preferences.txt file (in Unix, it's in ~/.arduino/preferences.txt
). Look for Serial.debug_rate
and change it to 9600
. Restart the Arduino UI and try uploading a simple sketch (eg. 'blink') and see if it's fix the problem.
I'm not sure why this would happen - I've used 14400 and never had a problem. I guess it's just one of those weird problems that never seems to have a repeatable reason?
I was having the same error. As far as I can tell, this is a permissions problem. The problem no longer occurred when I ran the Arduino IDE with root permissions. That is, I ran it as:
sudo ./arduino
I know this is a bad solution, but for now it works. I tried adding read/write access to the serial device file as mentioned in https://wiki.archlinux.org/index.php/arduino, but this had no effect, and still caused the error if I tried running it without root permission. I'm still looking for a better solution.
EDIT :
This problem has been fixed by following the answer given in https://askubuntu.com/a/58122/206687. In short, if you add yourself to the dialout
group, the problem should get fixed.
sudo usermod -a -G dialout $USER
Just logout and log back in again after running this command, and you should be able to access the serial port without any problems.