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.

    My first smart mirror in a frame of 40 x 30 cm with Raspberry Pi Zero W

    Scheduled Pinned Locked Moved Show your Mirror
    5 Posts 2 Posters 11.4k Views 2 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.
    • qu1queQ Offline
      qu1que Project Sponsor
      last edited by qu1que

      At the moment I only have the modules by default and some simple ones from third parties. In the future I hope to add some more, such as a presence detector to turn on the monitor when it detects movement. I’d like to show you some pictures of the project.

      If you prefer, you can watch a video on youtube about my mirror in this link:
      https://www.youtube.com/watch?v=JmT4wroDmCY (WITHOUT THE PIR AND THE RELAY)

      https://www.youtube.com/watch?v=a5RfCQVqrJo&t=6s (WITH THE PIR, RELAY AND SCRIPT WORKING)


      0_1527600294590_2013-11-26 15.32.28.jpg

      0_1527600460622_IMG_20180514_232826_pequeña.jpg

      0_1527600527366_IMG_20180527_201828_pequeña.jpg

      These little holes are for, from left to right:
      1 - infrared receiver for the remote control of the controller board.
      2 - led status of the screen, also included with the controller (on: green / off: red).
      3 - pushbutton to turn on / off the screen (for now also the rpi zero is turned off, since it is connected to a usb of the controller, in the future I hope that the screen can be turned off independently).
      4 - Activity LED of the raspberry (you have to follow these simple steps: https://sudomod.com/forum/viewtopic.php?t=1113).
      5- RESET button (if the raspberry is hanging, it is a hard reset).

      0_1527601092486_IMG_20180528_232838_pequeña.jpg

      0_1527601353326_IMG_20180528_234543_HHT_pequeña.jpg


      HARDWARE:


      0_1527602707788_IMG_20180529_125530_pequeña.jpg

      The Power Supply I’m using is a 12 V DC 2 A and works great for the controller board + raspberry Pi Zero W.


      DETAILED VIEW


      0_1527602929892_IMG_20180529_125422_pequeña.jpg

      0_1527603200284_IMG_20180529_125441_HHT_pequeña.jpg

      0_1527603364352_infrarrojo.jpg

      0_1527812996812_photo_2018-06-01_02-23-22.jpg

      0_1527603524750_IMG_20180529_125626_pequeña.jpg


      FINAL RESULT


      0_1527604682494_IMG_20180529_162004.jpg


      NEW UPDATE (2018-07-09): INSTALATION OF THE PIR AND RELAY TO SWITCH ON/OFF SCREEN AUTOMAGICALLY


      Well, I’ve finished my mirror installing the motion detector (PIR) and the relay. I’ve installed too one 18650 battery in case there is a blackout.

      The basic idea of the motion detector is that when nobody are near the mirror, it turns off the scree, but the raspberry is still running. When somebody aproax the mirror, it turns on the screen. The PIR output goes into an input GPIO of the raspberry (22, BCM), then, on pin 25 (BCM) goes the input to the relay (output from the raspberry GPIO). And finally, the screen detector as an input to the GPIO (pin 6 BCM). It’s a simple circuit from the USB port of the controller board of the screen that is on level HIGH (3v) when screen is on, and level LOW (0v) when is off.

      Here you can take a look at the script written in python for this purpose:

      #!/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 are some pictures of the back face of the mirror:

      0_1531143321488_photo_2018-07-09_15-34-52.jpg

      0_1531143349822_photo_2018-07-09_15-34-41.jpg

      Detail of the PIR on the back face of the mirror…

      0_1531143427906_photo_2018-07-09_15-34-27.jpg

      … and on the front face. I’ve made an 8 mm hole for the PIR detector (I think is a phototransistor, but I’m not sure)

      0_1531143483954_photo_2018-07-09_15-34-49.jpg

      Detail of the micro SD Extender to easily extract te micro sd card.

      0_1531143561440_photo_2018-07-09_15-34-45.jpg

      I’ve made a voltage divider with a few resistors to get 3 volts from the USB port of the screen. When the screen is on, the USB is on too, and vice versa. The 3 volts output of this voltage divider goes to pin 6 (BCM) of the raspberry.

      MATERIAL’S LIST


      • Laptop screen from a 10 years old Airis laptop (owned, not buyed).

      • Controller board for that screen:
        https://www.amazon.es/gp/product/B0722Q7HX3/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1

      • One power supply 12 V - 2 A (owned, not buyed).

      • A cheap frame (not exactly this model, but similar):
        http://www.leroymerlin.es/fp/320202_milo1z1haya1z1marco/milo-haya-marco-milo-haya-marco

      • A raspberry pi zero W:
        https://uk.pi-supply.com/products/raspberry-pi-zero-w

      • 12" x 12" Acrylic mirror:
        https://www.amazon.com/gp/product/B017ONH3EG/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1

      OPTIONAL:

      • One 3mm blue LED and two switches like these:
        https://www.amazon.es/gp/product/B072TSNZJ1/ref=oh_aui_detailpage_o03_s00?ie=UTF8&psc=1

      • Micro sd card extender
        https://es.aliexpress.com/item/48CM-60CM-TF-Male-to-micro-SD-card-Female-Flexible-Card-Extension-cable-Extender-Adapter-reader/32811147746.html?spm=a2g0s.9042311.0.0.3c4d63c06dnylM

      • 18650 Battery Shield USB Port with USB to Micro-USB Cable for Raspberry Pi and Arduino
        https://www.amazon.es/gp/product/B07B2JSXQG/ref=oh_aui_detailpage_o08_s00?ie=UTF8&psc=1

      • One 18650 battery cell from the same laptop than the screen.

      • One Step down to get 5 volts from the 12 v of the screen power supply:
        https://www.amazon.es/gp/product/B07142WLXT/ref=oh_aui_detailpage_o05_s00?ie=UTF8&psc=1

      MATERIALS FOR THE MOTION DETECTOR

      • One PIR for motion detection:
        https://es.aliexpress.com/item/Free-shipping-1PCS-LOT-HC-SR501-HCSR501-SR501-human-infrared-sensor-module-Pyroelectric-infrared-sensor-imports/32730387155.html?spm=a2g0s.9042311.0.0.2a4063c02jBYAy

      • One 3v3 Optocoupled relay module:
        https://www.ebay.es/itm/3V-3-3V-Relay-High-Level-Driver-Module-optocouple-Relay-Module-for-Arduino/351748538371?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2060353.m1438.l2649

      1 Reply Last reply Reply Quote 1
      • R Offline
        Ramez
        last edited by

        software tutorial please…
        thanks in advance

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

          I’ve just follow this tutorial:

          http://emmanuelcontreras.com/how-to/how-to-create-a-magic-mirror-2-with-pi-zero-w/

          And there are an image of all the software to burn and just configure with your choices/modules. The problem is that I can’t update it, always give me some error. So I decided not to update it. I hope it helps you!

          Here yo have a link directly to download the image for raspberry pi zero:

          https://mega.nz/#!J2xChCrD!I3lUEsfQP2NoZ91uxlYznIynC_KxyxVp0R68I6yqR4k

          R 1 Reply Last reply Reply Quote 1
          • R Offline
            Ramez @qu1que
            last edited by

            @qu1que many thanks I’ve made my mirror using the pi3 B model and thinking of making another (affordable) one using the zero w model but having some concern about berformance…is it fair enough to handle the MagicMirror only?

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

              @Ramez

              I have tried to install the MagicMirror software from scratch in a raspberry pi zero w and I have not been able to, too many errors that I was not able to solve. In the end I found this image and I got it working. It works well, but not with very demanding modules, rather with the default modules and few others.

              Then there is the problem that I can not update the image because I also get many errors. Anyway, I’m happy with the final result.

              1 Reply Last reply Reply Quote 1
              • 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