Skip to content

Instantly share code, notes, and snippets.

@dtex
Last active November 20, 2018 19:07
Show Gist options
  • Save dtex/e7c50f6e030964f72fb5cba0e80b4767 to your computer and use it in GitHub Desktop.
Save dtex/e7c50f6e030964f72fb5cba0e80b4767 to your computer and use it in GitHub Desktop.
What is firmata

WTF is firmata?

When I was first exposed to firmata I was confused by all the different parts and the scope of the ecosystem. Here is a breakdown for others who are curious but don't want to go researching:

firmata - A sketch for Arduino compatible devices. firmata is a simple client that executes basic GPIO commands on behalf of a host server. By default, the commands are received over serial. There are many versions of firmata and even a "configurator" over at http://firmatabuilder.com/ for building custom versions of the sketch. These custom versions may be optimized for certain devices whose inclusion would make firmata too big for low memory situations (ping, stepper) or they may provide other transport mechanisms for receiving commands from the host server (wifi, BLE).

firmata protocol - The protocol that is used for sending or receiving commands between the host server (running a firmata client) and an Arduino compatible device (running a firmata sketch). The protocol is the same regardless of the transport method being used so transports are swappable without a lot of rework. The firmata protocol is based on the MIDI message format and is fully documented at https://github.com/firmata/protocol

firmata.js - One of many firmata clients that run on the host server and is used to send/receive messages to/from the Arduino. There are firmata clients for Go, Rust, Clojure, Java, C#, Python, Ruby, Dart, PHP, and many other languages. firmata.js is the most complete, up-to-date, and objectively speaking, the best, but otherwise it is just one of many. The documentation is at https://github.com/firmata/firmata.js.

The thing about firmata.js that I find really interesting is that it models a standard API for other members of the IO-Plugin ecosystem. IO-Plugins are javascript classes that provide the same surface API as firmata.js but are used with devices that don't run firmata. Raspi-IO, Edison-IO, and Tessel-IO, are examples of IO-Plugins that run on SBC's and communicate with GPIO pins that are "local" (sometimes synchronous, sometimes asynchronous). Particle-IO is an example of an IO-plugin that communicates with a separate device over a network (always asynchronous). Imp-IO is an example of an IO-plugin that communicates with a device on the web through a proxy server optimized for IoT (always asynchronous).

I think a lot of people look at the IO-Plugins as a feature of Johnny-Five, but the truth is that any application, library, or framework that is built to work with firmata.js could easily swap in any of the io-plugins and work with other devices as well. All without having to rewrite any code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment