MagicMirror? What’s that?
If you combine something slightly transparent and reflective with some data you get a MagicMirror. Some people also call them «SmartMirrors».
Basically it’s just a display with a spy mirror in front of it.
On my mirror I display the weather, date, time, train connections, calendar entries and the water temperature of lake Zurich. Since this is more or less just a website (Electron), almost anything can be displayed.
Building a MagicMirror is a very popular project to do with a Raspberry Pi and it is also quite easy to build.
Sounds cool! What do I need to make one myself?
Hardware
To build your own MagicMirror, you need at least:
- A Raspberry Pi and an SD card
- A display, for example an old computer monitor
- A spy mirror (a film/foil may also work but it will probably not look as good as glass)
- HDMI and power cables for your Pi and monitor
- A frame (wood, metal, cardboard, whatever you fancy)
If you want to take it a step further you can also get some parts for your RasPi like a motion sensor, a camera, a button/switch, some lights or any other peripheral you can think of.
Software and technologies
- Raspbian/Raspberry Pi OS: Your Pi will run on Linux, so having some basic bash knowledge is nice-to-have. If you have never used Linux, it’s very easy if you just look up the few commands you will need.
- MagicMirror²: The actual software that is running your MagicMirror. You can think of it as just a browser which runs your «Mirror webpage» with some modules.
There are already a lot of modules for everything you can think of. In this list there is even my own module, MMM-SwissLakeTemperature 🙂. - HTML/CSS/JavaScript: Since it’s just a webpage, all the modules are built with web-technologies. There is a Node.js-Server running the application. If you want to write your own module you need some JavaScript/Node.js skills (or time and patience to learn).
- JSON: The configuration in which you will set up all your modules is written in JSON. Easypeasy.
- (Optional) SSH: «Secure Shell». With SSH you can access your RasPi from another computer if it is connected to the internet.
So for example you can run your RasPi which is connected to your Wi-Fi and access it from your main computer and configure it from there.
Building the Mirror
Putting everything together can be pretty easy and fast, depending on how much you want to customize your mirror.
Software
For the basic setup, just follow the official MagicMirror Documentation. This should be pretty straight forward and how to use the modules is also described. In every module’s github page is documentation on how to configure it.
Once your MagicMirror is running and setup how you like it, you may want to make sure that your mirror automatically runs the MagicMirror everytime you boot your RasPi (when your mirror is hanging on the wall you do not want to take it down to plug in your mouse/keyboard or ssh into it everytime). This can be done with the process manager pm2. Once again, just follow the detailed instructions. If you run into problems with starting pm2, this thread from the MagicMirror forum might help.
Hardware
Take apart your old monitor, stick all your RasPi parts and cables on it’s back. Then, together with your spy mirror, put it in a frame and hang it wherever you like.
Easypeasy, right? 🙂
…
NO, WRONG! >:(
This is the part where I actually spent the most time, because I thought it would be cool to add a motion sensor to turn on the mirror.
The motion sensor (aka «I do what I want sensor»)
I connected my PIR (motion sensor) via GPIO to my RasPi and configured it like it was described in this forum post. I started testing it and it worked… sometimes. Mostly it would just turn on by itself, with no motion nearby (so a «false positive»). I adjusted the hardware-dials on the PIR to be very unsensitive and only pickup a motion when it is right in front of it.
The PIR still had it’s own mind, turning on randomly every minute.
After a lot of tinkering, some research and looking for help, I found the problem. The PIR is affected by the Wi-Fi signal of my router. It somehow picks up the signal, thinks this was a motion and then turns on the mirror. Very annoying, because when I turn off Wi-Fi on the RasPi, it works perfectly. But because I fetch data from the web, I obviously have to turn this on.
I tried shielding the cables for the PIR with some tin foil, which seemed to help a little but it was not as effective as I wished. In the end I just hanged the mirror near my entrance, a bit further away from the router. Here the Wi-Fi signal is not as strong and there are very few false positives from the PIR.
If you have a proper solution to this problem, please let me know.
On/Off Button
To safely turn off the mirror (just pulling the plug could damage the RasPi), I added a small button to turn on/off the mirror. This is a good tutorial on how to do it.
The frame and putting everything together
I am lucky to have a roommate that is a carpenter, he made the whole frame and helped me assemble the mirror. All the electronics are just sticked to the back of the monitor (it’s not pretty, but hey, it works).
Cost of the project
Component | Price (CHF) | Bought at | Necessary |
---|---|---|---|
Raspberry Pi 3 | 75 | Digitec.ch | ✔ |
Raspberry Pi Heatsink Kit | 11.40 | Digitec.ch | ✘ |
Display | 0 | (old monitor) | ✔ |
Spy Mirror | 72.20 | Brigla.de | ✔ |
Spy Mirror Samples | 31.70 | Brigla.de | ✘ |
Spy Mirror delivery and customs | 20.40 | DHL | ✔ |
HDMI Cable 0.5m | 8 | Galaxus.ch | ✔ |
HDMI Angled Adapter | 6.95 | Galaxus.ch | ✘ |
Extension cable 1m | 7.75 | Galaxus.ch | ✔ |
Twin cable socket adapter | 8.05 | Galaxus.ch | ✔ |
Motion sensor, buttons, delivery | 26.50 | Bastelgarage.ch | ✘ |
M-F Jumpercable | 6.75 | Galaxus.ch | ✘ |
Frame | 21.50 | Carpenter friend | ✔ |
Total | 296.20 |
2 Comments
Very cool 😀
I always wondered how this works. Thank you very much for sharing!