BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Advanced IoT Application Support in .NET Core 3 with System.Device.Gpio

Advanced IoT Application Support in .NET Core 3 with System.Device.Gpio

Leia em Português

System.Device.Gpio is a new open-source library for .Net Core that aims to enable IoT applications to interact with sensors, displays, and input devices through their GPIO pins or other I/O control hardware. The library is augmented by a community-maintained collection of bindings for a number of devices.

As Microsoft .NET program manager Richard Lunder demoed, the new library gives developers control over the general purpose I/O (GPIO) pins of single-board-computers through a set of APIs that can be used to control external devices. This was not easily possible previously using .NET Core, although .NET Core could run for example on a Raspberry Pi. Supported platforms include the Raspberry Pi, BeagleBoard, HummingBoard, and ODROID, but leave out popular Arduino boards such as the UNO, Mega, Nano, etc.

The new library, which is available through a NuGet package, can run on Linux as well as Windows 10 IoT Core by relying on native drivers available for those platforms. For Linux distros based on Linux 4.8 and newer versions, System.Device.Gpio uses libgpiod, which supersedes the GPIO sysfs interface that provides a more limited and slower GPIO access available for older Linux versions. For top performance, albeit at the cost of portability, System.Device.Gpio on Linux also supports GPIO access through /dev/mem, although these board-specific drivers could be removed in the future.

System.Device.Gpio has a companion library called Iot.Device.Bindings aimed to make it easier to use many existing "dumb" sensors, displays, and input devices by providing developers a higher-level API to access them instead of relying on their pin-level protocols. Currently, Iot.Device.Bindings include bindings for dozens of devices such as A/D converters, accelerometers, gas sensors, light sensors, barometers, and many more. It is important to note the Iot.Device.Bindings are a community effort and not fully supported by Microsoft.

Lunder, who demoed using Visual Studio Code on a Mac to run a LED-controlling application running on a Raspberry Pi 3 with full support for step-by-step debugging, said parts of System.Device.Gpio are written in C++ but they are being progressively ported to C#, which should make it easier for .NET developers to contribute improvements and fixes.

System.Device.Gpio is considered still experimental and Microsoft is seeking active feedback on its API, which could thus change in future versions.

Rate this Article

Adoption
Style

BT