So what does it mean? In few words you can flash AtomVM on an ESP32 and get your Elixir/Erlang code running on it.

Why

I work full time on Astarte, which is an open source IoT platform written in Elixir, and I also use several embedded boards for work and fun, so while I was working with an ESP32 board I realized that it could be interesting to use some of the cool concepts behind Elixir on embedded hardware, so I started AtomVM.

Erlang and Elixir are really good at handling network packets (ESP32 has network connectivity), running concurrent processes (ESP32 is dual core), dealing with faults (embedded software needs to be reliable), writing testable software (early testing while developing is way better than debugging on the real hardware), enabling rapid development (which is an Arduino selling point) but OTP is not designed to run on low end devices.

For instance there are already two great projects that allow Elixir code to run on embedded devices that are Nerves and GRiSP. However in order to run they need a Linux powered embedded board such as a Raspberry Pi (Nerves) or a custom board with 64 MiB of RAM (GRiSP).

AtomVM tries to overcome those limitations by design and it enables Elixir development for such low end devices like the ESP32.

How

AtomVM tries to use the smallest possible amount of memory by design thanks to a few tricks, such as executing all code in place on the flash memory (which is usually memory mapped).

Some features are left not implemented, while some others are planned to be optional, for instance floating point support might not be needed in some use case, like also arbitrary-precision integers might be not needed on those devices.

Last but not least also the standard library is stripped down to save precious flash memory.

How to blink a led with Elixir

Blinking a LED is the “hello world” program of physical computing, so we’ll start with it:

… but wait a second, before starting you should make sure to have all the required components:

Hardware:

An ESP32 dev board with a LED on it (it is possible to buy one for less than 10 €)

In case your ESP32 board doesn’t have an onboard LED: a LED, few cables and a breadboard