How to Make a Magic Mirror

353,662

1,867

90

Published

Introduction: How to Make a Magic Mirror

In this project I will show you how I made a Magic Mirror that shows the date, time, some news and a little phrase at the bottom. You will use a Raspberry Pi, a computer screen and a webpage to make it look like you have "a smart mirror".

Everything on the mirror will be in Swedish (on the pictures), but I will translate what you need. I made this with a Raspberry Pi model B, but I will recommend that you use a Raspberry pi 2 or better. The first Raspberry Pi can't really handle the new OS Jessie when the screen is rotated and keep freezing and loosing internet connection. Make sure you are paying attention to if I write just "Raspberry Pi model B" or "Raspberry Pi 2 model B"!

What you need:

  • A computer screen (that you can take apart)
  • An observation mirror or glas and a mirrorfilm
  • A Raspberry Pi with casing + micro USB power cord
  • A SD-card (8GB)
  • A network adapter (for wifi, look at this link, not necessary for Raspberry Pi 3,)
  • Wood frame (boards, screw, glue, paint, drill)
  • HDMI-to-VGA-adapter (depending on if your screen has HDMI or not)
  • A mouse and a keyboard with USB
  • A second computer (for fixing OS and stuff)

Remember to don't take the measurements for the mirror until you have opened the screen. It will be smaller once the plastic is gone!

Also, when you get the screen, make sure that the contacts are on one of the sides and not straight back. If they are straight back, you might get a problem if you want to hang it on the wall later on.

I decided to do my own guide after having a lot of problems during my project, and I figured I could help other people who might end up with the same problems.

I followed these two guides:

http://michaelteeuw.nl/tagged/magicmirror (English, original creator)

http://pcforalla.idg.se/2.1054/1.601411/sa-bygger-... (Swedish)

Step 1: Configurations of the Raspberry

Put your SD-card in the computer and write down the letter (in my case [D:\]). Download Rasbian from raspberrypi.org/downloads. When the ZIP-file is extracted you need Win32 Disk Imager. You can download it at sourceforge.net/projects/win32diskimager/. Install and start it. Klick on the folder icon and browse to the folder where you have the Raspbian files. Make sure that the destination is the SD-card (in my case D:)

As you can see in the "Win32"-image, I'm using Raspbian Jessie.

When the write is successful, you just take the SD-card and put it in your Raspberry. Connect to the computer screen, add a mouse and keyboard, and start it.

In my case, I came directly to the desktop on start. To make the right configurations you need to open the terminal and enter "sudo raspi-config". In there, you are going to do three different things. First, "expand filesystem". Second, choose "Boot Options" and then choose to boot to Desctop GUI with the "pi" user. And third, choose "Internationalisation Options" and change to you own timeszone.

------------------------------------------------------------------------------------------------------------------------------------------------------

After a suggestion by Hansaplast in the comments, here is a link for people who uses Mac.

Mac users can use ApplePi-Baker to flash SD cards for RPI. http://www.tweaking4all.com/hardware/raspberry-pi...

Step 2: Updating, Wifi, Web Server and Screen Rotation

Now, it's time to make sure everything is updated.

Use the terminal again and type in "sudo apt-get update && apt-get upgrade -y", and sit back and relax.

When that is finished, you should create a web server. If you are used to servers and have done this before you can just type "sudo apt-get install apache2 apache2-doc apache2-utils" and "sudo apt-get install libapache2-mod-php5 php5 php-pear php5-xcache"

If you are not used to servers I recommend Raspberrys own webpage. Follow the instructions and there should be no problem, it's a really good guide.

https://www.raspberrypi.org/documentation/remote-a...

The images in this step is exactly what you should get if you've followed the guide correctly.

------------------------------------------------------------------------------------------------------------------------------------------------------

Here could be a good time to install the wifi. It could be done whenever you want basically during the project, but it's usually good to do in the beginning so you have one less cord to worry about.

Since there is so many different wifi modules, I'm just going to tell you too google it here. Use the name of the adapter and "Raspberry Pi install", and you shouldn't have any problems.

