Read the statement by Michael Teeuw here.
[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
FiskarenEdit: 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.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!
-
This post is deleted! -
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?
-
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!