December 15, 2016

DIY Smart Mirror ft. Alexa



Materials

  1. Computer Monitor. Buy used and look for cable inputs that point down or sideways instead of straight out. 22" recommended (I used Acer AL2216)
  2. Video cable. Whatever fits your monitor (I used HDMI to DVI adapter)
  3. Raspberry Pi 3, 16GB Micro SD Card, 5V Micro USB power supply, any RPi case
  4. Wood. I bought four 3ft lengths of 3"x1"
  5. 8 Angle brackets
  6. Short wood screws.
  7. Gorilla glue.
  8. Electrical tape.
  9. Extension Cord with multiple plugs.
  10. 50cm x 70cm Ikea STROMBY frame.
  11. Gila Mirrored Window Film 
  12. USB Sound CardLapel Micany USB powered speaker *
*Bonus Alexa Materials

Additional required tools/supplies are: scotch tape, a squirt bottle, dish soap, a drill or screwdriver, exacto knife, scissors, and a saw.

Creating the Two Way Mirror


The two way mirror is the most essential part of this build. To create this component, you just apply Gila Mirrored Window Film to any piece of glass or acrylic. This works equally well for glass and acrylic, and only takes about 15 minutes.



Ikea STROMBY with Gila Mirrored Privacy Film applied.


Remember, this is a budget solution so there is some compromise in optical quality. It's good enough for a non essential decorative mirror, but probably not a primary bathroom mirror.

Here you will need scotch tape, a squirt bottle, exacto knife, scissors, and a squeegy or scraper. There are lots of videos online with instructions too.

Applying the film:
  1. Fill the squirt bottle with water and add about 0.5 tablespoons of dish soap. Basically just one squirt.
  2. Cut off a piece of reflective film about 1 inch larger than your surface in all directions.
  3. Clean your surface, and then spray generously with dish soap mixture.
  4. Put scotch tape on both corners of the film, and pull it apart to remove the plastic protective liner. Peel the liner, spraying dish soap mixture between protective liner and the film sheet. 
  5. With the film sheet generously coated in soap mixture, lay it flat on your surface. 
  6. Squeegy down the middle, and then from the middle out to the sides. Keep spraying and smoothing until all the air bubbles are gone.
  7. Use scissors or the exacto knife to trim excess materials from edge.

You're done! Let it sit for a while before moving, as it hasn't really stuck in place until all the soap mixture dries. 


Building the frame


This frame simply facilitates holding the monitor, and attaching the mirror to your monitor. It will also serve as the enclosure for your Raspberry Pi.

Building materials


Start by finding a monitor, and ripping the bezel off by removing screws and jabbing a knife or paint scraper in the seam of the monitor. There may be some parts hanging free off the back of the monitor, which can be attached using electrical tape. Insulate the back of any menu buttons with electrical tape as well to prevent short circuiting.


Once you have ripped the bezel off, it's time to build the frame. Use your most basic woodworking skills to size the wood frame, and then use the 90 angle brackets to attached the inner corners. Note, this will be hidden, so you can do an ugly job. I placed 4 small screws in the front and back corners to hold the monitor in place. 


Wooden monitor bezel

I also painted my frame black for aesthetic reasons, however it's completely hidden by the frame overhang, so this is not necessary.

Sticking it all Together 


Now we need to attach our mirror and monitor. I did this by cutting a hole in the rigid frame backing of my Ikea frame, and gorilla gluing some angle brackets to the backing to attach to the outside of the frame.


Lining up monitor over frame backing with removed section(right).

The hole in the frame backing was done using multiple passes of an exacto knife. Then I lay the monitor flat over the hole, centred everything, and used the all surface gorilla glue to fasten 4 angle brackets around each edge. I used 3d printed parts for this, but any 90 degree bracket with sufficient strength will work. 

Once the glue has set, you simply screw the bracket into the monitor frame.


Gorrilla glue setting on 90 degree angle bracket. 


It's up to you how to arrange your components. I punched some holes in the frame to run wires for my speaker and mic using a drill, and another trough for the power cable using a hand saw.

