MagicMirror² v2.5.0 is available! For more information about this release, check out this topic.

PIR Sensor - Sleep LCD monitor



  • Hi,

    I want to sleep my LCD Monitor with the plugin MMM-PlR-Sensor.
    But I don’t cut my front panel LCD, can you validate my schema, please ?

    0_1489582610690_MagicMirror PIR.jpg



  • Hi,

    I think that you may be trying to achieve the same thing as me. Is your aim to have the Pi send a signal to the power button of the tv screen so that it enters sleep mode? Personally, I think that this is a good solution since it should avoid the “no signal” issue which occurs when the module cuts the HDMI signal.

    I assume that you plan to use “relayPIN” option to set the output pin to the tele but how do you determine the correct voltage and signal to send or is it a standard?

    As I say, I think that this could be a great way of allowing the mirror to switch the monitor on or off neatly (ie. avoiding splash screens or “no signal” messages). Happy to offer my help in this but, regrettably, I have very little experience or knowledge.

    Let me know how you get on,
    Steve



  • Thank you for your help, I spent part of my weekend on the project.
    I change my mind, I do not think it’s good to put the 5v on the front panel !!
    So I went through a relay and it works.
    I just have to find the best way for the relay to trigger only when a person triggers the PIR and after a delay, triggers to pause.
    Sorry for my English !!

    0_1490000505400_MagicMirror PIR v2.jpg



  • @Andromede88

    Sorry for my lack of understanding but how did you connect the relay to the switch? Also what sort of switch is it?

    (http://www.electronicshub.org/switches/)

    Keep up the good work,
    Steve



  • I connect directly to the output legs of the switch.

    0_1490004769823_MM2.jpg



  • 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;

    1. When movement detected activate power relay 1
    2. Wait 5s for splash screen to finish
    3. 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





  • @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'))