Nerves Course




What's in this preview?

We want you to get the feel for typical Groxio content and the reasons we provide each type of content. Each Groxio module comes in four scheduled releases consisting of the central PDF, videos, and resource links. Later releases have projects as well. You can see part of the first release here.

Add agility to your IoT development cycle



Buy Course Today!



Preview PDF!

Version: Feb 8, 2021


Just $70.00, A La Carte
(other options available)




Programmer Passport Nerves






Why a book?

The scientific teaching method we follow is the Dreyfus learning model. Books provide the metaphors experts need to build context, step-by-step instructions for beginners, and the exercises that intermediates need to learn.

Description

Elixir is an excellent general purpose language. It has features that let you write programs that are more reliable, easier to understand, and highly concurrent. Many of those same capabilities make Elixir an ideal language for embedded systems.


Embedded systems are smaller, special purpose computers used to control hardware. As embedded processors get more sophisticated, the demand for more complex systems grows, such as fridges that double as web browsers and doorbells that double as security cameras and networked intercoms. To support these new requirements, we need higher level languages with more powerful features.


Enter Nerves, Because many of today’s embedded apps are full-featured distributed, concurrent systems, they are ideally matched to functional programming languages like Elixir.

History

A few years after the creation of Elixir, Justin Schneck and Frank Hunleth recognized the need for advanced programming languages in the embedded community and founded the Nerves project. Nerves is the platform you’ll use to build embedded systems with Elixir. On the project’s website, you’ll find this description:

Nerves is the open-source platform and infrastructure you need to build, deploy, and securely manage your fleet of IoT devices at speed and scale.

As the years go by, more people join the community. Nerves is a staple at the yearly ElixirConf conferences and more successful projects emerge every year. In this course, you’re going to find out why.




Course Objectives

Groxio courses focus on concepts rather than features. We’ll spend more time building your intuition about Nerves from the ground up.

The classic light blinking project will teach you to burn firmware, build a boundary layer that can talk to hardware through Circuits.GPIO, build an adapter layer that can run the same program three ways: in tests, in IEx, and on hardware, and configure your project with config files.

The binary clock project will teach you to build a core, write genservers, and control hardware with OTP and your core. Two sensor projects will show you how to use a light sensor that will both report a state on demand, access your sensors over a network, and deal with a barametric sensor.

When you’re done, you’ll be able to:

  1. Understand the flow of a hardware project while writing code that runs in tests, on the hosts, and on a target embbedded system.

  2. Create Nerves projects that control hardware with

  • single-responosibility functions
  • contained in layered modules
  • that represent boundary, core, and adapter responsibilities.
  1. Establish project organization using Poncho projects, and differentiate between the major kinds of subprojects.

Videos

Public & Private




Why videos?

Groxio language modules have two kinds of videos. Our overview videos set the history and context of a language, or wrap up the work we've done, and are free to support language ecosystems. Our coding instruction videos, mostly starting with the second release, are paid content, and each one offers a live coding project.

Every learning level benefits from pair programming. Our videos are professional, but do not scrub away every tiny mistake. That way, you can see how experienced programmers deal with errors and changes in code organization.

Nerves - Interview with Frank Hunleth

In this interview with Nerves founder Frank Hunleth, we discuss the creation of Nerves, and talk about the various sensors that Nerves supports. We also discuss tips for the Groxio community as they start to make their first forays into Nerves, such as focusing on one thing at a time.

1. Elixir Nerves, SSH to a Nerves Target

In this video, we connect to a Raspberry Pi Zero using the Circuits Quickstart firmware. We'll use existing firmware created by the Nerves team, and then we remotely shell into the computer using a USB cord and SSH. We bring up an Elixir shell on the target, all in under 15 minutes.

Video

2. Elixir Nerves, Burning Firmware

In this video, we go through the process of using Nerves tooling to burn firmware. In later projects, we'll build our own program to burn. For this project, we first pick known working firmware from the Nerves team, and then install it using Nerves tooling. We'll use a tool called fwup for this project.
Subscriber content

3. Elixir Nerves, Building an LED Circuit

In this video, we build a basic Nerves circuit, using breadboard, an LED, a resistor, and a couple of jumper wires. Then, we shell into our target computer, a Raspberry Pi Zero, and control the LED. We use the Circuits.GPIO library to control our LED, and then make it blink.

Video

4. Blink an LED Circuit With Elixir Nerves

In this video, we build our initial circuit on breadboard, and control it with the Raspberry Pi. We learn techniques for working with electrical circuits using a raspberry pi zero, and control it using the Circuits.GPIO project.
Subscriber content

Video

5. mix firmware and Uploading Code

In this video, you'll learn to create an OTP release using mix firmware. After installing via a MicroSD card, you'll use mix upload to upload your code using an alternate partition. It's all built into Nerves.
Subscriber content

Video

6. Building a Boundary Layer for Nerves