My pi case is just wedged in place. I should probably glue that or something... 

Raspberry Pi Setup


So you've built your hardware! That's awesome, now it's time to get the raspberry pi running the  MagicMirror and Alexa software. Of course the first step is just getting an operating system. I strongly recommend raspbian jessie, which already has a great install guide.

Once the Pi starts up, run the following in terminal to get the software up to date:

$> sudo apt-get update
$> sudo apt-get upgrade

You should also follow these steps to enable VNC Viewer, a remote desktop tool that allows to you acces your RPi desktop from any computer on the same network. This lets you work remotely once you've finished the initial setup, without plugging in a keyboard and mouse.

Install MagicMirror

With the basic setup done, we will now install the core application called MagicMirror. There is a guide on the website to install MagicMirror, but it didn't entirely work for me.

First I had to update NodeJs and electron:

$>curl -sL https://deb.nodesource.com/setup_4.x — Node.js v4 LTS "Argon"  | sudo bash -
$>sudo apt-get install nodejs
$>sudo npm install electron

Then I downloaded and installed magic mirror using:

$> curl -sL https://raw.githubusercontent.com/MichMich/MagicMirror/master/installers/raspberry.sh | bash

If these run succesfully, you can just navigate to the MagicMirror directory, and run:

$>npm start

This should show the default dashboard. To edit this, navigate to the MagicMirror/config/config.js file and add custom location, calenders, moldules, etc.

There are also some additional configuration details regarding screen orientation, screensaver settings, and wifi.

Installing Alexa

If you've already got a computer on your wall, you may as well add some voice interaction. This can be done by installing and running Alexa on your raspberry pi as well. I covered this in a previous post.

Alexa and MagicMirror will then run simultaneously on the same raspberry pi (at about 25% CPU). I am hoping to create some skills to change the magic mirror layout, add to do lists, etc, but for now it's just stock Alexa.

Congratulations, now you've got a smart mirror, and maybe a personal assistant! Have fun never looking at your smart phone again. If you'd like to add some custom behaviour to Alexa, checkout this post on how to do it.



55 comments:

Unknown said...

Hi there!

Firstly, Thank you so much for taking the time to post a full detailed guide on how to do this.

I would really like to do this project but I had a few question I was hoping you could answer.

Would it be possible to do all the software setup (Raspberry Pi 3, and Alexa) on a mac? As i don't have access to Windows.

Also, I have no prior experience coding but I'm pretty sure I can follow the guides fairly easily.
Is the software setup too difficult or do you reckon I would be able to do it?

Secondly, Do you think it would be possible to do this project with the following dimensions? about 80x100, as I'd like to have this mirror in my foyer as soon as you walk in.

Lastly, Does the mirror look proper when it's turned off, as I'd like it to still be fully functional as mirror.

In your opinion, would the quality of the mirror be good enough to see as soon as you walk through the door? as you said it's probably not good enough as a primary mirror but in the photos and videos it seems to be pretty good quality.

Thank you so much!
Keep the guides coming cyber omelette!!

Ben Eagan said...

Hey unknown, I'm glad you liked the guide! Yes, this is very possible using a mac, and dimensions shouldn't be a problem so long as you can build it. Turned off the mirror looks great. I would suggest you buy some of the mirrored window film to test if it would be good enough for your foyer.

Anonymous said...

Hi man! I loved your mirror, I think it's one of the best I've seen.

Little question here, it's possible to command Alexa to play some music? I was wondering if I could use one of the USB ports of Raspberry for a flash drive, or make a folder in the SD card, and save music there for Alexa to play it... Do you think it's possible? If you could tell me at least a basis of how to do that, it would be awesome.

Thanks man, and happy holidays.

Ben Eagan said...

