MagicMirror² v2.11.0 is available! For more information about this release, check out this topic.

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

  • Hi @DirkS,

    I use a standard first generation RPi camera board. In other words, this solution works perfectly fine with IR filter on the camera.

    The reason I think there might be issues with the RPi2: you should realize that this solution requires the RPi to analyze 10 images per second (give or take a few, you can specify the frame rate) using OpenCV routines. This causes a significant bump in processor load (approximately 33% on the RPi3 on top of everything else, if I’m not mistaken). I simply don’t know if the processor of the RPi2 is fast enough to do the image analysis, run the MM and the operating system simultaneously. The only way to know for sure is to test. I can’t help you with that as I don’t own a RPi2. Should the RPi2 struggle, perhaps you can get away with analyzing fewer frames (5 or maybe even 2). I encourage you to try and report back!

    Best wishes,

  • Hello,
    my module is not working, I have the pir sensor connected to Pin 7 and when you start the screen stays white and nothing happens when I take the pir of the config it goes again.

  • @samydp Maybe you can find the answer here :After rebooting, run MM with pm2 and shows “White Screen”, I checked the pm2 error log shows something like “Expected 49, got 48” as before,
    Run “npm rebuild --runtime=electron --target=1.3.4 --disturl= --abi=49” in the MMM-PIR-Sensor folder,
    Run “pm2 restart mm” and it works.”

  • it is not’ve tried as it stands anyway thanks for your help

  • @IngmarSwart Thats a really nice solution. Did you use the virtual environment from the tutorials? If you did so, how did you wrap them together? Is it even possible? Thanks

  • Since IngmarSwart didn’t connect since few months, maybe someone can just explain me the reason why a PIR sensor is still needed in his config? i don’t get the role of the PIR since there is already a cam to detect the move…? if anyone… thx guys!

  • @Defibrillat0r: Thanks. Yes, I use the virtual environment. That being said, I don’t think it is stricktly necessary. In our configuration, the RPi is dedicated to running the MM, so the likelyhood that you need different versions of packages is very small. If you do use the virtual environment, you just have to make sure all the packages listed at the top of the python file are installed for the virtual environment you are working on. Other than that, no special tricks are needed.

    @bibi: In my solution a PIR sensor is not needed. You only use @paviro’s module to interface the python code with the MM.

  • @IngmarSwart ohh ok now it’s clear! thx alot for your reply.
    your hack is working perfectly so far?

  • @bibi: I’ve only tested my solution for a couple of days, so I can’t say much about the long term stability. The reason for this is simply that I was in the process of designing a (nearly) frameless mirror the last couple of months. The components have been ordered and I hope to assemble everything in the coming month. It might take a bit longer, as I have quite a few business trips lined up for November.

  • @IngmarSwart I see i am still getting everything but in meantime i am working on the software side. You solution is nice and i will try to implement it i think… with my noob skills :)))