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.

    PIR-Sensor - put your mirror to sleep if not used

    Scheduled Pinned Locked Moved Troubleshooting
    126 Posts 37 Posters 235.5k Views 20 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.
    • M Offline
      MechMatt @paviro
      last edited by

      @paviro any suggestions on what relay to get for use with this? There are lots of choices on amazon

      IngmarSwartI 1 Reply Last reply Reply Quote 0
      • P Offline
        Patrick
        last edited by

        Ok. When I’ve time, I will get a wireless transmitter.
        Would be embarrasing if it wouldnt work because I’ve never tried :anguished:

        1 Reply Last reply Reply Quote 0
        • IngmarSwartI Offline
          IngmarSwart @paviro
          last edited by

          @paviro I finally found some time to look into the problem I had some more. The exact origin is still unclear to me, but I did figure out that my problem, it is not related to your module, or the MM software in general. I got the same behaviour over ssh: tvservice -o switches the monitor connected to the Pi off, tvservice -p switches it back on, but the screen would appear black. After fiddling around a little bit, I found another solution that does not require root rights. Instead of using the sudo chvt 7 && sudo chvt 9 command, the problem can also be solved using fbset. My modified version of the activateMonitor function file node_helper.js:

          activateMonitor: function () {
              if (this.config.relayPIN != false) {
                gpio.digitalWrite(this.config.relayPIN, this.config.relayOnState)
              }
              else if (this.config.relayPIN == false){
                exec("/opt/vc/bin/tvservice -p", null);
                exec("/bin/fbset -depth 8 && /bin/fbset -depth 16 ", null);
                exec("/usr/bin/xrefresh",null);
              }
          

          For the command xrefresh to work when given via ssh, the correct display variable has to be set (in my case):
          export DISPLAY=:0 I have added this line to my .profile file in the /home/pi directory so that I don’t have to type it every time I log in via ssh.

          1 Reply Last reply Reply Quote 1
          • IngmarSwartI Offline
            IngmarSwart @MechMatt
            last edited by

            @MechMatt Have a look at the PowerSwitch Tail. If you live in the US, you can buy an assembled version from Adafruit. If you’re in 240V land (like me), you will have to do some (basic) soldering. Works like a charm for me. :-)

            1 Reply Last reply Reply Quote 0
            • KirAsh4K Offline
              KirAsh4 Moderator
              last edited by

              That’s really odd that you have to go through all of that. On my rPi-3 with the most recent Raspbian Jessie release, I can use 'tvservice -o' and 'tvservice -p' and it just works. I don’t have to do anything else. It’s all running as the unprivileged user 'pi' (and without issuing 'sudo' before each command.) I wonder if it has something to do with the monitor and what it responds with when a signal is sent … Glad you figured it out though.

              A Life? Cool! Where can I download one of those from?

              IngmarSwartI 1 Reply Last reply Reply Quote 0
              • IngmarSwartI Offline
                IngmarSwart @KirAsh4
                last edited by

                @KirAsh4 I agree, it’s very strange. Like you, I am using a rPi-3 with the most recent version of Raspbian Jessie and run everything as user pi. So maybe it is the monitor (Philips 273V5l). Which one do you use?

                Although the problem is fixed, I would like to know what is going on.

                1 Reply Last reply Reply Quote 0
                • KirAsh4K Offline
                  KirAsh4 Moderator
                  last edited by

                  Let me get home and get you the details on it. It a monitor we had sitting around at the office, some high end graphic Pro monitor that wasn’t being used anymore. I also have a test I want to perform on it, see if that makes a difference in what I’m seeing. Stay tuned.

                  A Life? Cool! Where can I download one of those from?

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    joerod @paviro
                    last edited by

                    @paviro I donwloaded to node 5.0.0 and I know get the following error

                    Failed at the magicmirror@2.0.0 start script 'electron js/electron.js'.
                    
                    paviroP 1 Reply Last reply Reply Quote 0
                    • paviroP Offline
                      paviro @joerod
                      last edited by

                      @joerod That’s all? Not a failure of my plugin. Any more logs?

                      We're all stories in the end. Just make it a good one, eh?

                      – The Doctor

                      J 1 Reply Last reply Reply Quote 0
                      • T Offline
                        Try2Fly
                        last edited by

                        For people who are not confortable with programming this, or need to buy a pir sensor anyway

                        You can also buy a pir with motionsensor like this

                        1 Reply Last reply Reply Quote 0
                        • J Offline
                          joerod @paviro
                          last edited by paviro

                          @paviro

                              9 verbose stack Error: magicmirror@2.0.0 start: `electron js/electron.js`
                              9 verbose stack Exit status 1
                              9 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:214$
                              9 verbose stack     at emitTwo (events.js:87:13)
                              9 verbose stack     at EventEmitter.emit (events.js:172:7)
                              9 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14)
                              9 verbose stack     at emitTwo (events.js:87:13)
                              9 verbose stack     at ChildProcess.emit (events.js:172:7)
                              9 verbose stack     at maybeClose (internal/child_process.js:817:16)
                              9 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
                          

                          I’ve tested my PIR sensor with a Python script to make sure I’m using the proper GPIO and its functioning as it should. I do see 1 & 0 when I move near the sensor so I don’t think its the hardware.

                          I’d love to use this module, I was going to do it in python but since you have it in JS I figured why not use that.

                          paviroP 1 Reply Last reply Reply Quote 0
                          • paviroP Offline
                            paviro @joerod
                            last edited by

                            @joerod please use Markdown on code snippets so it is easier to read! :) have you installed all the dependencies (also for the mirror itself?)
                            @MichMich any idea?

                            We're all stories in the end. Just make it a good one, eh?

                            – The Doctor

                            J 1 Reply Last reply Reply Quote 0
                            • MichMichM Offline
                              MichMich
                              last edited by

                              Sorry, no clue. :(

                              1 Reply Last reply Reply Quote 0
                              • J Offline
                                joerod @paviro
                                last edited by

                                @paviro I had to downgrade to node 5.0.0, I confirmed its that version of node. After the downgrade I removed the PIR module and did a git clone and then npm install in the folder. Still the same thing, is there a specific version of node 5 I should be using or a specific version of npm?

                                I’m running it from
                                /home/pi/MagicMirror/modules/MMM-PIR-Sensor

                                paviroP 1 Reply Last reply Reply Quote 0
                                • MichMichM Offline
                                  MichMich
                                  last edited by

                                  Could you try it with node serveronly ?

                                  1 Reply Last reply Reply Quote 0
                                  • paviroP Offline
                                    paviro @joerod
                                    last edited by

                                    @joerod also do npm install on the mm folder or install the whole thing from scratch :)

                                    We're all stories in the end. Just make it a good one, eh?

                                    – The Doctor

                                    1 Reply Last reply Reply Quote 0
                                    • D Offline
                                      DirkS @paviro
                                      last edited by

                                      @paviro as a feedback: i used the latest MMM branch and yours and it is working fine with my PIR sensor on a rpi2. I didn’t had to downgrade anything to node 5 (and i also don’t know what it is :D ) Thanks for your work. It is so great that the mirror is starting if a presence is detected!!

                                      paviroP 1 Reply Last reply Reply Quote 0
                                      • paviroP Offline
                                        paviro @DirkS
                                        last edited by

                                        @DirkS glad to hear! :)

                                        We're all stories in the end. Just make it a good one, eh?

                                        – The Doctor

                                        1 Reply Last reply Reply Quote 0
                                        • M Offline
                                          MechMatt
                                          last edited by MechMatt

                                          Hey Everyone!
                                          I am trying to use this module to turn off/on a tv and im having a bit of trouble on the physical end of things… I got the module working perfectly (tested it with PIR and hdmi on/off). Now I am trying to use a relay with the PIR sensor to have the TV screen itself turn on and off. I was planning on wiring this to the TV power button (so it is essentially the same as pressing the on/off button).

                                          I got the relay working… and I was about to take apart my tv when i thought…will even work for the on/off button? When it senses movement it will send the signal and then … turn off the tv I guess. As soon as the movement is undetected it stops sending the signal (or really pulse in this case)… just stopping wouldn’t turn the tv back on either. I guess it needs to send a pulse when it stops detecting movement, and then another one when it does again. Am I thinking about this wrong? Should I wire it to something else? Thanks in advance

                                          M 1 Reply Last reply Reply Quote 0
                                          • M Offline
                                            MechMatt @MechMatt
                                            last edited by

                                            @MechMatt On second thought, im having trouble with the relay as well… could you post a wiring diagram for the pi, relay, and tv? I’m not the best at electronics

                                            1 Reply Last reply Reply Quote 0

                                            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
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 7
                                            • 4 / 7
                                            • 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