Here is again a list for the wifi-adapters that work for the different Pis.

------------------------------------------------------------------------------------------------------------------------------------------------------

We usually want our mirror to be higher rather then wider, so therefore we will rotate the screen!

Screen rotation is really simple! Just type "cd /boot" and then "sudo nano config.txt". Now, you should be in a textfile. Scroll aaaall the way to the bottom, and then add "display_rotate=1" in a new line. This will rotate your screen 90 degrees.

If you have a Raspberry Pi model B, then you should start scrolling up and look for the line "hdmi_force_hotplug=1" and uncomment that. I don't think this is necessary for a Raspberry Pi 2.

Save and exit. The screen will be rotated when you restart the Raspberry. (you can do this now or later)(if you get a black screen when you restart, don't panik! Look at the bottom of this step!)

I my case, I used "display_rotate=3", since my screen had two USB-ports on the side it would be standing on otherwise. So if your screen has a similar thing, you can use =3 without problems! This will rotate the screen 90 degrees in the other direction.

------------------------------------------------------------------------------------------------------------------------------------------------------

If you get a black screen and nothing happens even if you have waited forever, don't panik. Unplug the Raspberry, take the SD-card and plug it in to your computer. There you should see the "config"-file in the list. Open it and uncomment the line "hdmi_force_hotplug=1". If you have a Raspberry Pi model B, I recommend you to only restart after everything is done. The first Raspberry can't handle the screen rotation very well and will freeze repeatedly.

Step 3: Web Browser and Autostart

This is where I know things are starting to get a little different depending on what version of the Raspberry Pi you have. (if you are not used to the terminal, I will add a little guide at the bottom of this step).

If you can't change in the autostart file, you need to make yourself an owner. You do that in the exact same way as you did when you installed the web server. Go back to the guide if needed.

For Raspberry Pi 2 model B: (I'm not sure about Raspberry Pi 3)

You should use Chromium as your web browser. It's installed easy with the command "sudo apt-get install chromium x11-xserver-utils unclutter" in the terminal. To create autostart you should go to the file "/etc/xdg/lxsession/LXDE-pi/autostart". Comment out the third line and put the 4 extra lines in there. Save and exit.

@lxpanel –profile LXDE-pi

@pcmanfm –desctop –profile LXDE-pi

#@xscreensaver –no-splash

@xset s off

@xset -dpms

@xset s noblank

@chromium --kiosk --incognito http://localhost (the adress to your server)

------------------------------------------------------------------------------------------------------------------------------------------------------

I recieved a comment about Raspberry Pi 3 Model B

open the below file
sudo leafpad ~/.config/lxsession/LXDE-pi/autostart

and change to @pcmanfm –desctop –profile LXDE-pi #@xscreensaver –no-splash @xset s off @xset -dpms @xset s noblank @chromium-browser --kiosk --incognito http://localhost and save. Post this on reboot it will open the browser with the localhost as desired. Ensure you know how to open a terminal Ctrl+Alt+T , incase you need it post reboot :-)

-- thinknaive

------------------------------------------------------------------------------------------------------------------------------------------------------

For Raspberry Pi model B:
You should use Midori as your web browser. It's installed easy with the command "sudo apt-get install php5 midori unclutter" in the terminal. To create autostart you should go to the file "~/.config/lxsession/LXDE-pi/autostart". Comment out the third line and put the 4 extra lines in there. Save and exit.

@lxpanel –profile LXDE-pi

@pcmanfm –desctop –profile LXDE-pi

#@xscreensaver –no-splash

@xset s off

@xset –dpms

@xset s noblank

@midori –e Fullscreen –a http://localhost/ (the adress to your server)

------------------------------------------------------------------------------------------------------------------------------------------------------

I've received a comment that might help someone, so please read if you have a problem to change/save the autostart file.

EDITING ROOT FILES - when we ran into a problem being able to change/save the 'autostart' file in Step 3, we ended up doing it with the Nano editor which runs in terminal. From terminal, we entered sudo nano /etc/xdg/lxsession/LXDE-pi/autostart This opened the file, we made the edits then exited and saved. Hope this helps others. - MsMacD

------------------------------------------------------------------------------------------------------------------------------------------------------

Remember:

–help-execute will list all available commands (at least in Midori)
F11 to get out of fullscreen

Commands for the terminal:

ls = lists the folders in that directory

ls -al = lists ALL the folders, even the hidden one.

cd name = moves you in to the folder "name". change "name" for the folder you want to enter

cd .. = will move you back upp a folder

"~/.config..." = means that it is in the root file, in my case in "pi". Use "ls -al" to see the autostart file.

Step 4: Webpage

The webpage that you should (could!) use, is a simple webpage with a black background and white text. Since you have an observation mirror, the black areas will make sure that you get the "mirror" and the white text will shine through so you can see it. Be creative and don't hesitate to make your own webpage if you want to! It's a perfect time for learning!

You can download the files I used from my GitHub. The files are originally created by Christoffer Orre, who hosts the Swedish guide. I just translated some of it to English. You can download his original files (in Swedish) here.

In the .php file, you can change the text, news, time and date (and of course add new things!) . And in the .css file you change where on the screen you want the stuff.

The files should be put in the folder "/var/www/html/MagicMirror" (where you were and changed things when you set up the web server). The "MagicMirror" folder is not necessary. It changes the "http://localhost/" to "http://localhost/MagicMirror/", but other than that it's just for keeping track of the files.

Step 5: Building the Frame (and Making the Mirror)

Now it's time to take apart the screen and build the frame!

In my case, a screwdriver in the side of the screen and then mild force cracked it open. You can probably find guides on YouTube for your specific screen.

Then, you take the measurements for the frame and start cutting. I used both screws and glue to make sure it was sturdy enough, the final product weighs quite a lot. Put some air holes at the top and a hole for the cord at the bottom.

I also cut the "frame" in the front in an angle, just because I like it. Then you put the front on the frame and you are almost done.

Make 4 small pieces that you later can put behind the screen, to make sure it doesn't fall backwards.

(I have no pictures of this unfortunately) Then it's time to put a mounting point at the back. You can see how Mr Teeuw did his mounting points here.

Then it's time for some paint and you are done!

------------------------------------------------------------------------------------------------------------------------------------------------------

If you chose to have a glass and mirrorfilm, this is a good time to do that. Add the film to the glass as the instructions show you. If you didn't get any instructions, you can search for "apply mirror film" on YouTube for good instructions!

Step 6: Assembly

Now everything is done and you should just put it all together!

Take the frame and put the mirror in the front. Place the screen behind it and plug in all the things you need. Start the Raspberry and make sure everything works. If everything is OK, turn it off and put the final 4 pieces behind the screen to make it stay up.

Then you just have to plug everything in there and maybe use some cable ties to make it look a little nice. You maybe have to make som final adjustments of the webpage to make it fit the screen when the frame is there.

Put it up on your wall (or place it somewhere) and you are done! You now have your own Magic Mirror!

3 People Made This Project!

Recommendations

  • Creative Misuse Contest

    Creative Misuse Contest
  • Water Contest

    Water Contest
  • Oil Contest

    Oil Contest

90 Discussions

I just got my Pi this morning to get this built. Everything seems to be ok apart from one bit. I've got the Pi 3 and have followed the instructions for that. I've edited the autostart file and when I boot, it comes up with the browser pointed to localhost in fullscreen mode. So far, so good. But it comes up with a bunch of errors implying that /home/pi doesn't exist. If I just dismiss them then it seems to be ok but I'd like to get rid of these if possible.

Any idea?

Cheers

Andy

Hi, is there a way that i can add an ai(google or alexa) too?

1 reply

well, I'm not sure. But I guess if you add a microphone and the correct software it should be possible :)

Thanks for Sharing. Good one.

In my case For Rasberry Pi 3 Model B , had to change Step 3 to change the following:

open the below file
sudo leafpad ~/.config/lxsession/LXDE-pi/autostart

and change to
@pcmanfm –desctop –profile LXDE-pi
#@xscreensaver –no-splash
@xset s off
@xset -dpms
@xset s noblank
@chromium-browser --kiosk --incognito http://localhost

and save. Post this on reboot it will open the browser with the localhost as desired. Ensure you know how to open a terminal Ctrl+Alt+T , incase you need it post reboot :-)

Now trying to see if I can change the php to show the latest tweet from a twitter account.

1 reply

Thank you for sharing! I will add your comment to the instructions! :D

To show Twitter is a nice idéa! :)

