@iwaldrum said in 27" custom framed magic mirror - fun to get done:
I’d love to hear how you have your motion sensor setup with fullpageOS. On my todo list…
This is far from perfect but it appears to work for me. Generally the screen is dim when I look at the mirror from afar or an angle but if I walk near it, it comes to life. I’m using the cheapie ol’ HC-SR501 motion sensor for this. I think I got a 5 pack for like 5 bucks on eBay. I actually have my sensor dangling at the bottom of my mirror, essentially aiming at the floor. These things are pretty darn sensitive it seems.
I essentially have the sensor hooked up to the Pi and and have converted the following Python script to a service that runs at startup. The monitor still has power but the HDMI signal is essentially disabled when motion isn’t detected with the tvservice command (whatever it is! ha).
/home/pi/motiondetector.py
import os
import subprocess
import time
from gpiozero import MotionSensor
pir = MotionSensor(4)
while True:
pir.wait_for_motion()
print("Motion!")
subprocess.call(["/bin/sh","/home/pi/scripts/refresh"])
os.system("tvservice -p; fbset -depth 8; fbset -depth 16")
pir.wait_for_no_motion()
print("No motion...")
os.system("tvservice -o")
The sources I used to cobble this together:
Install gpiozero
https://gpiozero.readthedocs.io/en/stable/
I think I had some issue getting the gpiozero module to load, but this thread looks familiar. I think the issue is I started with Jessie Lite.
https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=126320
Script as service
http://www.diegoacuna.me/how-to-run-a-script-as-a-service-in-raspberry-pi-raspbian-jessie/
Sensitivity Adjustment (this takes some tinkering for sure)
http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-hc-sr501-motion-sensor-tutorial/
You could probably gather all this with a few minutes of googling but I figured I’d share what I’ve cobbled together so far. A short range IR type sensor may be better if you only want the screen to activate when you get right in front of it, if you just want some mostly automated way of turning the screen off, this should work though.