• 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 and 7 inch touch LCD display for Raspberry-Pi

Scheduled Pinned Locked Moved Solved Troubleshooting
9 Posts 3 Posters 3.7k 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
    Serimner
    last edited by Oct 10, 2019, 7:37 PM

    Hello,
    Maybe this question has been put to the wrong forum, but I chance.

    I’m trying to use the Raspberry-Pi 7 "touch LCD with a PIR sensor.
    My goal is to have a photo frame with MM information. When no activity is detected, I want the screen to turn black (powersave) but when the PIR sensor detects activity, the screen should light up.
    I have tried all the modules that have to do with PIR sensors, but none of these work for me. At the start of MM I get a black screen with a mouse pointer, nothing more …

    My question is - is there anyone in this forum that has built something similar?
    If so, do you have any tips ?!

    //B

    S 1 Reply Last reply Oct 10, 2019, 7:41 PM Reply Quote 0
    • S Away
      sdetweil @Serimner
      last edited by Oct 10, 2019, 7:41 PM

      @Serimner tell us more, when did you install, how did you install, what modules did u add.
      open the developers window, ctrl-shift-i,. select the tab labeled ‘console’ and scroll up to see any errors,
      usually red text…

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      S 1 Reply Last reply Oct 10, 2019, 9:33 PM Reply Quote 0
      • S Offline
        Serimner @sdetweil
        last edited by Oct 10, 2019, 9:33 PM

        @sdetweil
        Hi Sam,
        I have installed this on my PI:
        Raspbian Buster 4.19
        MagicMirror v2.8.0
        Node v10.16.3
        pm2 v3.5.1
        I have installed this using the installationguide the provide (I’m real noob at this).

        The module I have tested most is MMM-PIR-Sensor (https://github.com/paviro/MMM-PIR-Sensor)
        My configuration:

        module: "MMM-PIR-Sensor",
        position: "fullscreen_below",
        config: {
        	sensorPin: 22,
        	powerSaving: true,
        	powerSavingDelay: 1,
        }
        

        But I can see in the code that MMM-PIR-Sensor uses vcgencmd!
        When i test “vcgencmd display_power = 0/1” from terminal it do not work om my hardware.

        If I try “echo 0/1 > /sys/class/backlight/rpi_backlight/bl_power” it works fine but…
        Every time MM updates its view, MM resets bl_power and light up the screen.
        (BTW, I have testet my PIR-sensor in Python and it works as expected…)

        //S

        S 1 Reply Last reply Oct 10, 2019, 9:36 PM Reply Quote 0
        • S Away
          sdetweil @Serimner
          last edited by Oct 10, 2019, 9:36 PM

          @Serimner so, rather than call the vcgencmd, call your python script, do what it does

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • S Offline
            Serimner
            last edited by Oct 11, 2019, 10:12 PM

            @sdetweil - Thank you for your feedback.
            It was one of the ideas I tested. The problem is that when MM updates its view (or the weather updates), bl_power is reset and the screen lights up again…

            /S

            1 Reply Last reply Reply Quote 0
            • Q Offline
              qu1que Project Sponsor
              last edited by Oct 12, 2019, 10:39 AM

              @Serimner Some time ago, when I was making my mirrors, I’d tried some PIR modules, and I could not make it work any of them. So, I’d write this python script and works perfect. Hope it helps:

              #!/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'))
              

              Here you can take a look at one of my projects:
              https://forum.magicmirror.builders/topic/7263/my-first-smart-mirror-in-a-frame-of-40-x-30-cm-with-raspberry-pi-zero-w/2

              1 Reply Last reply Reply Quote 0
              • S Offline
                Serimner
                last edited by Oct 13, 2019, 11:40 AM

                @qu1que - Thanks for your reply - really smart to use USB on the screen to see screen activity!
                But unfortunately vcgencmd does not work in my configuration/hardware.
                It sets the value, but it does not turn off the 7 inch touch LCD…

                Q 1 Reply Last reply Oct 14, 2019, 7:33 PM Reply Quote 0
                • Q Offline
                  qu1que Project Sponsor @Serimner
                  last edited by Oct 14, 2019, 7:33 PM

                  @Serimner

                  In this link explains how to do it for that screen:
                  https://www.raspberrypi.org/forums/viewtopic.php?f=108&t=120968&start=25

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    Serimner
                    last edited by Oct 15, 2019, 9:01 PM

                    Thanks for the posts with help and ideas!
                    I have tried further and am currently testing with “xset” to turn off/on the screen and it seems to work well.

                    I have “stolen” code and ides from these articles:
                    Cheap PIR Sensors and the Raspberry Pi - Part 1
                    Exit screensaver on Raspberry Pi with motion sensor
                    So I will not publish any code… :-)

                    //Serimner

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    1 / 1
                    • First post
                      1/9
                      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