Can i know how much is the cost for this project in RM@RINNGIT MALAYSIA

2 replies

Hello Comeli26.

As I got some of the parts donated, I don't honestly know how much this project costs. But my tip for you is to use the "what you need"-list and search for what it would cost for you if you bought the things in stores close to you. Good luck! :)

0
user
MsMacD

1 year ago

EDITING ROOT FILES - when we ran into a problem being able to change/save the 'autostart' file in Step 3, we ended up doing it with the Nano editor which runs in terminal. From terminal, we entered

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

This opened the file, we made the edits then exited and saved. Hope this helps others.

1 reply

Thank you MsMacD! I will add this to the instructions! :) It's awesome that we can help each other in making a great tutorial! Promise to send a pic when you are done!

Hi!

Thank you for this great work :)

I don't get 1 thing: do you use a glas or you put the mirror film directly on the computer screen?

Thank you!

1 reply

Thank you!
I use glas that I put in front of the screen :)

Nicely done!

I was originally thinking of making this project: https://www.instructables.com/id/Raspberry-Pi-Wall.... Now I am thinking of combining the two, maybe even throw in some voice recognition with a headless browser to pull up certain notifications (e.g. news, weather, calendar, public transport departure times. etc.).

1 reply

Thank you!

I think your plan sounds like an excellent idea! Send me a link when you are done! :D I would love to see the result!

