MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. fiskaren
    3. Best
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    F
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 12
    • Groups 0

    Posts

    Recent Best Controversial
    • RE: [SEMI-SOLVED] PIR-sensor wake screen

      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!

      posted in Troubleshooting
      F
      fiskaren
    • 1 / 1