nanoFramework.Iot.Device.Hcsr501 1.2.869

Prefix Reserved
dotnet add package nanoFramework.Iot.Device.Hcsr501 --version 1.2.869
                    
NuGet\Install-Package nanoFramework.Iot.Device.Hcsr501 -Version 1.2.869
                    
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.Hcsr501" Version="1.2.869" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nanoFramework.Iot.Device.Hcsr501" Version="1.2.869" />
                    
Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.Hcsr501" />
                    
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.Hcsr501 --version 1.2.869
                    
#r "nuget: nanoFramework.Iot.Device.Hcsr501, 1.2.869"
                    
#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.
#addin nuget:?package=nanoFramework.Iot.Device.Hcsr501&version=1.2.869
                    
Install nanoFramework.Iot.Device.Hcsr501 as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.Hcsr501&version=1.2.869
                    
Install nanoFramework.Iot.Device.Hcsr501 as a Cake Tool

HC-SR501 - PIR Motion Sensor

HC-SR501 is used to detect motion based on the infrared heat in the surrounding area.

Documentation

sensor

Usage

using(Hcsr501 sensor = new Hcsr501(hcsr501Pin, PinNumberingScheme.Logical))
{
    // detect motion
    bool isDetected = sensor.IsMotionDetected;
}

From the HC-SR501 sample, we can do comething more complete:

GpioController ledController = new GpioController();
ledController.OpenPin(27, PinMode.Output);

using (Iot.Device.Hcsr501.Hcsr501 sensor =
    new Iot.Device.Hcsr501.Hcsr501(17))
{
    while (true)
    {
        // adjusting the detection distance and time by rotating the potentiometer on the sensor
        if (sensor.IsMotionDetected)
        {
            // turn the led on when the sensor detected infrared heat
            ledController.Write(27, PinValue.High);
            Debug.WriteLine("Detected! Turn the LED on.");
        }
        else
        {
            // turn the led off when the sensor undetected infrared heat
            ledController.Write(27, PinValue.Low);
            Debug.WriteLine("Undetected! Turn the LED off.");
        }

        Thread.Sleep(1000);
    }
}

Hardware Required

  • PIR Motion Sensor - HC-SR501
  • LED
  • 220 Ω resistor
  • Male/Female Jumper Wires

Circuit

circuit

HC-SR501

settings

  • VCC - 5V
  • GND - GND
  • OUT - GPIO 17

LED

  • VCC & 220 Ω resistor - GPIO 27
  • GND - GND

Result

result

Product Compatible and additional computed target framework versions.
.NET Framework 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
1.2.869 136 9 days ago
1.2.864 141 9 days ago
1.2.852 153 a month ago
1.2.822 103 2 months ago
1.2.775 106 2 months ago
1.2.772 101 2 months ago
1.2.755 104 2 months ago
1.2.737 88 3 months ago
1.2.696 108 4 months ago
1.2.673 123 6 months ago
1.2.631 122 7 months ago
1.2.590 117 9 months ago
1.2.570 114 10 months ago
1.2.560 124 5/29/2024
1.2.548 98 5/15/2024
1.2.436 307 11/10/2023
1.2.416 144 11/8/2023
1.2.329 232 5/26/2023
1.2.313 195 5/12/2023
1.2.297 218 5/3/2023
1.2.217 386 1/6/2023
1.2.203 358 12/28/2022
1.2.159 435 11/14/2022
1.2.153 436 11/5/2022
1.2.141 463 10/25/2022
1.2.122 494 10/12/2022
1.2.114 450 10/8/2022
1.2.95 492 9/22/2022
1.2.87 569 9/15/2022
1.2.73 476 9/8/2022
1.1.116.8772 506 6/24/2022
1.1.113.2032 485 6/23/2022
1.1.58.10097 508 5/23/2022
1.1.3 529 4/15/2022
1.1.1 498 4/14/2022
1.0.300 506 3/31/2022
1.0.277-preview.126 143 3/25/2022
1.0.277-preview.125 134 3/25/2022
1.0.277-preview.112 132 3/19/2022
1.0.277-preview.110 131 3/18/2022
1.0.277-preview.105 135 3/15/2022
1.0.277-preview.99 139 3/10/2022
1.0.277-preview.98 141 3/8/2022
1.0.277-preview.77 133 2/18/2022
1.0.277-preview.41 150 1/28/2022
1.0.277-preview.32 156 1/27/2022
1.0.277-preview.17 152 1/24/2022
1.0.277-preview.15 143 1/21/2022
1.0.277-preview.13 148 1/21/2022
1.0.277-preview.1 150 1/11/2022
1.0.259 374 12/9/2021
1.0.218 222 10/18/2021
1.0.155 378 8/31/2021
1.0.135 400 7/16/2021
1.0.134 198 7/15/2021
1.0.133 207 7/14/2021
1.0.125 225 7/5/2021
1.0.121 230 6/29/2021
1.0.119 249 6/28/2021
1.0.105 297 5/29/2021
1.0.13 207 5/21/2021