MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    [npm library] @bugsounet/pir

    Scheduled Pinned Locked Moved Development
    1 Posts 1 Posters 242 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ? Offline
      A Former User
      last edited by

      @bugsounet/pir

      I created this library if you want use a pir sensor in your module.
      This library is very simplified and ready for use in your node_helper.js

      This library is used in MMM-Assistant2Display

      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.
      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 Reply Last reply Reply Quote 1

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • 1 / 1
      • First post
        Last post
      Enjoying MagicMirror? Please consider a donation!
      MagicMirror created by Michael Teeuw.
      Forum managed by Sam, technical setup by Karsten.
      This forum is using NodeBB as its core | Contributors
      Contact | Privacy Policy