My Smart Mirror

17,842

401

19

Student NMCT at Howest Kortrijk (Belgium)

Time in the morning can be limited. You have to get ready for work, school,... Looking up the weather takes some of that limited time away. The Smart Mirror eliminates the time you need to open your phone or computer and lookup the weather. In this project we will make such a mirror. It will be able to tell you the time, the local weather, temperature and humidity of the location where your mirror is hanging. This data will also be shown on a home made website.

Step 1: The Components You Need

The list of components can be found in a pdf below

  • Computer screen with HDMI input (or DVI input with convertor like in my case)
  • DHT11 temperature and humidity sensor
  • Raspberry pi 3 model B
  • Wood
  • Hardware to fix the wood in place (screws, glue, brackets)
  • Confrontation mirror, try to order the dimensions as close to the dimensions of the screen. I ordered a custom size and measured the outside of the screen, fully assembled, with border. The screen will be able to rest on the access mirror.
  • Cables to connect the sensor to your raspberry pi (female-female 2.54 to 2.0mm jumper wires reccomended)
  • HDMI cable

Step 2: Raspberry Pi Setup

Now it's time to install some software to control the Raspberry Pi:

  • Raspbian OS image
  • Win32 disc manager

1) Install the Raspbian OS software from the Raspberry pi website.

Download the ZIP file and extract it to a desired location.

2) Download the Win32 disc manager.

  • Click on the folder icon to select the image
  • Then select at "Device" your microSD
  • Then click on "Write"

When the image is written on your MicroSD card, you can open it in Windows Explorer.

  • Open the file "cmdline.txt"
  • Add the following line before the word "rootwait": 169.254.10.0
  • Then save the file.

Now insert the MicroSD into your Raspberry pi

Apply power to your Pi with a 5,2V power adapter.

Connect a network cable to your Pi and your computer.

Step 3: Connecting to Your Raspberry Pi

Now we have installed everything you need to use your RPi

1) Install Putty and open it.

2) Create a connection (as shown in the picture)

3) Login to your pi:

  • username: pi
  • Password: raspberry

4) WIFI setup

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf<br>

At the bottom of the file, you add these lines:

<p>network={<br>	ssid="name of the wireless network"<br>	psk="password of the wireless network"
</p><p>}</p>

5) To connect wireless to your RPi you first need to find your ip adress via this code:

ifconfig wlan0

You can now use this ip adress in putty to login wireless.

Step 4: Measuring the Dimensions for the Wooden Construction

You will need to measure 2 elements:

  • The dimensions of your screen (! only screen, no edge !)
  • Dimensions of the plexi mirror you bought

Do remember that these measurements will be the inside of the rectangle. When buying the wood, you will have to add 8 times the value of the width of the wood to have a correct length because it's nice if you saw the wood in miter.

For the front of the mirror, I used a wooden plank of 18 by 69mm and a length of 210cm

Write the dimensions down, we will use them later.

Step 5: Taking the Screen Apart

Now we will take the screen apart. Every screen is different, for my screen I had to loosen 4 screws and unfasten clips around the monitor. I my case, the screen was connected to the power supply by only a couple of wires. So I taped the back to the screen itself, so it wouldn't move around.

Step 6: Making the Front Section of the Mirror

  1. To make the front section, we need the measurements of the screen without border. You can choose how wide the wood had to be, but I recommend a height of +/- 20mm. The border doesn't have to be that tall.
  2. It helps if you first make a sketch like in the second picture with your measurements. It helps when cutting the planks.
  3. Measure the dimensions of your screen on the wood. Draw a corner of 45° outwards at each side. Repeat this for the 4 dimensions of your screen.
  4. You can cut the planks yourself using a circular saw, or ask the store where you bought the planks to do it for you.
  5. I drilled 2 small holes per plank per side in the height of the wood, so I could fit wooden taps inside the holes to connect the planks together.
  6. To permanently fix them together I used wood glue.
  7. Let the glue harden overnight.

