DIY Smart Mirrors and how to make one

leviathan

Snores like a puppy
Joined
Oct 7, 2007
Messages
2,469
Location
Frankfurt
Car(s)
Tesla Model 3
Since this topic has sparked some interest in my Tesla PYC thread, I thought I'd make a writeup on it in here. This should cover the bases for most everything involved - what Smart Mirrors are, how they work, and what do you need to get and do to make one of your own. Let's get started.

WTF is a Smart Mirror?

It's a mirror that can display not just your face, but also various other stuff around and on top of it. Starting from something very basic that just shows the time and maybe outside weather:

1581788315618.png

And all the way up a fully customized display with calendar entries, weather forecast, public transport information, fuel prices, stocks/crypro prices, travel times to upcoming events, local news, random jokes from the Internet... the list goes on:

IMG_0252.jpg

As the more tech-inclined among the readers may have guessed, that's because it's not just a mirror but more of a computer screen that also doubles as a mirror. The computer behind it is connected to the Internet, and runs custom software to show all the stuff you want.

How does it work?

Instead of an actual, not-at-all-seethrough mirror a smart mirror uses one of the following:
  • A proper, expensive one-way mirror, aka. "spy mirror". It's a special kind of mirror glass that reflects light coming from one side, but lets light from the other side through. The sort you find in interrogation rooms in various TV series, where the investigators will hide behind and observe the interrogation while staying unseen themselves.
  • A cheaper option that does the same thing, just not quite as nicely: a piece of acrylic glass covered with a one-way mirror film. This kind of film can be bought online, and is typically offered as a heat-reflecting and darkening layer for large glass facades or windows, that mirrors the glass from the outside but still allows you to look out. These usually don't allow for quite as good an image on the smart mirror as proper spyglass, and can be a pain the arse to apply without bubbles (think: huge screen protector), but are much cheaper and easier to get in the right size (just cut down to what you need).
The mirror glass (either kind) is mounted so that it reflects the light coming from outside, but allows bright light from the monitor behind it to be visible. Where the screen stays black, it's just a mirror - maybe not as 100% reflective as a normal modern mirror is, but still. Where there's white or otherwise bright text and stuff, it becomes visible instead. Voi-la.

How do I get one?

I believe there are some offered commercially. Probably for a lot of money. However, the reason we're all here is making one yourself - which also opens up all the possibilities.

The good news is: it's not rocket science. The hardware build isn't very complicated, and the software is all open-source and basically ready to run off the shelf with minimal configuration. You can of course make it as complex as you need/want - but the basics I'll be covering here are fairly simple.

Ok, what hardware do I need for a DIY mirror?

Now you're asking the right questions. The basic list goes something like this:
  • A piece of mirror glass in the size you want. Either of above mentioned options will do. For a first build I'd probably go with the acrylic+film option - the "proper" one-way mirrors can be really expensive.
  • A monitor to put behind that mirror glass. Here you again have two options:
    • Make the monitor behind the mirror full-size, allowing you to show stuff on the whole mirror surface.
    • Or put a small-ish monitor in one part of the mirror only, blacking out the rest. This way you can make a larger mirror (e.g. a vertical full-body-height one), but don't need to put a whole TV screen behind it.
  • A frame of some kind to hold the two together. It can be a picture frame from IKEA, something custom-made, or (as in the case of my mirror above) simply some tape or other method of mounting that's not an actual frame.
  • A wall mount to attach it to a wall. Or a stand to put it wherever.
  • A computer to run the thing. The typical choice is a Raspberry Pi. The 3B or 4 will do nicely, with built-in WiFi to get the online data it's the simplest option on the table. Don't forget a microSD card to install and run the software from, a power brick, and a fitting monitor cable (typically microHDMI to HDMI).
Another piece that is entirely optional, but I highly recommend to use to save a lot of running cost on the mirror:
  • A PIR sensor. It's a cheap and simple motion detector, that will allow to turn the screen off while no-one is there and turn it back one when someone walks in front of it, instead of running the screen all the damn time and wasting electricity. The go-to choice is a HC-SR501, they go for a couple $ on eBay, and can be plugged straight into the GPIO pins of the Raspberry Pi.
As for actually building the mirror from the pieces, I'll not go into too much detail, but instead link a couple of tutorials / build logs that I've looked at when building mine. It should be enough inspirational material to get you somewhere close to a complete smart mirror:
Googling "smart mirror build" will bring up a million more like those.

How do I get the software to run it?

The go-to software package for a Raspberry Pi-based smart mirror is MagicMirror². It's open source, free to use, looks decent, and comes with over a hundred community-contributed modules for diplaying all kinds of stuff you might find useful or entertaining.

The steps to getting it on your Raspberry Pi are:

1) Install the operating system - Raspbian Desktop

If you know how to do this and have used a Raspberry in some manner before: get Raspbian Desktop on the card, make sure you can talk to it via SSH, then skip all the way to MagicMirror installation.