Hey Anonymous, thanks! It is definitely possible to play music. I think the easiest way is simply to link Spotify to your Amazon account (https://support.spotify.com/us/listen_everywhere/on_speaker/spotify-amazon-speakers/)
. You can also us Amazon Music which gives you a small free storage space for around 100 songs.

Getting music to play from the hard drive isn't as obvious though, and is something I'd also like to get working. I think you would have to write your own skill, but it shouldn't be too difficult.

Matthew Jones said...

Awesome guide! I'm new to raspberry pi and this gave me the confidence to jump in on my own project. One quick question though; how does the on/off and power cord situation work? Two separate plugs, monitor standby mode makes sense but what about the rpi? Mostly just out of curiosity

Ben Eagan said...

The raspberry pi is on as long as it's powered. You can shut it down using the "halt" or "shutdown" commands, and you turn it on by providing power. Mine stays on all the time for this. I'm not sure I understood the question properly, but hopefully that helps. I'm glad to hear this is getting you started!

Anonymous said...

Hi, great looking mirror - quick question, using GILA mirrored film you mentioned the quality is lower, do you mean the quality of it as a mirror or the transparency of it, making the LCD not come through as bright? Also how does this work in low light, does the mirrored film lose the mirror effect or does it become clear in low light? Again great looking smartmirror and thanks for the write up!

Ben Eagan said...

Thanks Anonymous! GILA suffers most for crispness of reflection. Letters come through perfectly, but reflection is softened. Low light is good, but in a totally dark room you see some
monitor glow.

Unknown said...

Hello, anyone have a good config file??

Anonymous said...

Hi, thank you for posting this tutorial. I've got a raspberry pi for Christmas and intend to recreate this project with an old 42" tv. (might have to compromise on it if it proves to difficult)
I have a couple questions about setting up the speaker/mic.
I hope to skip the speaker installation part because the tv had speakers. However I'll need a microphone and I wonder I should use a webcam? maybe use skype on it later on? Do you recommend going this route? I don't know much about the pi yet so I wonder if the tv speakers will work at all?

Ben Eagan said...

Hey Anonymous, sounds like a good use for the TV! I'd love to see a picture once you get it going... Using the speakers sounds like a great idea, all you need is the 3.5mm audio jack as an input. So depending on how you pass audio to the TV, it should be simple to run it out of the Pi audio jack. Webcam would be an interesting addition too... I'd suggest getting it running on its own with the Pi first. Then you can work on the configuration details through MagicMirror or scripts.

Matilda said...

Hey! I love this tutorial. As someone completely unaware of how to code or do any tech work, what would you say the difficulty level of this is? Is it a good learning project? I really want to get into more tech-savvy crafts and this one appeals to me the most.

Ben Eagan said...

Thanks Matilda! I think you could probably get started with this project, but I would treat each step as it's own mini project. Just getting the raspberry pi setup would be the best place to start. Then you can try installing MagicMirror, and build the frame / mirror. I'd suggest adding Alexa last, as it's probably the hardest and least essential. Still pretty manageable though! Feel free to send questions my way as you work on it.

Unknown said...

Excellent guide. I see that you keep yours powered on all the time, but is it possible or is there an easy way to at least be able to power off the monitor? I assume the power button still works but it may just be hidden behind the mirror. I've just been thinking of possible solutions to conserve some energy.
-Eric

Ben Eagan said...

Hey Eric, I actually have a crontab script to turn mine off at night, and on again in the morning.

On:
#!/bin/bash
tvservice -p
fbset -depth 8
fbset -depth 32

off:
#!/bin/bash

tvservice -o


I'm hoping to do a followup post with tips and tricks like this one.

שחר צוק said...

is it important to use res pi 3 or can i use 1/2?

Eric Hand said...

Being new to Raspberry Pi's, I have another question you may be able to answer - could you also use the same pi to host the adblocker pi-hole?
-Eric

Ben Eagan said...

To answer the previous comment.. not sure about pi 1/2, worth a shot if you've got one lying around.

Eric, the only restriction will be CPU performance. Mine sits at about 50% with alexa and magic mirror going, I expect you could easily tack Pi-Hole on top of that. Give it a try!

Eric Hand said...

Thanks again for the info. I'm ordering the materials for mine and will hopefully get started on it next week! I already have a 22 in monitor that I don't use and I'm going to see if I can build one in a 16x20 shadow box frame.

שחר צוק said...

Is there a way to sync the calendar to the one on my phone?

Ryan said...

I've managed to get the software running, but after a while when running alexa and the smart mirror app at the same time, my raspberry pi freezes. Any suggestions

Ben Eagan said...

Hey Ryan, I think the first things to check are that you're giving sufficient voltage to the Pi, and that it isn't overheating. There are lots of tutorials if you google "get raspberry pi temperature". I would also make sure you followed the apt-get update and apt-get upgrade commands at the start of the Raspberry Pi config in this tutorial.

Good luck, and let me know how that goes. I should mention that since I've left Alexa running (about 1 month), I have had one case of the app crashing for unknown reasons. If yours is freezing (becoming unresponsive), then these are likely not related.

Anonymous said...

I know its probably unlikely but would their be any ways to do this with an aurduino

jbryanz1 said...

Hi There, great tutorial, i have set alexa up on my Pi however, im in england and the times are wrong, is there anyway of correcting this? any help much appreciated

jbryanz1 said...

dont worry ive fixed it! If anyone else has this issue you need to download the alexa app to your phone, select your Pi and change your location.

Anonymous said...

Will plexi glass work, and look okay

Ben Eagan said...

Hi Anonymous, plexiglass works well. It's what I built my prototype with.

שחר צוק said...

hey, I was wondering if there a way to sync the mirror with an android based calendar?

Ben Eagan said...

Yes it absolutely can be synced with android calendar. Checkout the magicmirror2 pages on config files to see how.

Anonymous said...

Hello I have a question I do not have a raspberry pi 3 at the moment but I found one of my old raspberry pi 2 will this still work with the pi 2?

Ben Eagan said...

Hey Anonymous, I haven't tried it myself as I don't have a pi 2 - but I am pretty confident it will work just fine. There is a 100% chance you can get magic mirror going, but I'm not sure about Alexa voice assistant.

Why not try getting the software running on what you have, and if it works you can proceed with the hardware mirror aspect?

Let me know how it goes too please!

Mr Teavhagun said...

Hi great work on your smart mirror. I was able to get Alexa to work on my magic mirror by following your thorough instructions. My question is how do I automatically run Alexa every time I turn on my Pi? Do you have the cron/script that you just execute? Care to share? Thanks!

Ben Eagan said...

Hey, nice work Mr Teavhagun! Care to share a picture of the finished product?

Unfortunately I still haven't solved that problem. I do run a "tvon" and "tvoff" script though to turn my monitor on and off, and then I leave the Pi running 24/7.

Scripts can be found here:
https://gist.github.com/benrules2/f3ddef15ce0c268226b172b61c98adb1

Mr Teavhagun said...

I'll take a pic once I get home. Sorry for not being specific, I followed this steps:

https://github.com/alexa/alexa-avs-sample-app/wiki/Raspberry-Pi

Step 7: Run your web service, sample app and wake word engine

Now that installation is complete, you'll need to run three commands in 3 separate terminal windows:

Terminal Window 1: to run the web service for authorization
Terminal Window 2: to run the sample app to communicate with AVS
Terminal Window 3: to run the wake word engine which allows you to start an interaction using the phrase "Alexa".

Can this be combine in one cron/batch file script so whenever I reboot by Pi, it will automatically launch Alexa?

Ben Eagan said...

The trouble is the 2nd command requires user interaction in a web browser, so automatically running them doesn't successfully start Alexa. Maybe you could use an automated GUI tool to get around it, but I think a new App is required that authorizes by device.

Mr Teavhagun said...

Thanks for your response. Will do some more research.

Carter's said...

My Alexa install was going so well until I tried to run it ". automated_install.sh" then it just freezes. Has anyone had this issue? its driving me mad

Ben Eagan said...

Hey Carter, a couple questions for you. Are you using the Raspbian Jessie distro? Does the whole system lock up, or just the script (will it respond to ctrl-c or ctrl-z)? Any output before it freezes?

Carter's said...

Hi Ben, thanks for getting back to me. I've managed to get it loaded. After I started to run the programme I would hit a pager page. This I now know gives you the opportunity to not install certain parts of the programme should you wish. When you scroll to the bottom of the page you get the option to "q to quit". After that the programme carries on loading until it completed.

Vageesh Vasisht said...

Can you tell how you get it to display in magic mirror. my whole setup is complete. Just could find how display is configured for in config.js

Ben Eagan said...

In the MagicMirror directory there is already a sample config that can be modified. If you run "npm start" from the MagicMirror directory, what happens?

Vageesh Vasisht said...

Ben Eagen .. It starts magic mirror and alexa is running in background fine but i was looking for something like sine wave that is displayed on Magicmirror when you say wakeword. That doesn't show up.

Mohammed Al-Azazi said...

Hey Ben,

How did you hang the magic mirror?

Ben Eagan said...

Hey Mohammed, I just found two wall studs and put screws in the wall sticking out about 1cm. Then I just placed the frame onto the screws, and the heads bit into the soft wood. I would probably recommend buying some framing wire though, as if these bent over time it could be bad!

Anonymous said...

Hi Ben,

First of all, great work! I'm building this one :)
There is only one question i have at this moment. You said "Alexa and MagicMirror will then run simultaneously on the same raspberry pi (at about 25% CPU)", are you sure about that? I tried both on the same RPi3 but it got a bit slow and Alexa wasn't responding that well. So i installed them on their own RPi3 and it works a lot better, especially Alexa but the wakewordagent is using like 85% of the CPU using Sensory (kitt_ai stopped after a few questions). Like to know how you got the CPU load at 25%, even when running both on one RPi3? :D

Thanks!

Bob

Ben Eagan said...

Hi Bob,

Glad to hear you're working on one of your own! If you have two pis, I can't see any reason to squeeze these both onto the same device.

I checked again though and my CPU usage sort of bounces between 25-35%, though that's between 4 cores. If I run "top -o %CPU" I see wakewordagent taking 100% (one core), and all other processes are less than 10%.

My only explanations for instability would be high enclosure temperatures, or the background noise increasing load on wakewordagent somehow.

If you've got two though, may as well use 'em!. I'd be interested to see how they look arranged in your enclosure together too. Fire over some links in these comments if you feel like sharing!

Anonymous said...

Hi Ben,

Thanks for your answer!

The Pi with Alexa is telling me the following when i do top -o %CPU:

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
18477 pi 20 0 124648 9632 6696 S 326.9 1.0 20:41.75 wakeWordAgent

As you can see, almost al 4 cores.

I will post some links when it' s ready! First gonna try to figure this out :)
Backnoise doesnt seem to be the problem as turning off the mic don't make any difference.

Bob

Ben Eagan said...

Bob, wow you weren't kidding about high cpu usage! Do you get the same results using kitt_ai (even if it crashes)? Feel free to pass on any other clues you may uncover if you want a second mind on it.

Anonymous said...

Hi Ben,

Kitt_ai is showning me i bitt less usage, but still around 300%.
Can't find anything about this on the internet and can't figure it out myself as i'm not a linux expert. It seems i just have to love with it and go on building :P Going to check your page about giving the mirror commands through Alexa :)

Bob

Anonymous said...

I ment live with it, but loving it as well ;)

Unknown said...

This is great, I got through setting everything up and Alexa worked first try, but then when I tried again, it didn't recognize me saying "Alexa." Can anybody help as to why this stopped working?

Justin Haskell said...
This comment has been removed by the author.
Colton Pinner said...

work's great I just am having trouble changing the time zone
"please help" !!!!!

Ben Eagan said...

Hey Colton, going to need more info than that. What's the problem? Time zone for your pi, or Alexa? Should just be an option in the settings either way.

Colton Pinner said...

Yeah it was I had the settings wrong in my pi, thank you :)

Post a Comment