arduino, elixir and nerves - code sync · arduino, elixir and nerves a deep dive into the firmata...

17
Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol

Upload: others

Post on 20-May-2020

17 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol

Page 2: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

Firmata

Firmata is a protocol for communicating with microcontrollers from software on a computer (host) based

on the MIDI protocol

Page 3: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

Firmata -> MIDI

0xD0 - 0xDF + 1 byte

MIDI: Channel + Pressure

Firmata: Report digital port + enable/disable

Page 4: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

Outgoing from Host

Page 5: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

Incoming to Host

Page 6: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

Few message types map 1 - 1 to MIDI protocol, basically analog and digital pin IO, firmware version, etc.

Mapping to a MIDI message must match MIDI message length exactly

Sysex Messages can be any length

Sysex Messages are used prominently for Firmata functionality

System Exclusive (Sysex) Messages

Page 7: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

Full Disclosure

Keyvan Fatehi (https://github.com/kfatehi) wrote the original Elixir Firmata Client

(https://github.com/entone/firmata) and is responsible for the majority of the architecture and parsing

logic.

Page 8: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

My contributions (maintainer)

● I2C read/write

● String data

● Analog pin <--> process mapping architecture.

● Ultrasonic sensor

● NeoPixel

Page 9: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

Typical Firmata Architecture

Page 10: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

Firmata.Board.init

Page 11: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

Parse UART input

Page 12: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

Firmata.Protocol

Page 13: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

Custom Firmata Additions

Page 14: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

Modifying the Firmata Client

Page 15: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

https://github.com/entone/firmata_example

Page 16: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from
Page 17: Arduino, Elixir and Nerves - Code Sync · Arduino, Elixir and Nerves A Deep Dive into the Firmata Protocol. Firmata Firmata is a protocol for communicating with microcontrollers from

Thank You

@entropealab

@CRTLabs

https://github.com/entone

http://code.crtlabs.org

https://github.com/entone/firmata_example