![]() |
VOOZH | about |
dotnet add package nanoFramework.Iot.Device.Hcsr04.Esp32 --version 1.2.955
NuGet\Install-Package nanoFramework.Iot.Device.Hcsr04.Esp32 -Version 1.2.955
<PackageReference Include="nanoFramework.Iot.Device.Hcsr04.Esp32" Version="1.2.955" />
<PackageVersion Include="nanoFramework.Iot.Device.Hcsr04.Esp32" Version="1.2.955" />Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.Hcsr04.Esp32" />Project file
paket add nanoFramework.Iot.Device.Hcsr04.Esp32 --version 1.2.955
#r "nuget: nanoFramework.Iot.Device.Hcsr04.Esp32, 1.2.955"
#:package nanoFramework.Iot.Device.Hcsr04.Esp32@1.2.955
#addin nuget:?package=nanoFramework.Iot.Device.Hcsr04.Esp32&version=1.2.955Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.Hcsr04.Esp32&version=1.2.955Install as a Cake Tool
Device bindings for the HC-SR04 sonar distance sensor. Calculates the distance from an object by using the HC-SR04 distance sensor. Specific implementation with ESP32 using RMT. This implementation is more precise than the other generic Hcsr04.
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 not possible to use the same pin for both Trigger and Echo.
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. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0-preview.85 | 49 | 6/1/2026 |
| 2.0.0-preview.80 | 55 | 5/27/2026 |
| 2.0.0-preview.73 | 60 | 5/20/2026 |
| 2.0.0-preview.62 | 57 | 5/13/2026 |
| 2.0.0-preview.49 | 51 | 5/4/2026 |
| 2.0.0-preview.45 | 63 | 4/29/2026 |
| 2.0.0-preview.37 | 60 | 4/22/2026 |
| 2.0.0-preview.32 | 66 | 4/20/2026 |
| 2.0.0-preview.16 | 66 | 3/10/2026 |
| 1.2.955 | 138 | 3/6/2026 |
| 1.2.952 | 121 | 3/4/2026 |
| 1.2.931 | 313 | 11/10/2025 |
| 1.2.907 | 277 | 10/2/2025 |
| 1.2.889 | 268 | 7/28/2025 |
| 1.2.869 | 356 | 4/2/2025 |
| 1.2.864 | 302 | 4/2/2025 |
| 1.2.852 | 342 | 3/11/2025 |
| 1.2.846 | 341 | 3/10/2025 |
| 1.2.835 | 267 | 2/27/2025 |
| 1.2.829 | 256 | 2/27/2025 |