[SEMI-SOLVED] PIR-sensor wake screen

  • 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

    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.

  • 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.setup(11, GPIO.IN)         #Read output from PIR motion sensor
    GPIO.setup(3, GPIO.OUT)         #LED output pin
    while True:
           if i==0:                 #When output from motion sensor is LOW
                 print "No intruders",i
                 GPIO.output(3, 0)  #Turn OFF LED
           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

    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!

  • @fiskaren
    Kudos for the appliance used… Mashed or not, if it works, it works! Well done ;-)

Log in to reply

Looks like your connection to MagicMirror Forum was lost, please wait while we try to reconnect.