Arduino Gets A Command Line Interface

When using an Arduino, at least once you’ve made it past blinking LEDs, you might start making use of the serial connection to send and receive information from the microcontroller. Communicating with the board while it’s interacting with its environment is a crucial way to get information in real-time. Usually, that’s as far as it goes, but [Pieter] wanted to take it a step farther than that with his command line interpreter (CLI) for the Arduino.

The CLI allows the user to run Unix-like commands directly on the Arduino. This means control of GPIO and the rest of the features of the microcontroller via command line. The CLI communicates between the microcontroller and the ANSI/VT100 terminal emulator of your choosing on your computer, enabling a wealth of new methods of interacting with an Arduino.

The CLI requires a hex file to be loaded onto the Arduino that you can find at a separate site, also maintained by [Pieter]. Once that’s running, you can get all of that sweet command line goodness out of your Arduino. [Pieter] also has some examples on his project page, as well as the complete how-to to get this all set up and running. There’s a lot going on in the command line world, in Linux as well as windows. So there’s plenty to explore there as well.

52 thoughts on “Arduino Gets A Command Line Interface

      1. Yes, that’s a what I was thinking; it’s just like a bus pirate, but without having to buy a separate bus pirate board…. and without having to keep the manual open in another window to decipher the UI.

        Altogether, probably a lot better than a bus pirate.

      1. I thought about it, but the programming style is so much better than mine I’d have to put in a lot of refucktoring work to make the code compatible with my Arduino-C++ gibberish. ;-)

          1. I was not entirely serious. But the code is quite well written. Still, porting it to run on ESP* boards would be a lot of work and I have enough projects lying around half finished, so…

    1. It just so happens that I’m doing exactly that, except I’m using a language called Squirrel. I don’t have UNIX style commands, but I have a REPL for things like pinMode(HIGH); I tried to keep close to the Arduino API as much as is practical in Squirrel. I’ve got SPIFFS working, I have multithreading support, an API to add new commands, and to accept callbacks(In a way that either the Squirrel or the Arduino code can cancel a callback), and I even have some M5Stack LCD routines.

      Now I’m working on python code to let you include Squirrel code as a home automation script on a server that gets automatically loaded, with shared variables and Pysquirrel messaging, as part of the Kaithem for Devices project.

    2. The ESP does have a command line interface using linenoise and arg3table library provided within the esp-idf framework.

      Here is a sample line from an ESP32 project f mine that allows me to test latency by the ping interface:

      ESP32 test console>ping -n -c 10 -t 1 -d 1
      Run ICMP ping test
      -n specify ipV4 ip address in dot notation
      -c 10 specify ping count per analysis
      -t 1 specify timeout in seconds as an integer
      -d 1 specify delay in seconds as an integer

    1. Adafruit Python GPIO library

      To make using the FT232H simpler, Adafruit’s Python GPIO library has been updated to include a simple interface for accessing GPIO, SPI, and I2C on the FT232H with the Python programming language. Using this library you can control the GPIO pins and send or received SPI & I2C commands much like programming those interfaces on a Raspberry Pi or BeagleBone Black. This library is built on top of the libFTDI library and supports Windows, Mac OSX, and Linux platforms.

    1. Such a bizarre question. I mean, perhaps your personal experience to a CLI is limited to DOS, but it was not the first CLI and nowhere near the most popular/common. So why would anyone call it “DOS-Like”?

      Though I’ll admit a Unix tag on this particular post is not really appropriate.

      1. I think the point was that every command line is instantly branded “unix like” even though it got nothing to do with it … there were command line interpeters before unix, and after, unless its doing “unix like” functions its just a command line

      2. Yes! The Unix tag doesn’t make sense here, but I came here because it. I have commented about NuttX that is in fact a sort of Unix/Linux for MCU and way smaller than uClinux and even RetroBSD.

    1. I expect there’s more people out there with Arduinos in their desk drawers than Bus Pirates, so this project would seem pretty attractive. It looks like a great way to understand and troubleshoot interfaces before incorporating a new device into a project.

  1. It’s always great too see innovative development tools but I prefer Forth for its endlessly versatile real time debugging. Here is a screen-pic of my Forth STM32F development system displaying a nicely formatted and labeled view of the RCC_AHBENR register bit values. I can view a similar default (without the unique register names) picture of any of the thousands of registers via a cmsis-svd to Forth parser for Mecrisp-Stellaris Forth I wrote a few years ago.

  2. There is a real Unix-like RTOS for Arduino (Mega or better) and many other STM32 boards, Kinetis Boards, SAM3/4 and SAMV7 boards, Particle Photon board and initial port to ESP32 without WiFi, it is called NuttX RTOS.
    It has something similar i2ctools from Linux, then you search for I2C devices on bus, read/write devices, etc.
    Recently Greg Nutt ported the SPIFFS to it, but I still using SmartFS because I think it has better wear-leveling support. It is worth trying if you are a Unix / Linux Guy.

      1. Hahah, try STMs free Eclipse Java based Atollic TrueStudio with Cube MX. I hear it will run on a low end 24 core Xeon with only 3TB of ram, with system reboots now down to only one a day!

        Disclaimer, I’m a utterly loyal and addicted STM32F fan.

  3. To everyone, thanks for all the kind words! This open source project has been a work of love for more than a decade and it is great motivational fuel when people indicate that they like it and that it matters. Who says there’s no such thing as “free energy” :)

    For the record, the CLI was inspired by u-boot and OpenOCD. I started to create it after needing a way to probe and debug a test fixture (a.k.a. a “bed-of-nails”). I needed an easy way to set a GPIO pin and probe the result on the DUT (Device Under Test) to locate the fault, without trying to debug someone else’s firmware or software too.

    1. Hi Pieter,
      Now you have assimilated the required knowledge, your project could grow into anything :)

      The beauty of Open Source tools like OPenOCD!

      I’m using a ‘tethered Forth’ named Mecrisp-Across (designed by Matthias Koch) atm which controls a virgin MSP430 mcu over a 3 wire JTAG umbilical. The Forth is hosted on a TM4C1294 Tiva Connected Launchpad which cross-compiles on the fly for the MSP430. To me it looks like my terminal is connected to the MSP430 target as the target response has no lag.

      I must say that back in the early 80’s we had nothing like these tools, and a simple cross compiler for the Motorola HC11 cost me around $150USD, ran on DOS and you didn’t get the source.

      Back in the early 70’s we had TTL, and in the early 60’s ? … valves and germanium semis that cost a arm and a leg.

      I know, I was there.


Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.