Select Page

Sensor connection under embedded Linux - how industrial I/O makes a difference

How can sensors be connected to embedded Linux systems efficiently and flexibly? In the MicroConsult webinar, embedded Linux expert Andreas Klinger provided practical insights into one of the most important subsystems for this: Industrial I/O (IIO) in the Linux kernel.

And as is often the case with Andreas, it all starts with a real-world project, in this case, a smart beehive scale..

Why industrial IO?

The Linux kernel essentially offers two subsystems for sensor technology:

  • HWmon: well-established, but more suited for traditional system monitoring
  • more modern, flexible, faster, and supporting a wide range of sensors moderner, flexibler, schneller und mit einer großen Zahl unterstützter Sensoren

IIO has a clear goal: a unified user-space interface for a wide variety of sensors.

Whether it’s temperature, air pressure, humidity, or analog input voltages, the interface always looks the same in the IIO subsystem. This means:

  • Easier sensor replacement
  • Standardized file structures in SysFS
  • Clear scaling models (SI units via fixed scaling factors)
  • Support of a wide range of sensors

Over 300 sensors and actuators are already supported in the mainline kernel today - and that number is growing.

Real-world example - the connected beehive scale

To illustrate how IIO works, Andreas presented his personal project: a scale that measures the weight, temperature, humidity, and air pressure of his beehives and derives important information from these measurements:

  • How much honey has been harvested?
  • Has a colony swarmed?
  • Is there robbing between colonies?
  • How does the flight behavior change depending on temperature and air pressure?

At the heart of the system are two components:

  1. HX711 – a 24-bit ADC that detects the slightest voltage changes in the load cell

embedded linux sensor hx711

Figure 1: Sensor HX711 (source: Andreas Klinger)

  1. Bosch BME280 – environmental sensor for temperature, humidity, and air pressure

emb linux Sensor bme280

Figure 2: Sensor BME280 (source: Andreas Klinger)

Both sensors are fully connected via Industrial-IO; the HX711 thanks to a driver that Andreas himself contributed to the Linux mainline. The three operating modes of Industrial-IO

The three operating modes of Industrial-IO

  1. Direct Mode – simple query

In direct mode, the user space queries the value, and Linux reads the sensor at that moment .

  • via SysFS files such as in_voltage0_raw
    with the corresponding scaling factor (in_voltage_scale)
  • ideal for sporadic measurements

An example: The weight of a beehive is converted to millivolts using the raw ADC values and the scaling factor - standardization is one of the major advantages of IIO.

  1. Buffered Mode – precise and continuous acquisition

In buffered mode, an HR timer handles the triggering of the sensor. Data is collected in a ring buffer within the kernel, stamped with precise timestamps, and efficiently passed on to user space.

emb linux Buffered Mode

Figure 3: Buffered mode (source: Andreas Klinger)

This mode is perfect for fast, regular measurements, latency-critical applications, and large data sets.

During the webinar, Andreas demonstrated live how to read out multiple channels in binary format using iio_generic_buffer, including nanosecond timestamps.

  1. Event-triggered mode – reacting instead of polling

The user process remains dormant until a sensor interrupt is triggered, for example, when a threshold is exceeded. This mode is suitable when a sensor reports relevant events “on its own,” when energy-efficient operation is required, or when interrupt-capable sensor technology is available.

Since neither the HX711 nor the BME280 provide such interrupts, this mode was not demonstrated in practice during the webinar.

Why industrial-IO is so valuable for developers

Andreas summed it up in the webinar: IIO provides a unified interface and abstracts the hardware without sacrificing flexibility. This means:

  • Drivers implement all hardware details directly in the kernel (including DMA, interrupts, etc.).
  • User space has the same access logic everywhere.
  • Sensors are easily interchangeable.
  • Performance is high and reproducible.
  • The development effort for custom applications is significantly reduced.

The number of available drivers also shows just how well-established the subsystem has become.

For those who want to dive deeper

During the webinar, Andreas shared some helpful resources:

  • Kernel configuration under Device Drivers → IIO Device Drivers → IIO
    - complete list of all sensors
  • Kernel documentation under Documentation/ABI
    - detailed description of the SysFS interface
  • Kernel source code
     – a grep search by sensor type usually finds the right driver file right away
  • IIO mailing list
    – for developers or more complex questions

And for the curious:
Andreas makes the live data from his beehives publicly available.

Conclusion: Industrial-IO is the key to modern sensor technology

The webinar impressively demonstrated how efficient, flexible, and practical Industrial-IO makes sensor connectivity under embedded Linux.

With a unified interface, clear standards, and the ability to implement even complex measurement tasks with high performance, IIO is one of the most important tools for embedded developers. And thanks to practical examples like the smart beehive scale, one thing is clear: Embedded Linux is capable of a lot - you just have to know how to use it.

Related MicroConsult training

Anyone who works professionally with embedded Linux, kernel drivers, or Yocto will find the right training at MicroConsult:

All training sessions build on one another - ideal for developers who want to systematically build and expand their Linux expertise.

Curious? In the webinar, Andreas Klinger will show you step by step how Industrial I/O works in practice.

Further information

MicroConsult Trainings: Embedded and Real-Time Operating Systems

MicroConsult Expertise: Embedded and Real-Time Development

MicroConsult training & coaching overview

MicroConsult Newsletter

With the MicroConsult newsletter, you'll stay on the pulse of the embedded world. Look forward to proven practical knowledge, real professional tips, and current events – directly from our experts for your project success.

Subscribe now!

Published by

Dipl.-Ing. (FH) Andreas Klinger

Dipl.-Ing. (FH) Andreas Klinger