Using Firmata On Arduino Compatible Boards

- 4 mins

What is Arduino?

Arduino is an open-source electronics prototyping platform. An Arduino board is development hardware consisting of a programmable microcontroller. The boards can collect information(inputs), act on the inputs(processing) and finally produce outputs. Typically, Arduino boards are programmed using the Arduino programming language through the Arduino IDE using custom firmware(sketches). Arduino exists in many forms and flavours, from the official boards such as the UNO, ArduinoBoard 101 and MEGA, to Arduino-compatible ones like the NodeMCU.

Components

Firmata

Arduino boards are usually based on microcontrollers with low CPU clock speed (around 16 to 32 MHz) and limited memory space. The Firmata protocol provides a way to harness the power of a more powerful machine to run complex processing while using the arduino being used to collect data from sensors and execute desired outputs.

Firmata is a protocol allowing communication between software and microcontrollers. It thus provides a common language with which both the software and hardware can communicate. It works as a host-client method where the microcontroller acts as the client and a more powerful device (smartphone, tablet or computer) acts as the host communicating through a channel such as WiFi, Bluetooth or USB connection. Basically, Firmata makes the board Input/Output pins available via serial communication.

The protocol has two implementations : Firmware and Client Libraries. The firmware runs on the development board and establishes a method for communication with software running on a host machine. The Arduino IDE provides a Firmata library, implementing the Firmata protocol.

The client libraries are software implementation of the Firmata protocol running on the host machine. Several Firmata client libraries and frameworks have been implemented in a variety of popular programming languages, namely Processing, Javascript, Python, Java and even Go!

Components

Advantages

Disadvantages

Connectivity

The client hardware can be connected to the host machine either physically (through a cable) or wirelessly. There Arduino IDE provides different implementations of the firmware taking into consideration the different means of communication such as Serial, Ethernet, WiFi and Bluetooth.

Getting Started on Arduino-Compatible Boards

Flashing Firmata Firmware

Download and install the Arduino IDE.

Arduino provides Firmata as sketches. The StandardFirmata sketch is the most widely used. It allows communication via a serial port such as USB. To flash it, naviagte to File –> Examples –> Firmata –> Standard Firmata. Choose the appropriate options for your board in the Tools section and finally upload the sketch to the arduino board.

Components

Testing

Via Firmata Test Program

Firmata provides a test program for boards running StandardFirmata. It allows quick testing of all I/O pins. It runs without installation and works on Windows, MacOs, and Linux. The binaries can be found here.

Components

Via Education LAB for Arduino and Firmata by Quai-Lab

It is similar to the Firmata Test program, however it is available as a chrome extension. It has a RECORDER feature that enables the recording and the replay of the actions done with the interface and an OSCILLOSCOPE feature which allows to observe voltage changes on one of the analog input.

Components

Writing Software

Once the board running Firmata firmware has been tested, software can be implemented in different programming languages. There are different client libraries.

Components

Also, there are frameworks using the libraries which makes it easier to write software for the board. The most popular frameworks use Javascript and include Johnny-Five and Cylon.Js.

Components

References

  1. Arduino, https://www.arduino.cc/
  2. Firmata Procotol, https://github.com/firmata/protocol
  3. Firmata Test Program, https://github.com/firmata/firmata_test
  4. Education LAB for Arduino and Firmata, http://quai-lab.com/lancement-deducative-lab-arduino/
  5. Johnny-Five Framework, http://johnny-five.io/
  6. Cylon.JS, https://cylonjs.com/
  7. Lyza Danger Gardner, JavaScript on Things - Chapter 1, https://www.manning.com/books/javascript-on-things
Rahul Thakoor

Rahul Thakoor

Rahul is always looking for new challenges and has too many interests to be listed in a few lines.

rss facebook twitter github youtube mail spotify instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora