Read the statement by Michael Teeuw here.
MMM-PIR-Sensor is turning off the screen when it detects user?
-
@Mar If it is doing the reverse of what you want, swap the comparison of
value == 1
andvalue == 0
of this section in thenode_helper.js
. -
Thanks not sure this worked, looks like the screen shuts off still. Looked through the code and found that “/opt/vc/bin/tvservice -o” shuts off my monitor correctly, but “/opt/vc/bin/tvservice --preferred && sudo chvt 6 && sudo chvt 7” does not turn it back on. When i try it on the command line it says “Powering on HDMI with preferred settings” but it doesnt turn back on.
Also I’m not even sure its shutting down on its own but cant really test that as i dont have a reliable PIR on/off function yet.
edit: well it does look like that command turns the monitor back on as the light stops blinking and stays on, but the screen is just blank
-
@Jopyth
On this line/opt/vc/bin/tvservice --preferred && sudo chvt 6 && sudo chvt 7
changing the 7 to 2 fixed being able to turn the screen back on.
/opt/vc/bin/tvservice --preferred && sudo chvt 6 && sudo chvt 2
The only issue im having with this now seems to be that on a reboot the screen stays on if the sensor is not detecting anyone. Tested with a small script to show the sensor is sending a 0. Then when I trigger the sensor after a boot it shuts off the screen but then everything starts working properly.
-
@Mar This is why when I had mine running I ran outside the mirror…
https://github.com/cowboysdude/Pir-Sensor
The commands for on and off could be replaced with the ones I used then I just ran it at Raspberry pi startup… worked great!
-
@cowboysdude Thanks for the tip, it does seem like a lot less hassle.
-
@cowboysdude Trying to give this a shot, cloned it into /home/pi/Pir-Sensor/ and changed the shutdown/startup files and confirmed they work, running with sh.
/opt/vc/bin/tvservice --preferred && sudo chvt 6 && sudo chvt 2
#! /bin/bash /opt/vc/bin/tvservice -o
In my crontab I have:
@reboot python cd /home/pi/Pir-Sensor/pir.py &
but it doenst look like its doing anything on reboot, ive confirmed the sensor is working correctly and i’ve run the chmod commands.
-
@Mar I kept it really simple on mine… no directories just put the files directly into the root directory… that way didn’t have to figure out paths and such.
Also this has to match how your’s is setup… in the pir.py file:
io.setmode(io.BCM) SHUTOFF_DELAY = 20 # seconds PIR_PIN = 17 # Pin 11 on the board
-
@cowboysdude Great i’ll move it across and keep it simple. And yes my sensor is installed to your default pin. Just so I can get an idea if its working, when would the screen shut off? Is this before MM loads or after?
-
@Mar Because it’s not mirror related it will shut off and turn on if the mirror is running or not … :)
Hang in there it took me a bit to get it working … not being sure how the PIR sensor is setup [should be two screw settings on the sensor one is timing the other is sensitivity]…
-
@cowboysdude Perfect, so I should expect it to shut off by the time the system loads to the prompt.
Yes it has two sensors, one for sensitivity and the other for how long to send the active signal. Suppose I’ll just play around a bit. Maybe i’ll try find the logs for wherever it tells you when cron jobs have run. Not having any luck so far. i might be doing the cron part wrong, i’ve never played around with cron jobs before.
Im thinking its the pir.py script as I’ve done the cron job right I think.
edit: locations of the startup and shutdown script in pir.py need to be updated! Doh!