i finally got it to work, i forgot to change the apache server to php, it works now. Also what can i change the address to so that its in english or something like weather

I would love to make this and you are so kind to share these instructions. I wish I knew the first thing about any of this, I would be making it today. Wonderful job!!

2 replies

Thank you!! :D You should try something! There are tons of cool stuff here at instructables!

I have made a few things here and there but THIS is the one want to do. I have been trying to find a way to have my mirror give me my morning information while I get ready for work and this is perfect for that. The last time I wrote a program we were making sprites and using HLIN and VLIN commands. Things have changed so much and I have been horribly remiss when it comes to keeping up with the times. Please keep sharing your wealth of knowledge. Thanks.

Great Project, i did all the coding for it but my website shows code on it, for example next to the time and date on the left side there is

...

load('http://youtube.com'); // Specify the address to the feed $feed = array(); foreach ($rss->getElementsByTagName('item') as $node) { $item = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue, ); array_push($feed, $item); } $limit = 3; // Number of posts to be displayed for($x=0;$x<$limit;$x++) { $title = str_replace(' & ', ' & ', $feed[$x]['title']); $description = $feed[$x]['desc']; $date = date('j F', strtotime($feed[$x]['date'])); echo '

'.$title.'

'; '.$date.''; '.strip_tags($description, '

<').'

'; } ?>

<06) and ($now < 10)) echo

and below that where the time based messages are there is

<06) and ($now < 10)) echo 'Good morning!'; else if (($now >= 10) and ($now < 12)) echo 'Have a nice day!'; else if (($now >= 12) and ($now < 14)) echo 'Time for lunch!'; else if (($now >= 14) and ($now < 17)) echo 'Come and see!'; else if (($now >= 17) and ($now < 20)) echo 'Time to start to think about dinner?'; else if (($now >= 20) and ($now < 22)) echo 'Have a nice evening!'; else if (($now >= 22) and ($now < 23)) echo 'Sleep tight, see you tomorrow!'; else if (($now >= 00) and ($now < 06)) echo 'Shh, sleeping...'; ?>

can someone help me i dont know what i did wrong, my index.html file is exsactly the same as yours.

1 reply

oh and i only did youtube as the address because the original one wasnt working so i was trying to test a random site.