Read the statement by Michael Teeuw here.
PIR Sensor - Sleep LCD monitor
-
I connect directly to the output legs of the switch.
-
Great idea!
Mine has a power button that you lightly touch and the monitor turns on or off (see pic https://goo.gl/photos/2rnRtovAJpCvTZXp7 ) This means that the button doesn’t have an on or off position. Would this mean that I’d need to get the Pi to send a short pulse to turn the monitor on or off or would it be continuous power to turn it on and no power to put into standby?
Did you manage to avoid having a splash screen when it enters or leaves standby? (See video https://goo.gl/photos/QnGRPccautfSnBCt8 ). This is really important to me!
One idea I thought of is to find an internal wire that provides power to the screen and install a relay there as well. Then run the script as follows;
- When movement detected activate power relay 1
- Wait 5s for splash screen to finish
- Activate power relay 2 which allows power to the screen
Good work on the mirror by the way,
Steve![0_1491074010177_20170401_205947.jpg](Uploading 100%) -
Hello, Have you already solved this issue? I am with the same idea, I have the PIR, a 3.3V relay and a python script so that, when it detects presence, the relay is activated and makes contact on the button to turn the screen on or off.
The sript I’m using is this:
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setup(22, GPIO.IN) GPIO.setup(25, GPIO.OUT) GPIO.setwarnings(False) while True: if GPIO.input(22): GPIO.output(25, GPIO.HIGH) else: GPIO.output(25, GPIO.LOW)
PIR output is connected on pin 22 (BCM). Relay input is connected on pin 25 (BCM).
This simple script works correctly, but I want to go one step further. With this crypt, the screen is turned on or off when detecting presence.
My idea is that (when the screen is off), when detecting presence, the screen will turn on for a while (for example 5 minutes), and then turn off again.
For that purpose, I made this modification on the original script:
import RPi.GPIO as GPIO import time import commands GPIO.setmode(GPIO.BCM) GPIO.setup(22, GPIO.IN) GPIO.setup(25, GPIO.OUT) GPIO.setwarnings(False) while True: if GPIO.input(22): GPIO.output(25, GPIO.HIGH) commands.getoutput('vcgencmd display_power 1') time.sleep (300) commands.getoutput('vcgencmd display_power 0') else: GPIO.output(25, GPIO.LOW)
But this modification doesn’t work. Could someone help me with this? My knowledge in python is very elementary
-
take a look at point 5.2 ;)
u can define a delay time
-
@cruunnerr
I’ve tried that script yesterday, but it didn’t work for me. Thanks anyway -
Finally, I’ve finnished my script, and it works like a charm. I paste it here if someone else need it.
#!/usr/bin/python3 # PACKAGES NEEDED TO WORK: sudo apt install python3 python3-rpi.gpio # My screen has an USB port, that turns on when screen is on, and off when screen is off. # So, I made a voltage divider with a few resistors to get 3 volts, to activate pin 6 (BCM) # on the raspberry Pi. In this way, the script can 'know' if Screen is ON or OFF. import RPi.GPIO as GPIO import time import subprocess from subprocess import call GPIO.setmode(GPIO.BCM) GPIO.setup(22, GPIO.IN) # PIR's output GPIO.setup(6, GPIO.IN) # Screen power detector GPIO.setup(25, GPIO.OUT) # Relay Input GPIO.setwarnings(False) while (GPIO.input(6) == 0): # IF SCREEN IS ON if (GPIO.input(22) == 1): # PIR DETECTS MOTION call(('/opt/vc/bin/vcgencmd', ' display_power', '1')) GPIO.output(25, GPIO.HIGH) # RELAY ACTIVATION time.sleep(3) GPIO.output(25, GPIO.LOW) time.sleep(60) # THE TIME WE WANT THE SCREEN TO STAY ON if (GPIO.input(22) == 1): # IF PIR DETECTS A NEW MOVEMENT, time.sleep(60) # ACTIVATES THE MIRROR ANOTHER AMOUNT OF SECONDS else: GPIO.output(25, GPIO.HIGH) # WITH THIS LINE, THE SCREEN POWERS OFF TO SAVE ENERGY time.sleep(3) GPIO.output(25, GPIO.LOW) else: GPIO.output(25, GPIO.LOW) while (GPIO.input(6) == 1): # IF SCREEN IS OFF if (GPIO.input(22) == 1): # PIR DETECTS MOTION call(('/opt/vc/bin/vcgencmd', ' display_power', '1')) GPIO.output(25, GPIO.LOW) # SAME AS ABOVE, BUT THIS TIME DON'T ACTIVATE THE RELAY time.sleep(60) if (GPIO.input(22) == 1): time.sleep(60) else: GPIO.output(25, GPIO.HIGH) # WITH THIS LINE, THE SCREEN POWERS OFF TO SAVE ENERGY, AGAIN time.sleep(3) GPIO.output(25, GPIO.LOW) else: GPIO.output(25, GPIO.LOW) call(('/usr/bin/python3', '/home/pi/SCRIPTS/pir.py'))