Step 7: Making the Back Side of the Mirror

  1. Now we will need the measurements of the plexi-mirror.
  2. We aren't going to cut the planks at a 45° angle.
  3. Your drawing should look like the third photo.
  4. For the length, we are going to add 2 times the width of the plank.
  5. For the height, we are going to cut the planks to the measurements of the plexi-mirror. The result is, when placing the planks like in the photo, the inside measurements are identical to the ones of the plexi-mirror.
  6. To fasten the wooden planks together, I drilled holes and fastened it with screws. Because this will be the back side, the refinement isn't a priority.

Step 8: Finishing the Wooden Construction

Now, we are going to fasten the 2 constructions together.

I used metal 90° bends and screws to fasten the 2 as shown in the picture.

You can also use these small triangles with screws, but it is not necessary.

Step 9: Placing the Plexi-mirror and Screen in the Construction

  1. If everything is correct, your mirror fits nicely in from the back and rests on an edge from the front part.
  2. I put some glue on the edge and placed the mirror in its final position.
  3. Place some weight on the mirror, so it dries nicely.
  4. Let it sit overnight.

Step 10: Placing It All Together

Now our construction is complete, we are going to place our screen in the housing, with the DHT11 temp sensor.

How you fix it, is up to you, just make sure the screen and pi aren't going anywhere.

I mounted the DHT11 temp sensor on the outside of the mirror, so the readings would be the most accurate.

Step 11: SQL- Database

  1. In this step we will be installing some items that will make it possible to run the database.
  2. sudo apt update

  3. sudo apt install -y python3-venv python3-pip python3-mysqldb mariadb-server uwsgi nginx uwsgi-plugin-python3

We currently have no user. We use this code to create user, you just need to fill in the user and the password:

CREATE USER 'FILL_USER_IN'@'localhost' IDENTIFIED BY 'FILL_PASSWORD_IN';
CREATE DATABASE smart-mirror;
GRANT ALL PRIVILEGES ON smart-mirror.* to 'FILL_USER_IN'@'localhost' WITH GRANT OPTION;
<p>sudo mariadb < sql/db_init.sql</p>

Step 12: SQL Connection to Pycharm

We will connect our database to pycharm

  1. Go to View > Tool Windows > Database and click on the green plus to add connection
  2. Choose Data Source > MySQL and Download driver, if it comes up

General

  • Host = localhost
  • Port = 3306
  • User = *name you chose in last step*
  • Password = * password you chose in last step *

SSH/SSL

  • Proxy host = * your ip adress *
  • Port = 22
  • Proxy user = pi
  • Proxy password = raspberry

To insert tables

  1. you right click on smart-mirror > open console
  2. Execute sql in the zip file in the console
  3. Database is made

Step 13: Getting Code for the Project

In pycharm go to:

  1. File > settings > Build, Execution, Deployment > Deployment

Fill the screen in like in the photo

Do the same in

  1. File > Default settings > Build, Execution, Deployment > Deployment

Now you just download the code from my github and open it in pycharm

Step 14: Auto Running the Project

To load the screen page on startup, in your Pi, you type this:

<p>cd /home/pi/.config/lxsession/LXDE-pi/</p>

and open the autostart file with nano

nano autostart

You make sure this is what is in the file:

<p>@lxpanel --profile LXDE-pi<br>@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@point-rpi
@chromium-browser --incognito --kiosk 127.0.0.1/monitor
@xset s noblank
@xset s off
@xset -dpms</p>

Now the monitor page will load on startup and the screensaver is disabled.

Step 15: Enjoy Your Smart Mirror

Now you just power on the screen and pi, and let the mirror do its magic.

It takes some time for the Mirror to boot up, but let it do it's work.

The location on the screen is set to Kortrijk, Belgium, the location where the mirror is made, but if you want to change it, go into web > static > JavaScript folder in the code and search for the line where City = Kortrijk; (it is in the first lines of the code). You can change it to the location where you live. You should change it in the 2 javascript files for the location to change on the site and on the mirror.

Enjoy your Smart Mirror!

Clocks Contest

Second Prize in the
Clocks Contest

