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.

    [SEMI-SOLVED] PIR-sensor wake screen

    Scheduled Pinned Locked Moved Troubleshooting
    5 Posts 3 Posters 5.0k Views 3 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.
    • F Offline
      fiskaren
      last edited by fiskaren

      Soo… this will be my third troubleshooting thread. Thankful for all the help I’ve got.

      Anyway, the problem now is with PIR-sensor. I simply want the screen to be blacked out when I’m not there and wake when motion is detected. There is a module for this, but from what I understand that module is only made for HDMI monitors. I use the 7" official touchscreen which connects through the DSI-cionnector on the Pi. So I am wondering how to solve this matter? It does not have to be a module or something, I am happy for every solution.

      I have tried google it and there are some solutions. But there are either the problem they assume you know what you do, I don’t. Kinda need a step-by-step guide. Or the solution are made for HDMI.

      And I don’t have to shut down the screen, I understand that is not possible with DSI-screens. I just want it to become black/dark!

      Best regards
      Fiskaren

      Edit: I would be happy if it was possible to just make the PIR send a mouseklick or keystroke as that would solve my problem as well.

      1 Reply Last reply Reply Quote 0
      • F Offline
        fiskaren
        last edited by

        Wow, I actually managed to do this myself. Probably in the worst way ever, and everyone who knows coding will cringe. But at least I’m happy.

        I took the code from a PIR-guide (this one: https://diyhacking.com/raspberry-pi-gpio-control/). Basically just to show how it works. And then I googled as hell for other commands. And finally mashed them togheter to this AWESOME python script.

        //import RPi.GPIO as GPIO
        import time
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(11, GPIO.IN)         #Read output from PIR motion sensor
        GPIO.setup(3, GPIO.OUT)         #LED output pin
        while True:
               i=GPIO.input(11)
               if i==0:                 #When output from motion sensor is LOW
                     print "No intruders",i
                     GPIO.output(3, 0)  #Turn OFF LED
                     time.sleep(0.1)
               elif i==1:               #When output from motion sensor is HIGH
                     import os
        	os.system("xscreensaver-command -deactivate"),i
                     GPIO.output(3, 1)  #Turn ON LED
                     time.sleep(0.1)
        

        And I put this in autostart. So I guess it checks the GPIO every 0.1 second. And I made the true to deactivate xscreensaver. I didn’t even remove the other code so I guess my command line are getting spammed by “No intruders” all the time hahaha.

        This is really the first time coding something. Otherwise I have just followed step-by-step guides when RPIng. So this is a big step for me.

        Anyway, if someone has a better way for this then I am happy to hear!

        johnnyboyJ 1 Reply Last reply Reply Quote 2
        • johnnyboyJ Offline
          johnnyboy @fiskaren
          last edited by johnnyboy

          This post is deleted!
          1 Reply Last reply Reply Quote 2
          • O Offline
            Oliver_Tooth
            last edited by

            HI,

            I’m trying to use your script for the exact same purpose, but for some reason it doesn’t seem to deactivate the screensaver. I’ve tested the script and the PIR sensor is working fine, any ideas?

            F 1 Reply Last reply Reply Quote 0
            • F Offline
              fiskaren @Oliver_Tooth
              last edited by

              @Oliver_Tooth

              Hmm check if you have installed xscreensaver, otherwise reinstall it.

              And also check if you placed the script in the right autostart folder! I sometimes pick the old one.

              Write xscreensaver-command -activate in command line. If it doesn’t active the problem is with xscreensaver!

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