My first smart mirror in a frame of 40 x 30 cm with Raspberry Pi Zero W
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)
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).
The Power Supply I’m using is a 12 V DC 2 A and works great for the controller board + raspberry Pi Zero W.
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:
Detail of the PIR on the back face of the mirror…
… 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)
Detail of the micro SD Extender to easily extract te micro sd card.
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.
Laptop screen from a 10 years old Airis laptop (owned, not buyed).
Controller board for that screen:
One power supply 12 V - 2 A (owned, not buyed).
A cheap frame (not exactly this model, but similar):
A raspberry pi zero W:
12" x 12" Acrylic mirror:
One 3mm blue LED and two switches like these:
Micro sd card extender
18650 Battery Shield USB Port with USB to Micro-USB Cable for Raspberry Pi and Arduino
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:
MATERIALS FOR THE MOTION DETECTOR
One PIR for motion detection:
One 3v3 Optocoupled relay module:
software tutorial please…
thanks in advance
I’ve just follow this tutorial:
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:
@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?
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.