Jeff McGehee, senior data scientist and IoT practice lead of Very gave a keynote at Gig City Elixir on October 26, 2018.
In his keynote, called, “How to Pour Beer with Your Face,” Jeff talked about how Very architected a self-pouring kiosk with facial recognition technology using Elixir and the Nerves framework. Work on this project yielded a scalable, modular, distributed self-pour draft beer system with Phoenix, Nerves, and Swift as the foundation along with a little AWS Rekognition sprinkled in.
Why Elixir and Nerves?
Elixir has been adopted by the web community and it also boasts strengths for low-level hardware applications. The Nerves project successfully leverages the ideologies of web development (frameworks, powerful tooling, etc...) and combines them with the strengths of embedded Elixir. This makes the Elixir/Nerves stack ideal for rapid, robust development of IoT devices, and as such, it is the preferred IoT firmware stack used at Very.
The web is a world of massive user bases and ever-changing user needs, which requires web software to be robust, performant, and adaptable. Due to the scale of many web platforms, it’s feasible that a single line of code in a web ecosystem may execute more times in one day than its embedded counterpart will be executed over the entire lifetime of its hardware host. In addition, this single line of code will need to evolve to meet the needs of its user base without incurring huge engineering costs behind the changes.
Luckily, the ecosystem of web languages and technologies has evolved in order to meet the needs of the web world. This has yielded languages that are easy to write/refactor and frameworks that enforce best practices. Among these best practices are security-minded patterns, test-driven development, and continuous delivery.
Elixir is a language designed for building distributed, fault-tolerant applications. Elixir is executed within the Erlang runtime system, which was designed for use in low-level hardware applications and is most notable for being:
- Soft real-time
- Highly available and non-stop
In recent years, the Phoenix framework has made it possible for Elixir to be successfully adopted by web developers looking to create web-based applications that leverage the core characteristics of the language. As a result, an ecosystem of Elixir tools that supports the web’s best practices has emerged.
Though Elixir has been adopted by the web community, its strengths for low-level hardware applications still remain. The Nerves project successfully leverages the ideologies of web development (frameworks, powerful tooling, etc.) and combines them with the strengths of embedded Elixir. This makes the Elixir/Nerves stack ideal for rapid, robust development of IoT devices, and as such, it is the preferred IoT firmware stack used at Very.
Particular capabilities of the Elixir/Nerves stack which have aided in the Agile+Lean development of IoT devices at Very include:
- Seamless test-driven development including peripheral/sensor emulation. This eliminates slow hardware-in-the-loop testing on every iteration and often yields software that works the very first time it touches the embedded target.
- Continuous delivery of tested firmware builds via common continuous delivery tools designed for the web.
- Many compatible open source tools for secure communication with web servers via HTTP and WebSockets.
- Fault-tolerant and automated OTA firmware updates.
- Applications that are tolerant to hardware failures/abnormalities like accidental shorts, etc...
These capabilities are critical when it comes to delivering reliable software quickly (as is the custom among strong web development teams), but they are exceedingly difficult or impossible to achieve with embedded C and out of the box embedded Linux solutions.
By leveraging Nerves and utilizing its security-minded ecosystem of open source tools, we’re changing the way IoT products are being developed.