A .NET Foundation open source project has emerged for using C# to write embedded applications, letting developers leverage familiar Microsoft technologies to build software for small devices.
Called the .NET nanoFramework, the project lets developers use the Visual Studio IDE and C# to write managed code applications for embedded systems without having to worry about the low-level intricacies of a microcontroller. The platform is suitable for projects ranging from IoT sensors and wearables to robotics and industrial equipment.
The .NET nanoFramework includes a reduced version of the .NET Common Language Runtime and a subset of the .NET base class libraries as well as common APIs included in the Universal Windows Platform, enabling reuse of code from desktop applications, IoT Core applications, .NET code examples, and open source projects.
Specific features cited for .NET nanoFramework include:
- Runs on resource-constrained devices with as little as 256kB of flash and 64kB of RAM.
- Runs directly on bare metal. At present, ARM Cortex-M and ESP32 devices are supported.
- Supports common embedded peripherals and interconnects such as GPIO, UART, SPI, I2C, and USB.
- Native multithreading support.
- Support for energy efficient operation such as devices running on batteries.
- Interop code support lets developers write libraries that have both managed (C#) and native code (C/C++).
- Inclusion of a mark-and-sweep garbage collector means there is no manual memory management.
- Execution constrains to catch device lockups and crashes.
.NET nanoFramework picks up where .NET Micro Framework for embedded application development left off and uses some of its building blocks, the project developers said. Many components were completely rewritten, others improved, and others reused.
Most core team members and contributors to .NET nanoFramework are embedded systems enthusiasts, according to the project’s GitHub repo.