Using the Arduino tools from the Linux command line


I’m not a huge fan of GUI tools, my workflow is mostly on the commandline. As such, I find the standard Arduino interface a bit painful, so I figured it was time to figure out how to get this working on the commandline. Historically, there have been a number of alternatively, the Arduino tools themselves are of course a wrapper round avrdude, so it’s possible to use that directly. There have also been other projects such as inotools, and sets of Makefiles which will work against Arduino ino files. However with version 1.5 of the Arduino tools command line support has been introduced natively.

Debian Jessie, unfortunately doesn’t appear to have 1.5 in it’s repository (it is after all still in beta). So you’ll need to download it. You can download the latest Beta here (1.5.8 at the time of writing).

First of all if you have the arduino package installed, you should probably remove it (apt-get remove arduino). You can then install the new arduino tools, for example (make sure you have a /opt directory):

tar zvxf arduino-1.5.8-linux64.tgz
sudo mv arduino-1.5.8 /opt/
sudo ln -s ./arduino-1.5.8 ./arduino
echo "PATH=\$PATH:/opt/arduino" >> ~/.bashrc
sudo sh -c 'echo "PATH=\$PATH:/opt/arduino" >> /root/.bashrc' # if you want it in the root path

You will need to restart your terminal to pickup the new arduino path. (note sudo arduino wont work, because sudo on Debian defaults to using “secure_path” for the path, you need to use sudo -i arduino). You can then upload a sketch from the commandline as follows:

sudo -i arduino --upload /home/new/gitcode/arduino_snmp/arduino_snmp.ino --port /dev/ttyACM0

You may, or may not need to use the full path, or specify the port/other configuration info. The tool is supposed to retain the port configuration set in the UI. A full list of command line options is available here.