• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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 10.5k 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.
  • A Offline
    Andromede88
    last edited by Mar 15, 2017, 1:00 PM

    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

    1 Reply Last reply Reply Quote 0
    • S Offline
      steve23p9835908
      last edited by Mar 19, 2017, 9:23 AM

      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

      1 Reply Last reply Reply Quote 0
      • A Offline
        Andromede88
        last edited by Mar 20, 2017, 9:03 AM

        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

        S 1 Reply Last reply Mar 20, 2017, 9:40 AM Reply Quote 0
        • S Offline
          steve23p9835908 @Andromede88
          last edited by Mar 20, 2017, 9:40 AM

          @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

          1 Reply Last reply Reply Quote 0
          • A Offline
            Andromede88
            last edited by Mar 20, 2017, 10:13 AM

            I connect directly to the output legs of the switch.

            0_1490004769823_MM2.jpg

            1 Reply Last reply Reply Quote 0
            • S Offline
              steve23p9835908
              last edited by steve23p9835908 Apr 1, 2017, 7:33 PM Apr 1, 2017, 7:10 PM

              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
              • Q Offline
                qu1que Project Sponsor
                last edited by qu1que Jul 6, 2018, 9:51 AM Jul 6, 2018, 9:49 AM

                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
                • C Offline
                  cruunnerr
                  last edited by Jul 6, 2018, 10:13 AM

                  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

                  Q 1 Reply Last reply Jul 6, 2018, 10:30 AM Reply Quote 0
                  • Q Offline
                    qu1que Project Sponsor @cruunnerr
                    last edited by Jul 6, 2018, 10:30 AM

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

                    1 Reply Last reply Reply Quote 0
                    • Q Offline
                      qu1que Project Sponsor
                      last edited by qu1que Jul 9, 2018, 12:31 AM Jul 9, 2018, 12:20 AM

                      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