In this video, we begin to explore the layers of an Elixir Nerves system. Using the system in Designing Elixir Systems with OTP, Gray and Tate build a typical OTP system. It works for hardware too! We explore the system, beginning with a boundary layer.
Subscriber content

7. Building an Adapter Layer

Nerves projects in Elixir work best when you can run the same code three ways, in on the host in development mode (perhaps with IEx), in tests, and on your target hardware. We deal with different requirements when running different environments and targets.

Video

8. Configuration

Configuration of Nerves projects can work two ways. Poncho projects use different projects for each environment, and configuration projects build a separate config file for each target. This video shows you how to compartmentalize configuration.
Subscriber content

Video

9. Behaviours and Interfaces

Once you've built your adapter, sometimes you want some extra type protection for the adapter's clients. In this chapter, we wrap the adapter layer in a behaviour. This strategy lets us specify the types and functions for the public callbacks that make up the interface.
Subscriber content

Video

10. Using GenServers with Nerves

In this video, we build our boundary layer for the Nerves project. This layer will present the interface that your hardware's clients will interact with. The server layers have constructors to create the core data type, reducers to move from one state to the next, and converters to transform the state to a useful form.
Subscriber content

Video

11. Implementing Nerves Lifecycles with Supervisors

Once a project has a working GenServer, the next step is to connect a lifecycle layer. That happens in application.ex. This file is responsible for implementing the supervisor for an application. Supervisors are important for Nerves because they define exactly which services to start, and how to restart.
Subscriber content

12. Networking with VintageNet

Once your project is working standalone, you'll want to network with it. A great way to do so is to use VintageNet to build a persistent connection. It's easy to do. With a connection to IEx over IEx, all you need to do is issue a command to build a persistent connection.

13. Poncho Projects

In Nerves, we often want to establish individual Elixir projects that clearly separate responsibilities, and establish clear responsibilities through carefully designed APIs. We'll do so through a simple directory, called a poncho, that holds other mix projects.

Video

14. Communication with PubSub

Networking can sometimes be tricky with hardware projects, but a combination of distrributed Erlang, process groups, and Phoenix PubSub can smooth out implementation details. This brief video shows a basic walkthrough of how it works.
Subscriber content

Video

Project Intro: Binary Clock Intro

This project is presented in video because of the hardware parts of the project. This introduction shows you how the clock will work.
Subscriber content

Video

Project 1-1: Clock Cabinet

The first step to building out this project is to build out a housing that will keep everything together. I've built this one with wood, but other options exist as well. This video also gets into building individual LED wires that will serve as bits.
Subscriber content

Video

Project 1-2: Clock Connections

Once you've built out your cabinet and started to work on your LEDs, you're going to want to wire everything up. That means connecting the SPI interface with your Raspberry Pi, and hooking up the LED wires to your project and your housing.
Subscriber content

Video

Project 1-3: Solderless Option

If you absolutely can't solder, you might try to implement this project solderlessly. I haven't tried this yet, but I point you to some resources that may help you do so if you want to try it yourself.
Subscriber content

Video

Project 2-1: Light LEDs Using the Serial Peripheral Interface

In this episode of the project, we begin to use the Circuits.SPI library to control the individual lights of the assembled clock. We start by sending blocks of full-brightness lights to simplify our approach.
Subscriber content

Video

Project 2-2: Explore Time and Bits in IEx

In this video, we work in IEx to determine which numbers to send to light up the individual LEDs on our clock. We'll use a variety of tools from binaries to for comprehensions to smooth out the typically jagged edges of dealing with hardware.
Subscriber content

Video

Project 2-3: Build a Core Layer

With the exploration done, we write the software for the clock. We start with the core. This layer is repsonsible for creating a constructor and reducer. The constructor builds a custom time, splitting out the AM/PM indicator, and stringing together bytes that represent brightnesses.
Subscriber content

Video

Project 2-4: Build the Boundary Layer

This final episode builds a GenServer, the boundary for our binary clock. Though process work is notoriously difficult, we've done the heavy lifting for the rest of the project in a core, so all that remains is to periodically send messages and upload a known set of bytes to a standard SPI interface.
Subscriber content

Community Resources

Cool quick trips for Nerves




Why resource links?

Each new chapter has a set of links, separated into three categories. The categories reflect different competency levels and resources that match that stage of learning, for each Groxio release.

Learn It

These resources will get you on the path to learning with background information, tooling and exercises.

Do It

You decide how deep to go. These resources are exercises and projects to cement your learning.

Grok It

These resources will help you put your new knowledge into context so you'll be better at your everyday job.

Projects

Longer Excursions (chapters 3 and 4)






Why projects?

The Dreyfus model is originally instruction for pilots. A typical pilot course is based on reading material to understand context, and then flying a plane. Our videos and PDFs are important, but in the end, programmers need to program in order to learn. Our projects offer different levels of assistance, from "give me the answer" to "make this test pass".