Firmata is a protocol for communicating with microcontrollers to, e.g., set digital outputs and read analog inputs from another computer. This allows rather effortless access to the digital pins on a mainly Arduino compatible microcontrollers supported by Firmata, that can be used to detect button presses and control relays and outputs. In the Blocks driver repo on GitHub, there is a driver that can be used to control a Firmata-enabled microcontroller from Blocks. This article describes roughtly the steps involved in programming the Firmata software on a microcontroller using the Arduino IDE and how to use the Firmata Blocks driver. It is assumed that the reader is familiar with the Arduino IDE. Firmata and Arduino it not covered within the scope of Pixilab support, any Arduino issues must be directed to the maintainers of firmata and their user forums and documentation or adressed to Pixilab as a consultancy request.
Make sure Blocks version is 6.1 or higher.
Note: The Firmata driver for Blocks only supports a subset of Firmata 2.6.0. More specifically, the driver supports controlling digital inputs and outputs, analog inputs and servos over a serial connection using the StandardFirmata 2.5.9 Arduino sketch. The driver has been tested to work with the Arduino Uno and Arduino Nano Every microcontroller.
Adding StandardFirmata to a microcontroller using Arduino IDE
Using the driver
If propely configured, the pins should appear in blocks with the property names defined in the devices Custom options.
Caution, the use of Analog inputs is not always ideal as such data is reported to Blocks as continious reports in a fixed interval potentially causing a lot of network traffic. There is a setting for the device global samplingInterval setting in the drivers options that should be set to as a high number as possible. If we sense temeratures a very large number could be used. The driver has a treshold (hysterisis) setting that can prevent the driver to call update on the blocks property just from natural signal noice, preventing such input consume system resources A better solution for many analog sensors may be to write a standard Arduino sketch that only send date if the value has changed above a treshold (hysterisis to keep the sensors from sending data for every sample.