Here you will learn about what hardio is, the benefits it brings, and its various components.

What is hardio?

Hardio is a collection of drivers and interfaces that allow users to easily implement new drivers and use them without having to change their code for each hardware change they might encounter. The hardware components are abstracted by the different implementations of the hardiocore package and thus the drivers have the ability to work on all boards that have a corresponding hardiocore implementation without modifying their code.

Hardio also provides high level generic interfaces for many types of sensors. This allows users to only focus on the type of sensors that they are using and not on the specific models. This makes it possible to reuse the high level code on any hardware configuration that has the correct types of sensors connected and only have to change a little amount of code for the initialization part of the low level components.

The remaining sections of this page will describe all of the hardio components.



Hardiocore is the base package that is at the center of how hardio works. It defines all of the low level interfaces as well as the generic interfaces. These are the interfaces that need to be implemented to create new drivers or that are used to abstract various communication channels (like I2C or Serial).


One of the interfaces defined by hardiocore is Iocard. This is the interface that needs to be implemented in order to make hardio work on a specific board. Each board will have a corresponding IoCard implementation (hardiorpi for raspberry pi, hardioup for upboard, …). All devices need to be registered on an iocard in order to be able to work.


Devices implement one or more of the interfaces defined in hardiocore (like i2cdevice, or piniodevice). They also have to implement one or more of the generic interfaces (like thermometer, or watersensor) in order to be used like generic devices. Devices use some of the communication interfaces defined in hardiocore, thus allowing the same device to work on multiple boards without having to change the code in the device.

Each device needs to be registered in an IoCard before being used. A device can also implement the IoCard interface and act as a “composite” device. An example of a composite device is the powerswitch, which is a device, that needs to be registered on an IoCard, but is also and IoCard, and thus has the ability to register its own devices (like motors and lights).

Using hardio

Hardio provides two main namespaces:

  • hardio: The main namespace where all devices are implemented. Everything implemented in hardio should be under this namespace or one of its sub namespaces. This namespace will contain Iocard implementations and all devices.
  • hardio::generic: The namespace where all generic device interfaces are defined. This namespace only contains generic interfaces definitions. It is used by implementations of these interfaces in various devices and high level code that wants to use the abstrations it provides.

Additionnal documentation and examples

Examples on the usage of most devices, hardiocore, and hardio::generic are available in the example packages such as upboardexample and rpiexample. The tutorial also covers some of these examples and explain how to use the various components in the hardio framework.