1.1.0 • Published 2 years ago

@bugsounet/pir v1.1.0

Weekly downloads
80
License
MIT
Repository
github
Last release
2 years ago

pir

single node routine for PIR sensor read

Installation

npm install @bugsounet/pir

In the ending of installation, if you use electron you can do electron rebuild step.

Do you want to execute electron rebuild ? [Y/n]
Your choice:

Sample with pir contructor

const Pir = require("@bugsounet/pir")

this.config = {
  gpio: 17,
  reverseValue: false
}

var debug= false

this.pir = new Pir(this.config, callback, debug)

this.pir.start()
setTimeout(() => { this.pir.stop() } , 5000)

function callback(status, err) {
  console.log("[PIR:CALLBACK] Status: " + status)
  if (err) console.log("[PIR:CALLBACK] " + err)
}

constructor of pir

Pir(pirConfig, callback, debug)

pirConfig {}

  • gpio - BCM-number of the sensor pin.
  • reverseValue - reverse presence detector value.
  • delayed - send presence callback after defined delayed time (ms)

callback (status,error)

callback return with event status:

  • PIR_INITIALIZED: Pir constructor is initialized
  • PIR_STARTED: Pir start detection confirmation
  • PIR_STOP: pir stop detection confirmation
  • PIR_DETECTED: pir user presence detected
  • PIR_ERROR: pir error

callback error return with PIR_ERROR

if error detected, it will return it with error value

debug

if you want debuging information, just set to true

Functions

  • start() : start pir
  • stop() : force stop pir
1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago