VOOZH about

URL: https://www.nuget.org/packages/nanoFramework.Iot.Device.Hcsr04/

⇱ NuGet Gallery | nanoFramework.Iot.Device.Hcsr04 1.2.952




👁 Image
nanoFramework.Iot.Device.Hcsr04 1.2.952

Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.Hcsr04 --version 1.2.952
 
 
NuGet\Install-Package nanoFramework.Iot.Device.Hcsr04 -Version 1.2.952
 
 
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="nanoFramework.Iot.Device.Hcsr04" Version="1.2.952" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nanoFramework.Iot.Device.Hcsr04" Version="1.2.952" />
 
Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.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 nanoFramework.Iot.Device.Hcsr04 --version 1.2.952
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: nanoFramework.Iot.Device.Hcsr04, 1.2.952"
 
 
#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 nanoFramework.Iot.Device.Hcsr04@1.2.952
 
 
#: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=nanoFramework.Iot.Device.Hcsr04&version=1.2.952
 
Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.Hcsr04&version=1.2.952
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

HC-SR04 - Ultrasonic Ranging Module

Device bindings for the HC-SR04 sonar distance sensor. Calculates the distance from an object by using the HC-SR04 distance sensor.

Documentation

Usage

In most of the cases, you just need to pass the 2 pins you're going to use: the Echo and Trigger pins.

using (var sonar = new Hcsr04(4, 17))
{
 if (sonar.TryGetDistance(out Length distance))
 {
 Debug.WriteLine($"Distance: {distance.Centimeters} cm");
 }
 else
 {
 Debug.WriteLine("Error reading sensor");
 }

 Thread.Sleep(1000);
}

Note: it is possible to use the same pin for both Trigger and Echo but it's not recommended.

Hardware Required

  • HC-SR04
  • Male/Female Jumper Wires

Circuit

  • VCC - 5V
  • GND - GND
  • Trig - Any valid GPIO
  • Echo - Any valid GPIO

The fritz diagram above depicts how you should wire your MCU in order to run the program, the resistance for R1 is 1kOhm. (Optional). As the HCSR04 works only with 5V and the MCU are mainly 3.3V, this resistor will help protecting the MCU. Check your MCU to see if the pin is 5V tolerant or not.

Product Versions Compatible and additional computed target framework versions.
.NET Framework net net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0-preview.85 52 6/1/2026
2.0.0-preview.80 50 5/27/2026
2.0.0-preview.73 60 5/20/2026
2.0.0-preview.62 61 5/13/2026
2.0.0-preview.49 49 5/4/2026
2.0.0-preview.45 57 4/29/2026
2.0.0-preview.37 58 4/22/2026
2.0.0-preview.32 59 4/20/2026
2.0.0-preview.16 58 3/10/2026
1.2.952 141 3/4/2026
1.2.931 315 11/10/2025
1.2.907 280 10/2/2025
1.2.889 273 7/28/2025
1.2.869 373 4/2/2025
1.2.864 354 4/2/2025
1.2.852 353 3/11/2025
1.2.846 364 3/10/2025
1.2.822 290 2/26/2025
1.2.775 327 2/4/2025
1.2.772 292 2/4/2025
Loading failed