Skip to content

serhat-m/hc-sr501-sensor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js based API for the HC-SR501 motion detector.

Connect sensor

Import

const { HCSR501 } = require("hc-sr501-sensor")

Constructor HCSR501(sensorPin, delay)

Parameters

  • sensorPin You have to specify the GPIO pin where the sensor is connected to.
  • delay This parameter is optional. You can specify a delay in milliseconds to stop motion detection. The smallest number is 3000.

Example

const sensor = new HCSR501(17, 3000)

sensor.watch((motion) => {
    // motion = boolean
    if(motion) {
        // do something
    } else {
        // do something else
    }
})

About

Node.js based API for the HC-SR501 motion sensor

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published