If you don't, follow these steps:
  1. Download the latest Raspbian Desktop image (without the "recommended software") for your Raspberry Pi: https://www.raspberrypi.org/downloads/raspbian/
  2. Download balenaEtcher (the software for writing the image to the SD card) on your PC/Mac: https://www.balena.io/etcher/
  3. Insert the microSD card into the computer. Run balenaEtcher, flash the Raspbian image to the card, then eject it and insert it into the Raspberry Pi.
  4. Connect your Raspberry Pi up to a monitor, and plug in a keyboard and a mouse. You'll only need the latter for the initial configuration, later the mirror will work without them ofc.
  5. Connect power to the Raspberry Pi and let it boot up. Follow the configuration prompts to setup your WiFi, language/locale and other initial config stuff.
  6. Open up the "Raspberry Pi Configuration" in the menu and change the following things:
    1. Set the hostname to "raspi-magicmirror" or something similar
    2. Enable SSH under "Interfaces"
  7. Reboot the Raspi, make sure it shows a good WiFi connection after it's booted up. Congrats, you have a working Raspberry Pi to run a mirror on. Proceed with next step.
If some or all of the above was too confusing, watch this and copy what he does (it's a bit different but the same end result anyway):

2) Install MagicMirror

2.1 Establish a remote connection to the Raspberry Pi


You can do this on the Pi itself via keyboard/mouse. However, I recommend connecting to it remotely at this point, since you'll want to do it later anyway to change settings or modules on your mirror while it's already installed where you want it and running. To do this:

If you're on Windows:
  • Download PuTTY: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html. Choose the "Windows Installer"
  • Install and run it.
  • As "Host name", enter: raspi-magicmirror.local (replace "raspi-magicmirror" with whatever hostname you've given your Raspi in the configuration step before, keep the ".local")
  • Hit "Open"
  • Enter "pi" as the username and whatever password you set in the configuration (the default is "raspberry"... you should really change it)
  • On a successful connection, it'll print some information about your Raspberry.
On a Mac:
  • Open up a Terminal.
  • Type "ssh pi@raspi-magicmirror.local" (replace "raspi-magicmirror" with whatever hostname you've given your Raspi in the configuration step before, keep the ".local")
  • Enter whatever password you set in the configuration (the default is "raspberry"... you should really change it)
  • On a successful connection, it'll print some information about your Raspberry.
Congrats, you can now control your Raspberry Pi from your computer. Disconnect the keyboard and mouse from the Pi if you haven't yet, you won't need them anymore.

2.2 Actually install MagicMirror

Follow the "Manual installation" instructions at https://docs.magicmirror.builders/getting-started/installation.html.

Congrats, you now have an actual MagicMirror software running on your Raspberry Pi. If you've already installed the monitor and the Pi in your mirror, I guess you now have a fully functional Magic Mirror.

Continue with the "Configuration" instructions at https://docs.magicmirror.builders/getting-started/configuration.html#raspberry-specific to optimize some aspects of you Raspi for use as a MagicMirror, and to set up some basic configuration like the overall zoom factor, time format etc.

Read up some basics on using a Linux command line if you need to: https://electronicshobbyists.com/most-basic-and-commonly-used-raspberry-pi-commands/

3) Customize the crap out of it

The beauty of MagicMirror² is that you can and indeed should fine-tune it to your own delight.

Dig into the default module docs to figure out how to configure them for yourself: https://docs.magicmirror.builders/modules/introduction.html

And of course check out https://github.com/MichMich/MagicMirror/wiki/3rd-party-modules for a (probably incomplete) list of stuff that you can add to the mirror.

To make adding/changing/reconfiguring modules easier, I can recommend using WinSCP to connect to the Raspi via SFTP - then you can edit files (including config files) using your editor of choice on your computer, instead of through nano or vim on the command line.

How does that motion sensor you mentioned work?

Get the module for it here: https://github.com/paviro/MMM-PIR-Sensor. Install it as described in the Readme. For configuration, this is what mine looks like:

Code:
{
    module: 'MMM-PIR-Sensor',
    config: {
        sensorGpio: 17, // you can choose any other GPIO pin, check the pinout below
        powerSaving: true,
        turnOffAfterSeconds: 90
    }
},

Save the configuration, and turn off your mirror (run "shutdown -h now" in the terminal and wait for the screen to turn off, the unplug power). Plug in the HC-SR501 PIR sensor into the Raspi GPIO pins like so:

1581793058649.png 1581793136853.png

Turn the mirror back on. After you move in front of the sensor once and then don't move for 90 seconds, the screen should turn off. It should turn back on again if you move, with a slight delay.

That's it.

For now anyway. Discuss :) And post results if you end up deciding to make one of these yourself.
 
Last edited:
Thought I'd maybe add the list of modules I use myself, as inspiration/basis for anyone lost in all the options. Here goes:

IMG_0252.jpg

Top left:
  • Clock (standard module)
  • Calendar(standard module; uses ICS format links to my private calendars, formerly Google Calendar, now Fastmail, and shows upcoming events)
Top right:
Bottom left:
Bottom right:
 
Nope, I can't resist. Can you show me how to make one that isn't a mirror? ?

I'd love to make one and I already have relevant data to display on it, probably will just make a wall-mounted display because I could do without my mug frightening me every morning.
 
Nope, I can't resist. Can you show me how to make one that isn't a mirror? ?

I'd love to make one and I already have relevant data to display on it, probably will just make a wall-mounted display because I could do without my mug frightening me every morning.
At that point just look at your phone? lol
 
For almost 4 years, the mirror that the 1st post is all about hung on my wall, with the pane of mirror glass literally taped on the screen, and the whole thing screwed to the wall with a cheap VESA mount.

Well not anymore! Now there's a frame around it :) Also a better monitor (LG IPS panel with much better contrast / black value than the old TN) and a Raspberry Pi 3B instead of the previously used 2B inside - so basically it's a completely new mirror.

IMG_0620.1024.jpeg


IMG_0616.1024.jpeg
 
Top