Skip to content

Belay.NETConnect C# Applications to Hardware Instantly

A .NET library that lets your desktop applications communicate with MicroPython devices as easily as calling a method. No embedded programming knowledge required.

Belay.NETBelay.NET

What Is Belay.NET? ​

Belay.NET is a .NET library that bridges the gap between your C# desktop applications and MicroPython hardware. Think of it as a communication layer that lets you treat microcontrollers like remote objects in your application.

Instead of learning embedded programming, writing firmware, or dealing with serial communication protocols, you simply:

  • Install the NuGet package
  • Connect your MicroPython device via USB
  • Write C# methods that execute Python code on the device
  • Get strongly-typed results back in your application

It's designed for C# developers who need to connect to hardware quickly without becoming embedded systems experts.

Key Features ​

  • πŸš€ Zero Configuration: Connect and control devices in seconds with automatic device detection and protocol negotiation.
  • 🎯 Type-Safe Remote Execution: Full IntelliSense and compile-time safety for remote code with strongly-typed return values.
  • ⚑ Async First: Modern async/await patterns throughout the API with proper cancellation token support.
  • 🏷️ Attribute-Based Programming: Decorate methods to run seamlessly on devices with [Task], [Setup], [Teardown], and [Thread] attributes.
  • πŸ“¦ Dependency Injection Ready: First-class DI support with Microsoft.Extensions including configuration, health checks, and factory patterns.
  • πŸ” Built-in Monitoring: Health checks, performance metrics, and comprehensive error handling with structured logging.

The Problem We Solve ​

Connecting C# desktop applications to hardware is unnecessarily complex. Traditional approaches require:

❌ Learning embedded programming languages
❌ Writing and deploying firmware
❌ Managing serial communication protocols
❌ Handling device state and error conditions
❌ Converting between data formats manually

Belay.NET eliminates this complexity:

βœ… No firmware needed - Works with standard MicroPython
βœ… No serial protocols - Handled automatically
βœ… No embedded knowledge - Write familiar C# code
βœ… Type safety - Get compile-time checking and IntelliSense
βœ… Error handling - Comprehensive exception management

How It Works ​

1

Connect Your Device

Simply plug in your MicroPython device via USB. Belay.NET handles the communication protocol automatically.

2

Write C# Code

Create C# classes that represent your hardware. Use attributes to mark methods that should run on the device.

3

Execute Remotely

Call your C# methods normally. Belay.NET translates and executes them on the microcontroller, returning typed results.

See It In Action ​

Transform complex hardware control into simple C# method calls:

csharp
// Install: dotnet add package Belay.NET

public class SmartSensor : Device
{
    [Setup]
    public async Task InitializeAsync() =>
        await ExecuteAsync("from machine import Pin, ADC; sensor = ADC(Pin(26))");
        
    [Task(Cache = true, TimeoutMs = 5000)]
    public async Task<float> ReadTemperatureAsync() =>
        await ExecuteAsync<float>("sensor.read_u16() * 3.3 / 65536 * 100");
        
    [Task]
    public async Task<bool> SetLedAsync(bool state) =>
        await ExecuteAsync<bool>($"led.{'on' if state else 'off'}(); True");
}

// Use like any other .NET classβ€”no hardware knowledge required
var sensor = new SmartSensor();
await sensor.ConnectAsync("COM3");
await sensor.InitializeAsync();

var temperature = await sensor.ReadTemperatureAsync();
Console.WriteLine($"Current temperature: {temperature}Β°C");

Production-Ready Features ​

For Individual Developers ​

  • Zero Configuration: Works out of the box with popular development boards
  • Rich IDE Support: Full IntelliSense, debugging, and error checking
  • Type Safety: Strongly-typed remote execution with compile-time validation
  • Async/Await: Modern async patterns for responsive applications

For Enterprise Teams ​

  • Dependency Injection: Full Microsoft.Extensions.DependencyInjection integration
  • Health Monitoring: Built-in health checks and performance metrics
  • Configuration Management: Structured configuration with validation
  • Error Handling: Comprehensive exception hierarchy with device error mapping
  • Session Management: Advanced connection pooling and lifecycle management
  • Structured Logging: Integration with Microsoft.Extensions.Logging

Use Cases We Enable ​

🏭 Industrial Automation

Control PLCs, sensors, and actuators from .NET applications. Build SCADA systems with familiar tools and deployment patterns.

🏠 Smart Home Systems

Create intelligent home automation with ASP.NET Core backends that directly control IoT devices. Build dashboards with Blazor or React.

πŸ“Š Data Collection

Build research instruments and monitoring systems. Store data directly to SQL Server, Entity Framework, or cloud databases.

πŸŽ“ Educational Projects

Teach IoT concepts without the complexity of embedded programming. Students learn hardware control using familiar C# syntax.

Supported Hardware ​

πŸ”Œ Raspberry Pi Pico

Full MicroPython and CircuitPython support

Fully Supported

πŸ“‘ ESP32

WiFi-enabled microcontroller with rich peripherals

Fully Supported

⚑ PyBoard

Original MicroPython development board

Fully Supported

🐍 CircuitPython

Adafruit's education-focused Python variant

Beta Support

View supported hardware β†’

What's New in v0.2.0 ​

  • ✨ Dependency Injection: First-class Microsoft.Extensions.DependencyInjection support
  • πŸ₯ Health Checks: Built-in system and device health monitoring
  • βš™οΈ Configuration: Comprehensive configuration management with validation
  • 🏭 Factory Patterns: Clean abstractions for device and communicator creation
  • πŸ”§ Session Management: Advanced session lifecycle and resource management
  • ❌ Exception Handling: Unified exception hierarchy with device error mapping

Read the full changelog β†’

Released under the Apache License 2.0.