false

Arduino IDE is nice for start but after sometime it becomes very limited. I’m fan of the Atom editor and i wanted to use it with Arduino. It turned that Arduino IDE 1.5+ supports terminal commands. You can find manpage on github. Unfortunately it don’t support serial monitor but we can use picocom.

Instalation

First we need to install picocom:

sudo apt-get install picocom

Next we install Arduino IDE 1.5+:

cd /tmp
wget http://downloads.arduino.cc/arduino-1.5.7-linux64.tgz
tar -zxvf arduino-1.5.7-linux64.tgz
mv arduino-1.5.7 ~/arduino-ide
chmod +x ~/arduino-ide/arduino
ln -s ~/bin/arduino ~/arduino-ide/arduino

Now you should get arduino IDE after typing arduino in console.

Simple Hello World from console

Lets create directory for new sketch.

mkdir hello_world

In hello_world/hello_world.ino with content:

void setup() { Serial.begin(9600); } void loop() { Serial.println("Hello world!"); delay(1000); }

First let check if sketch is valid:

arduino hello_world/hello_world.ino --verify
Sketch uses 2,080 bytes (6%) of program storage space. Maximum is 32,256 bytes. Global variables use 202 bytes (9%) of dynamic memory, leaving 1,846 bytes for local variables. Maximum is 2,048 bytes.

To upload sketch to arduino we need to pass –upload flag:

arduino hello_world/hello_world.ino --verify --upload

Our sketch will be uploaded onto arduino board. Now we can look at serial output using picocom. My arduino is connected on /dev/ttyUSB0

picocom /dev/ttyUSB0 -b 9600 -r -l
picocom v1.7 port is : /dev/ttyUSB0 flowcontrol : none baudrate is : 9600 parity is : none databits are : 8 escape is : C-a local echo is : no noinit is : no noreset is : yes nolock is : yes send_cmd is : sz -vv receive_cmd is : rz -vv imap is : omap is : emap is : crcrlf,delbs, Terminal ready Hello world! Hello world!

You should now see “Hello World” printed on screen.

One line command

We can combine everything in one command like this:

arduino [sketch_file] --upload --verify && picocom [USB port] -b [baudrate] -r -l
Sketch uses 2,080 bytes (6%) of program storage space. Maximum is 32,256 bytes. Global variables use 202 bytes (9%) of dynamic memory, leaving 1,846 bytes for local variables. Maximum is 2,048 bytes. picocom v1.7 port is : /dev/ttyUSB0 flowcontrol : none baudrate is : 9600 parity is : none databits are : 8 escape is : C-a local echo is : no noinit is : no noreset is : yes nolock is : yes send_cmd is : sz -vv receive_cmd is : rz -vv imap is : omap is : emap is : crcrlf,delbs, Terminal ready Hello world! Hello world!

Comments

disqus_RGZVojfncG on August 25, 2015 07:33

Thanks a lot your contribution ! But since version arduino-1.6.5 it seems that Arduino cannnot support for this kind of compilation, maybe I'm wroong, but it products some error in the console like this : [email protected] ~ $ ~/arduino-ide/arduino ~/test_uno/Blink/Blink.ino --verify/home/pi/arduino-ide/arduino: line 36: ./java/bin/java: cannot execute binary file