Share

    Recommendations

    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • Plastics Contest

      Plastics Contest
    • Optics Contest

      Optics Contest

    19 Discussions

    0
    None
    ygreq

    Question 4 months ago

    My I ask what that program is at step 11? Looks like an IDE for SQL. Thank you!

    1 more answer
    0
    None
    WoutVanOvermeirenygreq

    Answer 3 months ago

    I used the tool in MySQL Workbench to create the database. It is an easy way to create the database.

    0
    None
    Rando234

    Question 4 months ago on Introduction

    Great job, looks great...Is there a wireless thermometer or sensor to place outside of the house and cast the info back to the unit?

    1 more answer
    0
    None
    WoutVanOvermeirenRando234

    Answer 4 months ago

    Thank you! And with some research, you will maybe find one. But a friend of mine used an ESP32 to send wireless data to his raspberry pi for his project. You can connect the sensor to the ESP32 and send data to your raspberry pi. It is like an Arduino, but with wifi. That would make it possible to put the sensor outside of your house.

    0
    None
    PaulA23

    4 months ago

    Very nice! I can see a much smaller version of this making a great vehicle rear-view mirror - like maybe using a small tablet etc. It would also be capable of presenting an inset screen of a dash cam or backup camera... Yes, all of these things are already individually available, but a project like yours could bring them all together into a really nice, custom rear-view smart mirror...
    Great job!

    1 reply
    0
    None
    WoutVanOvermeirenPaulA23

    Reply 4 months ago

    Thank you! And yes that is a great idea, maybe for a future project!

    1
    None
    CalebT3

    5 months ago

    I was on a team that wanted to build one of these, but I could not fathom the purpose. For telling time and weather, it is expensive. Even if you would like it to show emails or news, the user then has to stay in the room and stare at the mirror, whereas people prefer mobility (i.e. prefer staring at their phones). It's really not realistic, I don't think, to suppose people will do a lot of multitasking with this.

    To get more out of it, though, I suggest adding a microphone and speech recognition such that videos and music can be called up. It'll still be an expensive toy because people usually need to leave the room after briefly looking at a mirror, but it will be a little more useful, at least. You might also add BT pairing so the mirror knows who is in the room and what to show/play, and can turn off automatically when the person leaves.

    A time-of-flight sensor would also be helpful to allow people to make hand motions to control this and that.

    All the best.

    1 reply
    0
    None
    WoutVanOvermeirenCalebT3

    Reply 5 months ago

    Thank you for your suggestion! It might be interesting to add these features in a future project.

    0
    None
    DavidL138

    5 months ago

    Very well written! Also easy to follow. Is there a solution using a Mac instead of a PC? I don't do Windows. Nope, not ever.

    3 replies
    0
    None
    WoutVanOvermeirenDavidL138

    Reply 5 months ago

    Thank you for your comment! And sorry I have no idea, I only have experience using Windows.

    0
    None
    CalebT3DavidL138

    Reply 5 months ago

    You've shackled yourself to a limited OS and you're having trouble carrying out a simple project. Interesting.

    If Windows is off the table, there's still Linux -- also far better than OSX for the average user.

    0
    None
    DavidL138CalebT3

    Reply 5 months ago

    Before I retired over 10 years ago I was both an MCSE and programmer. I was expert in Windows, MacOS and Unix. Because of my years as a manager of an R&D lab I grew to like and appreciate Apple. Yes, sometimes limiting but much more secure.

    0
    None
    spark master

    Question 5 months ago

    What is a

    "Confrontation mirror", and a link to yours even if we need a local source. This is not a common name for it in American English, I think what you want to say is "two way" mirror.

    This place has it in USA

    https://www.twowaymirrors.com/

    1 more answer
    0
    None
    WoutVanOvermeirenspark master

    Answer 5 months ago

    It is a mirror (or plexi in my case) that blocks light in one direction. So when you place it on the table, or block light from one direction, it will reflect. But if you hold it up against a light source, it will be transparant. This is the site from where I bought my plexi mirror.

    https://www.dokter-plexiglas.nl/plexiglas-spiegel

    0
    None
    Gadisha

    5 months ago

    Seems like a plan with potential, looks great, good thinking!

    1 reply
    0
    None
    fortranfiend

    Question 5 months ago on Step 15

    The github connection for your impressive smart mirror project appears to be broken. Can you send me a link to you project code?

    2 more answers