Read the statement by Michael Teeuw here.
working module Raspberry Pi 4 and PIR?
-
OK, I had that in mind, my problem is, when my monitor turnes on, it start some kind of splash screen that is pink/purple with Benq logo before it’s totally tuned on, I find that so annoying to see. That’s the reason I’m not going that path :)
-
@DariBer
Another solution is to create a script to run the command “xset dpms force off” to turn off the monitor and “xset dpms force on” to turn it on.
Use this video as an example to create something similar. -
I give a lot of courage for find ;)
-
@bugsounet your standalone solution is archived, so not very helpful .
-
-
https://github.com/paviro/MMM-PIR-Sensor
I’m using it with raspi zero W with sensor and works great -
how does your config.js file look like for that module?
Would you be kind and show it? -
I’ve done this by putting a relay directly in the backlight circuit. Connect the PIR to 5V and a gpio pin, and the relay to 5V and another GPIO pin. Use wiring pi and a simple bash script to get the state of the PIR and energize/de-energize the relay appropriately. It’s really simpler than it sounds and requires little to no knowledge of electronics.
You need to first install wiring-pi
sudo wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb
Here’t the script I run at startup to control it - works great.
#!/bin/bash # # Runs in the background to switch backlight on or off # depending upon the state of the PIR motion sensor. # # Usage: nohup backlightd [-r|-f] 0<&- &>/dev/null & # -r log on loghost # -f log locally (default) # # Set as configured PIR=18 # GPIO BCM number of PIR sensor BACKL=15 # GPIO BCM number of backlight relay OFF_DEL=60 # Minimum number of seconds to keep backlight om ON_DEL=2 # Minimum number of seconds to keep backlight off TIMO=3600 # Maximum number of seconds to wait for edge event # # Set for local policies PRIO=local.info # if using rsyslog set priority TAG=backlightd # and tag to use on loghost LOGFILE=/var/log/backlightd.log # if using local syslog file PATH=/bin:/usr/bin # error handling xit() { rlog "Line $1 Err $2 - $3 - exiting"; exit "$2"; } die() { rlog "Exit signal received - exiting"; exit 0; } # logging case $1 in -r) rlog() { /usr/bin/logger -p "${PRIO}" -t "${TAG}" "$1"; } ;; *) rlog() { /bin/echo "$1" >>"${LOGFILE}" ; } ;; esac cd / || xit $LINENO $? "Cannot cd to / ?!?" reset(){ # reset gpio pins, set initial conditions gpio edge "$PIR" both \ || xit $LINENO $? "Cannot set edge GPIO$PIR" gpio export "$BACKL" out \ || xit $LINENO $? "Cannot set export GPIO$BACKL" PIR_STATE=$(gpio -g read "$PIR") \ || xit $LINENO $? "Cannot read GPIO$PIR" gpio -g write "$BACKL" "$PIR_STATE" \ || xit $LINENO $? "Cannot write to GPIO$BACKL" } trap reset SIGUSR1 trap die SIGTERM reset while true do timeout "$TIMO" gpio -g wfi "$PIR" both ; STAT=$? if [ "$STAT" -eq 124 ]; then rlog "gpio wfi timed out after ${TIMO}s - respawning" STAT=0 fi [ "$STAT" ] || xit $LINENO $STAT "gpio wfi terminated abnormally" PIR_STATE=$(gpio -g read "$PIR") \ || xit $LINENO $? "Cannot read GPIO$PIR" gpio -g write "$BACKL" "$PIR_STATE" \ || xit $LINENO $? "Cannot write GPIO$PIR" if [ "$PIR_STATE" ] then sleep "$ON_DEL" else sleep "$OFF_DEL" fi done
-
@DariBer Please see this document… this is how I use my PIR to turn off the screen when no one is in front of it.
https://www.thedigitalpictureframe.com/pir-motion-sensor-raspberry-pi-digital-picture-frame/