Skip to content

BLOG

Advocating for Nerves with Eric Rauer

October 29, 2020
5 min read

If you know anything about Very, then you know we love Nerves. But what is it about this Internet of Things (IoT) technology that makes it so perfect for embedded devices?

In a recent Nerves in Action webinar titled Advocating for Nerves Without Sounding like an Elixir Fanboy, Eric Rauer from Blue Clover Devices explained that “Nerves is the open-source platform and infrastructure that you need to build, deploy, and securely manage your fleet of IoT devices at speed and at scale.” Watch the full video here:

In this article, we’re going to give you a short tour of the Nerves landscape by cataloging some of the unique features that make it ideal for IoT development. Before we get into it, let’s go over the preliminaries. 

Nerves is an embedded Linux solution that’s built in the Elixir programming language, which, in turn, is built on Erlang. Advantages of Erlang include:

Elixir includes these benefits and adds some of the following:

Nerves attractiveness becomes especially apparent when we compare it to a platform like the Raspberry Pi OS:

As you can see, Nerves boots faster, has a significantly smaller firmware size, and includes hardening mechanisms like redundant A/B partitions and a read-only root filesystem. It’s also compatible with many different target devices, such as Raspberry Pi, BeagleBoard, and generic x86 architectures.

With this basis in mind, let’s talk about some of the individual features that set Nerves over the top as our platform of choice.

Elixir Circuits

Nerves includes a selection of core libraries for interfacing with hardware. Remember, since IoT devices contain unique hardware, we need a way to easily and quickly start interacting with sensors and other peripherals.

These highly readable code-bases include some of the following:

  • GPIO for general purpose input/output (I/O)
  • I2C, a serial protocol for interfacing with everything from LCD monitors to accelerometers
  • SPI, which is ideal for analog-to-digital conversions (ADC) such as temperature, ambient light, or air quality readings
  • UART, another serial protocol that we often use for inter-device communication via Bluetooth, GPS, or RFID

VintageNet

Another cornerstone Nerves library is VintageNet. This network configuration tool helps us to connect both to our LAN and to the internet by supporting Ethernet, Wi-Fi, and cellular connectivity.

It allows us to configure IPv4 and IPv6 addresses with either automatic DHCP or static assignment, it includes built-in support for network authentication methods like WPA2 and EAP, and even supports USB gadget mode. Essentially, VintageNet lets us rapidly bring our devices online so that we can start integrating early and often.

BlueHeron

A relative newcomer to the Nerves ecosystem, BlueHeron is purpose-built for Bluetooth communication. While Bluetooth may not have the widest range, its small footprint and low power consumption make it perfect for PAN applications, such as smart wearables.

BlueHeron includes support for both UART and USB integration.

Tortoise

Another library that we want to highlight is called Tortoise. This client application lets us send and receive MQTT messages. MQTT has quickly become one of the most dominant machine-to-machine (M2M) protocols for IoT development, and one of its key features is that it allows our field devices and IoT gateways to talk to our AWS cloud via IoT Core.

Tortoise is lightweight, fault-tolerant, and secured by SSL encryption.

Shoehorn

Speaking of fault-tolerance, Shoehorn is one of our best tools for creating systems that can boot key services even if applications crash or other processes fail. Basically, this library lets us decouple select startup processes from our overall application so that we always have a way to update our device.

Some common targets for Shoehorn include VintageNet for networking, secure shell (SSH) for remote terminal access, and NervesHub for over-the-air (OTA) firmware updates.

NervesHub

NervesHub is a one-stop-shop to reap all the benefits of building your firmware with Nerves. It solves headaches like remote console access and fleet firmware rollouts, all while being easy to integrate with your existing IT infrastructure. As a developer, the fewer headaches the better.

First, NervesHub is able to write to our A/B disk partitions so that we always have a good, working firmware to fall back on if something goes wrong. Second, NervesHub gives us a centralized place from which to control entire fleets of devices by using tools like IEx console. Third, NervesHub’s API lets us integrate firmware management into our overall IT infrastructure.

NervesSSH

Circling back to remote console access, we even have a Nerves-specific ssh daemon called NervesSSH. Though it’s not too different than the standard sshd we’d find on any Linux machine, it does have a few points we want to highlight.

Foremost, it lets us send Elixir language commands over ssh in addition to the regular bash commands that we all know and love. Second, going back to our Shoehorn feature, NervesSSH can run as an independent startup process so that we still have shell access, even if something else breaks. Just imagine having a full CLI on a failed boot instead of getting stuck in the bootloader’s minimal shell.

Nerves Time

Another useful feature is nerves_time for real-time control and scheduling. This program lets us keep the internal clock on our Nerves devices in-sync with a connected network clock by integrating an ntp daemon.

Even if our device does connect from the network, nerves_time can keep us close to in sync to provide another layer of fault-tolerance.

Conclusion

It’s not hard to see that we could go on and on about everything that Nerves brings to the table. We didn’t even cover features like nerves_key, ring_logger, or RamoopsLogger. Instead, we want to take a moment to draw attention to the #1 perk of using Nerves: our awesome community.

The Elixir Forum is a vibrant community hub where professional developers and hobbyists alike come to ask and answer questions, show off their latest projects, and support each other. If there’s one lesson that we’ve learned from the open-source revolution, it’s that free collaboration facilitates community-driven progress.

Want to hop aboard the Nerves hype-train? Join the #nerves channel on the Elixir Slack to stay up-to-date on all the latest Nerves news. 

You can also check out our Nerves development services for more information about how we transform our clients’ visions into real-world IoT applications.