Meadow.Foundation.Sensors.Distance.Hcsr04 3.0.0-beta

This is a prerelease version of Meadow.Foundation.Sensors.Distance.Hcsr04.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Meadow.Foundation.Sensors.Distance.Hcsr04 --version 3.0.0-beta
                    
NuGet\Install-Package Meadow.Foundation.Sensors.Distance.Hcsr04 -Version 3.0.0-beta
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Meadow.Foundation.Sensors.Distance.Hcsr04" Version="3.0.0-beta" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Meadow.Foundation.Sensors.Distance.Hcsr04" Version="3.0.0-beta" />
                    
Directory.Packages.props
<PackageReference Include="Meadow.Foundation.Sensors.Distance.Hcsr04" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Meadow.Foundation.Sensors.Distance.Hcsr04 --version 3.0.0-beta
                    
#r "nuget: Meadow.Foundation.Sensors.Distance.Hcsr04, 3.0.0-beta"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Meadow.Foundation.Sensors.Distance.Hcsr04@3.0.0-beta
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Meadow.Foundation.Sensors.Distance.Hcsr04&version=3.0.0-beta&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Meadow.Foundation.Sensors.Distance.Hcsr04&version=3.0.0-beta&prerelease
                    
Install as a Cake Tool

Meadow.Foundation.Sensors.Distance.Hcsr04

HCSR04 digital ultrasonic distance sensor

The Hcsr04 library is included in the Meadow.Foundation.Sensors.Distance.Hcsr04 nuget package and is designed for the Wilderness Labs Meadow .NET IoT platform.

This driver is part of the Meadow.Foundation peripherals library, an open-source repository of drivers and libraries that streamline and simplify adding hardware to your C# .NET Meadow IoT applications.

For more information on developing for Meadow, visit developer.wildernesslabs.co.

To view all Wilderness Labs open-source projects, including samples, visit github.com/wildernesslabs.

Installation

You can install the library from within Visual Studio using the NuGet Package Manager or from the command line using the .NET CLI:

dotnet add package Meadow.Foundation.Sensors.Distance.Hcsr04

Usage

Hcsr04 hCSR04;

public override Task Initialize()
{
    Resolver.Log.Info($"Hello HC-SR04 sample");

    hCSR04 = new Hcsr04(
        triggerPin: Device.Pins.D05,
        echoPin: Device.Pins.D06);
    hCSR04.Updated += HCSR04_DistanceUpdated;

    return Task.CompletedTask;
}

public override Task Run()
{
    while (true)
    {
        // Sends a trigger signal
        hCSR04.MeasureDistance();
        Thread.Sleep(2000);
    }
}

private void HCSR04_DistanceUpdated(object sender, IChangeResult<Meadow.Units.Length> e)
{
    Resolver.Log.Info($"Distance (cm): {e.New.Centimeters}");
}

How to Contribute

Need Help?

If you have questions or need assistance, please join the Wilderness Labs community on Slack.

About Meadow

Meadow is a complete IoT platform with defense-grade security that runs full .NET applications on embeddable microcontrollers and Linux single-board computers including Raspberry Pi and NVIDIA Jetson.

Build

Use the full .NET platform and tooling such as Visual Studio and plug-and-play hardware drivers to painlessly build IoT solutions.

Connect

Utilize native support for WiFi, Ethernet, and Cellular connectivity to send sensor data to the Cloud and remotely control your peripherals.

Deploy

Instantly deploy and manage your fleet in the cloud for OTA, health-monitoring, logs, command + control, and enterprise backend integrations.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Meadow.Foundation.Sensors.Distance.Hcsr04:

Package Downloads
Meadow.Foundation.ICs.IOExpanders.SerialWombat

SerialWombat I2C IO expander for GPIO, PWM, servos, etc.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.2-beta 95 9/13/2026
3.0.1-beta 97 9/9/2026
3.0.0-beta 124 9/4/2026
2.5.0.12-beta 178 4/25/2026
2.5.0.11-beta 179 3/17/2026
2.5.0.10-beta 172 3/11/2026
2.5.0.9-beta 158 3/6/2026
2.5.0.8-beta 172 2/28/2026
2.5.0.7-beta 163 2/27/2026
2.5.0.6-beta 165 2/24/2026
2.5.0.5-beta 265 12/23/2025
2.5.0.4-beta 242 12/20/2025
2.5.0.3-beta 344 12/17/2025
2.5.0.2-beta 494 12/9/2025
2.5.0.1-beta 504 12/9/2025
2.5.0 327 11/24/2025
2.4.0.15-beta 473 11/20/2025
2.4.0.14-beta 236 11/7/2025
2.4.0.13-beta 252 11/6/2025
2.4.0.12-beta 256 11/5/2025
Loading failed