Firmata

The Firmata protocol is based on the MIDI protocol used for communicating with musical equipment.

It is also one of the most widely used protocols for communication with Arduino devices.

This driver is built to be compatible with the StandardFirmata Arduino Sketch which can be found here (Version last changed on August 17th, 2017)

Connection String Options

Name

Type

Default Value

Required

Description

Name

Firmata

Code

firmata

Maven Dependency

<dependency>
  <groupId>org.apache.plc4x</groupId>
  <artifactId>plc4j-driver-firmata</artifactId>
  <version>0.12.0</version>
</dependency>

Default Transport

serial

Supported Transports

  • serial

Config options:

Transport config options:

serial

serial.baud-rate

INT

57600

Baud-rate the serial port is set to.
Typical values are:
- 9600
- 14400
- 19200
- 38400
- 57600
- 115200
- 128000
But can also be smaller or larger values.

serial.num-data-bits

INT

8

Number of data-bits used to send data.
Typical values are:
- 7
- 8
But can also be smaller or larger values.

serial.num-stop-bits

INT

1

Number of stop-bits used to terminate data.
Typical values are:
- 1
- 2
(The theoretical 1.5 stop-bits setting is not supported)

serial.parity

STRING

NO_PARITY

Number of bits used to calculate data parity.
This is used to detect errors in transmission.
Allowed values are:
- NO_PARITY
- ODD_PARITY
- EVEN_PARITY
- MARK_PARITY
- SPACE_PARITY

Name

Value

Description

Supported Operations

write

Writing is only supported to digital addresses.

subscribe

Reading is supported for both digital and analog addresses. See note after this table however.

When subscribing to pins, these are configured to become read pins. When writing to digital pins, these are configured to become output pins. However, writing to pins for which a subscription exists, an exception will be thrown. In order to write to previously subscribed pins, all subscriptions for this have to be cancelled first.

Individual Resource Address Format

Similar to the Modbus protocol, the Firmata protocol support Boolean and Short values.

Booleans are used for the digital IO pins and short values for the analog inputs.

Binary Addresses

The full format for a digital address has the following format:

digital:{start-address}[{array-size}]:{special-config}

The start-address and array-size are simple integer values. special-config can be used to configure the digital input pin to something else than INPUT.

Currently the only supported option is PULLUP which configured the Arduino’s digital input pin to use it’s built in pullup-resistor.

Both the array-size as well as the special-config parts are optional. So the following example addresses are valid:

digital:4
digital:4[5]
digital:4:PULLUP

A normal Arduino Uno is equipped with 14 digital inputs: 0-13

However in case of using the serial port (which will always be the case when using this driver), the pins 0 and 1 are the RX and TX pins of the serial port and can’t be used.

Analog Addresses

The full format for an analog address is as follows:

analog:{start-address}[{array-size}]

The start-address and array-size are simple integer values.

Both the array-size is optional. So the following example addresses are valid:

analog:1
analog:2[3]

A normal Arduino Uno is equipped with 6 analog inputs: 0-5