MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    PIR Sensor - Sleep LCD monitor

    Scheduled Pinned Locked Moved Unsolved Hardware
    monitorlcdpir
    10 Posts 4 Posters 11.1k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      steve23p9835908
      last edited by steve23p9835908

      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%)

      1 Reply Last reply Reply Quote 0
      • qu1queQ Offline
        qu1que Project Sponsor
        last edited by qu1que

        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

        1 Reply Last reply Reply Quote 0
        • cruunnerrC Offline
          cruunnerr
          last edited by

          https://forum.magicmirror.builders/topic/6291/howto-turn-on-off-your-monitor-time-based-pir-button-app?page=1

          take a look at point 5.2 ;)

          u can define a delay time

          qu1queQ 1 Reply Last reply Reply Quote 0
          • qu1queQ Offline
            qu1que Project Sponsor @cruunnerr
            last edited by

            @cruunnerr
            I’ve tried that script yesterday, but it didn’t work for me. Thanks anyway

            1 Reply Last reply Reply Quote 0
            • qu1queQ Offline
              qu1que Project Sponsor
              last edited by qu1que

              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'))
              
              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Enjoying MagicMirror? Please consider a donation!
              MagicMirror created by Michael Teeuw.
              Forum managed by Sam, technical setup by Karsten.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy