Project Overview
This project creates a smart mirror that displays information (time, weather, calendar) when someone approaches, and turns off the display when no one is present. The PIR sensor detects motion and triggers the display via Raspberry Pi. The two-way mirror makes the display invisible when off.
Difficulty: Advanced
Estimated time: 4-6 hours
Estimated cost: $100-150
How It Works
A PIR sensor mounted on the mirror frame detects when someone approaches. A Raspberry Pi runs MagicMirror software that displays information. When motion is detected, the Pi turns on the monitor. After a period of no motion, it turns off the display.
Materials Needed
- Raspberry Pi 4 (1)
- Monitor/LCD panel (19-24 inch)
- Two-way acrylic mirror sheet cut to size
- Wood frame to hold mirror and monitor
- HC-SR501 PIR sensor (1)
- 5V relay module to control monitor power
- Jumper wires
- USB power for Pi (5V 3A)
- Power strip for monitor and Pi
Smart Mirror Construction
- Remove monitor bezel carefully, keeping LCD panel and controller board
- Build wooden frame slightly larger than LCD panel
- Secure LCD panel inside frame
- Place acrylic mirror sheet over LCD, shiny side facing out
- Secure Raspberry Pi and power strip behind mirror
- Drill small hole in frame and mount PIR sensor at bottom edge
Circuit Diagram
Connection Table
| Component |
Pin |
Raspberry Pi GPIO |
PIR Sensor |
OUT
GPIO 4
Relay Module |
IN
GPIO 17
表
Raspberry Pi Setup
- Install Raspberry Pi OS Lite
- Install MagicMirror²: git clone https://github.com/MichMich/MagicMirror
- Configure MagicMirror modules in config.js
- Set up autostart on boot
Python Script for Motion Detection
#!/usr/bin/env python3
import RPi.GPIO as GPIO
import subprocess
import time
PIR_PIN = 4
RELAY_PIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIR_PIN, GPIO.IN)
GPIO.setup(RELAY_PIN, GPIO.OUT)
GPIO.output(RELAY_PIN, GPIO.LOW)
display_on = False
last_motion = 0
TIMEOUT = 60
def monitor_on():
global display_on
if not display_on:
GPIO.output(RELAY_PIN, GPIO.HIGH)
subprocess.run(['vcgencmd', 'display_power', '1'])
display_on = True
def monitor_off():
global display_on
if display_on:
GPIO.output(RELAY_PIN, GPIO.LOW)
subprocess.run(['vcgencmd', 'display_power', '0'])
display_on = False
try:
while True:
motion = GPIO.input(PIR_PIN)
if motion:
last_motion = time.time()
monitor_on()
if display_on and (time.time() - last_motion > TIMEOUT):
monitor_off()
time.sleep(0.5)
except KeyboardInterrupt:
monitor_off()
GPIO.cleanup()
Installation Steps
- Build mirror frame with LCD and two-way mirror
- Mount Raspberry Pi behind mirror
- Install PIR sensor on frame edge
- Connect relay to control monitor power
- Install software and motion script
- Approach mirror to test display activation
- Adjust timeout in script as desired
Project Extensions
- Add microphone for voice commands
- Add camera for facial recognition
- Add touch overlay for interactive features
- Add DHT22 to display room conditions
- Display doorbell camera when motion detected
Conclusion
This smart mirror combines functionality and style, displaying useful information only when you need it with PIR activation.