DIY Smart Mirror W/ Google Assistant & Wireless Charging - 2021
by Harsha Gundala in Workshop > Home Improvement
7289 Views, 60 Favorites, 0 Comments
DIY Smart Mirror W/ Google Assistant & Wireless Charging - 2021
Want to build the COOLEST SMART MIRROR EVER (in my opinion 😃)? Do you have a lot of free time and aspire to make something amazing? Well, you've come to the right place!!
Introduction:
In this tutorial, we'll go over how to make a DIY Smart Mirror with some really cool features like Google Assistant and Wireless Charging built-in. I'm just a beginner at making things, so if any of you guys are debating whether you can create a project like this, fear not! I'll try to make these instructions as foolproof and descriptive as possible. So what are we waiting for? Let's get started...
Huge shoutout to my Principals of Engineering teacher, Ms. Berbawy, for helping me throughout this project!
Also, thanks to these people/groups for their online instructions, making this project possible:
- MaxTheSpy on Raspberry Pi Forums
- Sdetweil on GitHub
- Grensom on Youtube
- Keval Patel on Medium
- Google's Python Documentation
Important Notes:
- This tutorial assumes you have Raspbian OS formatted onto a Raspberry Pi, and the computer is ready to go. If you don't, that's okay! Follow these easy setup instructions by the Raspberry Pi Foundation and you'll be ready to go in no time.
- This tutorial uses all of the materials listed below, however, you might not need all of them. Make sure you read this entire Instructables tutorial before starting so you understand how/why each component is used. If you think you can achieve the same end goal using a different method, go for it! Remember, this tutorial is just a template, and as a Maker yourself, you have complete control over where you want to take this project. If a feature on this Smart Mirror doesn't interest you, don't add it. If you want to change something up, do it!
- Inevitably, some steps on this Instructables won't work for you (particularly, that pesky software part). I'll do my best to include troubleshooting tips and things that worked for me, but if they don't work, don't give up! Try Google-ing the error message or try to find people who solved similar problems. If nothing works, don't hesitate to leave a comment on this Instructables or reach out to me directly, I'd love to see what I can do to help you!
- This project will take roughly 30-40 hours to complete
Supplies
Materials:
- LCD Panel (I procured this 15.6-inch model by disassembling an old laptop I had)
- 40 Pin Display Control Board (most LCDs use a 40pin connector, and a control board is used to power/control the LCD. This one does the trick)
- One Way Mirror (this is what makes the Smart Mirror a mirror instead of just a screen—I bought this one, but make sure you buy the right size. 12x18 inch size is big enough for this project)
- Raspberry Pi 3 (this is the brain of the project. The newer version, Raspberry Pi 4, will also work. If you don't have them, you can buy them here)
- USB Microphone (to enable Google Assistant to hear you—I used this)
- Speaker with AUX (to enable you to hear Google Assistant—I used this)
- LEDs (so you know when Google Assistant is on. Any LEDs will work, however, I wanted to be a little fancy and used LEDs that automatically change color. You can buy them here)
- Stencil Sheets (to diffuse the light from the LEDs as much as possible. I used these)
- Wire (to hook up LEDs and power various components, I worked with this one)
- DC Power Adapter 12V (I found this one to work. It's used to power the whole project)
- DC Power Splitter (lets us power multiple things. This one is what I used)
- Adjustable Voltage Regulator (to convert 12V down to 5.1V to safely power our Raspberry Pi, Speakers, and LEDs. I used this one, and it works great!)
- Wireless Charger (to enable wireless charging on the Smart Mirror! I used an old charger, but a cheap one like this will work too)
- Birch Wood (you'll need birch wood panels to laser cut and build the mirror's housing. I used both 1/8th inch and 1/4th inch thick panels, and you can buy both types here)
- Magnets (to allow the top panel of the mirror housing to open when needed. I used these)
- HDMI Cable (an extra one you have at home with work, but if you don't, here are one you can buy)
Tools:
- Laser Cutter (to precisely cut wood for the Magic Mirror Housing)
- 3D Printer (I used a Prusa Mini but any printer can be used)
- Calipers (to precisely measure materials, these work well)
- Ruler (to measure some bigger materials, the one you have at home will do the trick)
- Straight Cut Snip (used to cut small pieces of wood, I used this one)
- Hot Glue Gun (to glue everything together, even a cheap one like this will work)
Software:
- Adobe Illustrator (if you don't have access to this, feel free to contact me and I can send you the design files)
- CAD Software (I used OnShape, but literally any CAD software will work for this project. Tinkercad is a free online CAD software I would recommend)
Raspberry Pi Setup - VNC Software
Action Summary:
Why: Setting up VNC (Virtual Network Computing) will make using our Raspberry Pi a lot easier to program and play around with. By the end of this, we will be able to remotely control our Raspberry Pi using a laptop instead of plugging the device into its own separate monitor and using separate input devices (keyboard and mouse).
Toughness Scale: This step is very simple!
Instructions:
Thank you to MaxTheSpy on Raspberry Pi Forums for making this step possible! Read the thread here. Below is the code that worked for me.
1: Boot up Raspberry Pi and Open Terminal
Click on the terminal icon on the top application bar to open a terminal window.
2: Install VNC on Raspberry Pi
Type the following command into Terminal to install RealVNC on your Raspberry Pi. Things should download and install.
sudo apt-get install realvnc-vnc-viewer
3: Open the Raspberry Pi Configurator to Enable VNC
Type the following command into Terminal to open Settings.
sudo raspi-config
Then navigate to 'Interfacing Options' and 'Enable' the 'VNC' Option. Click 'Apply' to return back to your Terminal Panel.
4: Reboot the Raspberry Pi
Type the following command to reboot your Raspberry Pi so changes take effect.
sudo reboot
5: Install VNC on Your Personal Computer
Now, on your personal Laptop/Computer (not the Raspberry Pi), navigate to the RealVNC website to download 'VNC Viewer' for your operating system (works on virtually any OS including Mac, Windows, and Linux)
Complete the installation process, and create an account when prompted (alternatively, you can use VNC as a guest).
6: Let's Get Things Working Together!
Return back to your Raspberry Pi. Once it boots up, navigate to the top bar and click on the 'VNC' icon that should now be activated. Click on it to view your IP Address and Pass-Phrase.
On your Laptop or Computer, enter this information to remotely connect to the Raspberry Pi. If everything went correctly, you should be able to see and control your Raspberry Pi using your personal computer! Play around with it and say goodbye to two different sets of keyboards and mice for our projects—this will make our lives so much easier for the next couple of steps!
Troubleshooting Tips:
Something didn't work? Try the following actions below to see if they fix the problem:
1. If you entered the IP Address of your Raspberry Pi into VNC Viewer on your personal Laptop/Desktop only to see an error along the lines of 'device not found' or 'failed to connect,' ensure that both your Computer and the Raspberry Pi are connected to the same internet or WiFi signal.
2. Ensure that your Internet connection works on both the Pi and your Computer. You can simply open the preinstalled 'Chromium' Browser on the Raspberry Pi or a browser of your choice on your personal computer and try checking your email or searching something up.
3. If nothing works, try rebooting both the Pi and your personal computer.
Raspberry Pi Setup - Magic Mirror Software
Action Summary:
Why: The Magic Mirror Software is what we are going to use in order for our Smart Mirror to display useful things to us. After installing and setting up Magic Mirror, a window should pop up automatically when we boot our Raspberry Pi. This window will have widgets like the weather, time, and news (and these are fully customizable with many other widgets people have made for Magic Mirror). The most important part of this window is that the background is black, so when we place our LCD Panel behind our one-way mirror, the widgets will shine through but the background won't, making the Smart Mirror seamless and integrated.
Toughness Scale: This step is a little bit longer, but is fairly manageable, and I'll do my best to break it down into easy chunks :)
Instructions:
Huge thanks to Sdetweil on GitHub and Grensom on Youtube for making this step possible!
1: Open Terminal on Raspberry Pi
We are going to be running a couple of lines of code to install Magic Mirror on our device. The first thing we need to do is install a package called 'npm' which helps us download the Magic Mirror software.
Run this code:
sudo apt-get install npm
It should be a relatively fast install.
2: Use Sdetweil's Script to download and install Magic Mirror
I've tried a ton of other methods in order to install Magic Mirror on the Raspberry Pi, and Sdetweil's code is, by far, the easiest method that works. Sdetweil's simple script automatically installs all the necessary dependencies and packages for Magic Mirror to work on your device. Again, huge thanks to Sdetweil!
To install Magic Mirror, run the following code:
<pre>bash -c "$(curl -sL <a href="https://raw.githubusercontent.com/sdetweil/MagicMirror_scripts/master/raspberry.sh" rel="nofollow"> <a href="https://raw.githubusercontent.com/sdetweil/MagicM..."> https://raw.githubusercontent.com/sdetweil/MagicM...>>)"
This install process took around 15 minutes for me. You've finished when you see the "We are ready" message pop up on terminal.
3: Raspberry Pi Configuration
Next, we need to set up some things on Raspberry Pi to make it perform like a Smart Mirror. You know how after a bit of time staying inactive, most computers automatically log-off or show a screen saver? We need to turn that off or else our Smart Mirror will keep turning off. We also need to make sure the Magic Mirror software automatically starts up whenever our Raspberry Pi boots up, so if your electricity gets interrupted, we don't want to manually start Magic Mirror again. Big thanks again to Sdetweil for providing these scripts!
To turn off the screensaver, run this:
<pre>bash -c "$(curl -sL <a href="https://raw.githubusercontent.com/sdetweil/MagicMirror_scripts/master/screensaveroff.sh" rel="nofollow"> <a href="https://raw.githubusercontent.com/sdetweil/MagicM..."> https://raw.githubusercontent.com/sdetweil/MagicM...>>)"
To auto-boot Magic Mirror on the Raspberry Pi, run this:
bash -c "$(curl -sL <a href="https://raw.githubusercontent.com/sdetweil/MagicM..." rel="nofollow"> <a href="https://raw.githubusercontent.com/sdetweil/MagicM...</a"> https://raw.githubusercontent.com/sdetweil/MagicM...>>
And now, our Raspberry Pi is configured!
4: Run Magic Mirror for the first time
By now, the Magic Mirror software should've booted up already, and you should see a window that looks like the Smart Mirror's User Interface. If this window hasn't popped up, run this code:
pm2 start Magic Mirror
You'll likely notice that the weather, time, and center messages on the Magic Mirror window are inaccurate or not customized yet. We'll fix this next!
5: Magic Mirror Configuration
Huge shoutout to Grensom on Youtube for an amazing tutorial on how to do this step! First, let's make sure the Weather Widget is calibrated to show accurate information for the specific city you live in.
To do this, you need to make an account on OpenWeatherMap (this is free and is super quick). By signing up, our Magic Mirror Software can take advantage of OpenWeatherMap's API system, which is required to get weather data. Once you make your account, on your home page, navigate to the tab which is titled 'API Keys.' If needed, generate or rename an API key (it looks like a long string of alphanumeric characters). Copy your API key.
Then, on your Raspberry Pi, open the 'Files' app, navigate to the 'MagicMirror' folder (which is downloaded on the '/home/pi' directory), click the 'config' folder, and finally, double-tap the 'config.js' text file. You should see a list of modules that are currently running on Magic Mirror. You can edit this folder to change the widgets, location of the widgets, etc., however, for now, navigate to the module titled 'currentweather'.
Where it says: 'appid: "YOUR API KEY HERE"' paste your API key you just copied between the quotes. Two lines above, you should see 'location: "New York"' Edit 'New York' and type in the city you live in. Finally, we need to edit the 'locationID: ""' field (which should be the line right underneath). Every City has a unique ID that tells OpenWeatherMap what city you want the weather for. Commented out right next to that line of code, you should see a URL where you can download a full list of Cities and their matching codes, however, that URL did not work for me. If it doesn't work for you either, I've tracked down another OpenWeatherMap link where you can download this folder, which you can access here. Open that file, find your city (or the city closest to you), and copy its locationID into the field (between the quotes; make sure to not delete the quotes) on the config.js file.
Copy and paste the same three fields from the module we just filled out onto the module right underneath it, titled 'weatherforcast'. Save and close this 'config.js' file. Great! Now, we are done configuring the weather part!
Next, we can customize the messages that appear on the Magic Mirror itself! We'll do this by navigating to 'home/pi/MagicMirror/modules/default/compliments' via the files app again. Open the '.json' file, and you can now change up the lists you see to display any message you want depending on the time of day. Ensure you add/edit strings using the same format you see, like "quotes around strings" and commas separating each unique message.
6: Magic Mirror Add-Ons
We are almost done! The last thing we are going to explore in this Magic Mirror Setup Step is the myriad of additional widgets that are publicly available for us to enjoy (most are completely free too!). From tracking FedEx shipments to seeing live streams of earth from space, there are widgets for almost everything you can think of.
Here is the full list of modules for Magic Mirror, along with documentation on what they are and how to install them. For the purposes of this tutorial, we will install a module I thought is cool called 'MMM-Screencast'. This allows any device connected to the same internet network of the Smart Mirror to cast videos from Youtube right onto the Mirror!
Thank you to 'kevinatown' on GitHub for building this super cool public module, and providing documentation on how to install it.
To install it, first, open Terminal on Raspberry Pi and go to the MagicMirror/modules directory (this is where all the modules are stored). We need to go into this location so when we download 'MMM-Screencast', it automatically saves in the correct location. To change directories, use the 'cd' command:
cd /MagicMirror/modules<br>
Then clone the 'MMM-Screencast' module from GitHub:
git clone <a href="https://github.com/kevinatown/MMM-Screencast.git" rel="nofollow"> <a href="https://github.com/kevinatown/MMM-Screencast.git<..."> https://github.com/kevinatown/MMM-Screencast.git<...>><br>
Once it is successfully installed, enter into the 'MMM-Screencast' module using the 'cd' command again:
cd MMM-Screencast<br>
Now, install dependencies (which are other tools/packages which are required to run this module):
npm install<br>
Okay! That was easy, right? We're soo close. Open up the files app on Raspberry Pi, and navigate to the 'config.js' text file we modified before ('/home/pi/MagicMirror/config/config.js').
In the modules section, add the following code directly after the line of code that says "modules: ["
<pre>{ module: 'MMM-Screencast', position: 'bottom_right', config: { position: 'bottomRight', height: 500, width: 800, castName: 'ANYTHING YOU WANT'},
Notice that there is a comma at the end of the bracket at the end. All the modules in the modules section of the config.js file must be separated by a comma. This is why it's important the code above is pasted directly after "modules: [" because that ensures this is the first module in the list. That's why we don't need a comma before the first bracket as well.
The parameter, 'castName:' is what your Smart Mirror looks like to other devices when they want to cast YouTube videos over to it. Change it to whatever you like!
Save this file and reboot your Raspberry Pi by running the code below in Terminal:
sudo reboot
And we are officially done with this step! Check out the Screencast module by clicking the cast button on the YouTube app on a mobile device (it's amazing when it works!)
Feel free to play around with other modules as well; most are just as easy and just as cool! Next up, we are going to learn how to integrate Google Assistant onto our Smart Mirror.
Troubleshooting Tips:
Something didn't work? Try the following actions below to see if they fix the problem:
1. We did a ton of installing/editing things in this step, so chances are, if something didn't work, you probably encountered a pesky error message (I hate them too!!). Even though they are super annoying, they are usually fairly easy to fix. Try Googleing the error message and usually, a ton of people experienced the same error and found a solution. If nothing works, don't hesitate to reach out :)
2. For step number 5, Magic Mirror Configuration, you might have experienced some problems getting your locationID. Not all cities are on the downloadable list, and for some reason, every time I try to use CTRL+F to search for a city, it lags and doesn't work. I've found a pretty simple solution for this, and it works for almost any city! First, navigate to OpenWeatherMap. There is a search bar on the top left of the website; search for the city you live in. Once you get the list of returned results, find and click on the right city. You'll get redirected to the current weather page for that city and the 'slug' of the URL is your locationID. For example, the weather page for San Francisco, California is at 'https://openweathermap.org/city/5391959' and 5391959 is its locationID. Hope that helps someone out there!
Raspberry Pi Setup - Google Assistant Software
Action Summary:
Why: Next up in this project, we are going to integrate a Google Voice Assistant into the Smart Mirror. Using the Raspberry Pi, USB Microphone, and Speaker, this Google Assistant program will run in parallel to Magic Mirror. The result, when we're done, is a Smart Mirror that you can ask questions to by saying "Hey Google." From learning about traffic near you to the weather forecast and daily news, you'll be surprised how much productivity this feature adds to your Smart Mirror.
Toughness Scale: Adding Google Assistant in the Smart Mirror was what took me the longest amount of time with a lot of trial and error. Lucky for you, you don't have to do all that testing since I've done it for you! After you get through this step, we'll be done with the software element for building this Smart Mirror.
Instructions:
Thank you Keval Patel for your amazing guide on how to program Google Assistant on a Raspberry Pi; without this, I don't know how I would have gotten through this step! Also, shout out to Google's Documentation that helped me with debugging.
1: Create a New Project on Google Cloud Platform
Keval Patel did a fantastic job explaining the Google Assistant programming process on a Medium post; thanks again for the tutorial! I'm going to try to add on to that tutorial and hopefully help some of you not spend hours troubleshooting :) I'm going to approach this setup process a little differently than Keval did, however, by the end of this, we will still hit all of the key steps to make this work.
On your Raspberry Pi, we need to set up a Google Cloud Platform account in order to integrate Google Assistant into our project. Make sure you use your Raspberry Pi to set up this account as it will save time later.
Go to this link to create an account and start a new project. Name your new project anything you like!
Now, go to 'APIs & Services' and then 'OAuth consent screen'. There should be a short form to fill out. Once that is done, click on the tab right above 'OAuth consent screen' titled 'Credentials.'
Click on the 'Create Credentials' button and click on 'OAuth client ID.' For Application Type, select 'Desktop' and for Name, type something along the lines of "[YOURNAME]smartmirror".
Once your credential is created, click on the download button; this will save a special file onto your Raspberry Pi. And we are done with this step!
2: Connect and Set Up the Microphone and Speaker
Ok, next we have an easy step. We need to connect a microphone and speaker onto our Raspberry Pi and make sure the Raspberry Pi knows they are there. First, plug your USB Microphone into the Raspberry Pi, and use an AUX cable to plug your speaker into the audio jack of the Raspberry Pi.
Open the terminal on your Raspberry Pi and run this command:
arecord -l
Your output should look something like this if your USB mic is working correctly:
**** List of CAPTURE Hardware Devices **** card 2: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio] Subdevices: 1/1 Subdevice #0: subdevice #0
Notice that my output says 'card 2:'. Your's might say 'card 1' or a completely different number, but don't worry. Just remember your card number for the USB mic, whether it's 1 or 2 or something else.
Now run:
sudo nano /etc/asound.conf
Copy and paste the following code in this text file:
pcm.!default { type asym capture.pcm "mic" playback.pcm "speaker" } pcm.mic { type plug slave { pcm "hw:2,0" } } pcm.speaker { type hw card 0 } ctl.!default { type hw card 0 }
Note, in line number 9, pcm "hw:2,0", change the "2" to whatever mic card number you found from before. If you had the mic register on card 2, then you don't need to change anything. However, if it said card 1 for you, change that line to read: pcm "hw:1,0".
To exit the text editor, hold Control + X, type Y to save, and Enter to confirm.
Next, run this command to make 1 more text file:
sudo nano .asoundrc.
In this text file, copy and paste the exact same configuration items you saved in the '/etc/asound.conf' file, remembering to modify line 9 to be your specific USB Mic Card Number. Save and exit this file (Control + X, type Y to save, and Enter).
To set up your speaker via AUX, we need to tell the Raspberry Pi that audio needs to go to the speaker and not anywhere else. To do this, run the code below in Terminal:
sudo raspi-config
This opens up a menu that's kind of like the settings on a Raspberry Pi device. Navigate to 'System Options' (click Enter to select), and 'Audio' (use up/down keys to navigate). Navigate to AUX or Headphones as the audio output, and enter to confirm. Then click on the right arrow key, and click enter, to exit out of the raspi-config menu.
At this point, reboot your Raspberry Pi. Once your device loaded back up, open up the terminal again. We will now test to confirm that our speaker and microphone settings work.
Run this:
speaker-test -t wav<br>
If you hear your speaker saying something along the lines of "Right, Left..." then your speakers are set up correctly :) Hold Control + C to turn off this test.
To test our microphone, we will record something and play it on our speaker. To do this, we first need to record ourselves, and we can do this by running the code below:
arecord --format=S16_LE --duration=10 --rate=16000 --file-type=raw audiotest.wav
This records a 10-second clip using the USB Microphone and saves it in a file called 'audiotest.wav' Make sure to talk or say something during these 10 seconds so the mic records something.
Then, to play this audio file on the connected speakers, run:
aplay --format=S16_LE --rate=16000 audiotest.wav<br>
You should now hear your beautiful voice play on the speakers for 10 seconds. If you did, your speaker and microphone are correctly set up and ready for Google Assistant integration! We're so close!!!
3: Configure Raspberry Pi and Authenticate Your Device with Google
In this step, we are going to install important packages to enable Google Assistant on our Pi. Before doing any major installations like this, it is always good practice to update our system and packages to ensure everything is in its most bug-free state. To update, run this code in the terminal on your Raspberry Pi.
sudo apt-get update<br>
Then run this command to install a package that will let us control the LED indicator lights that we will add in the future:
pip install RPi.GPIO
Now, we need to install Python 3, as Google Assistant only runs in a Python 3 environment. To install, run this command:
sudo apt-get install python3-dev python3-venv<br>
After it is installed, run this command to activate the package:
python3 -m venv env<br>
Next, install all the dependencies (other packages needed to run Python 3) by running this convenient piece of code:
env/bin/python -m pip install --upgrade pip setuptools<br>
To fully activate your Python 3 Environment, run this activation command:
source env/bin/activate<br>
If everything worked correctly, you should see the (env) text at the beginning of every command line in the Terminal Window. Now we will install the Google Assistant library which is really what powers the whole operation of making the voice assistant even work:
python -m pip install --upgrade google-assistant-library<br>
Next, we are going to authenticate your specific Raspberry Pi onto your Google Cloud Developer Account. We need to do this because Google Assistant will know your name, and sync with your Gmail emails, Google Calendar, and anything else from the Google World, so it is important your information is safeguarded from random people. First, we need to install a specific authenticator tool from Google by running the code below:
python -m pip install --upgrade google-auth-oauthlib[tool]<br>
Remember that file we downloaded onto our Pi from the Google Cloud Developers portal before. Go to the File Explorer App on Raspberry Pi, and go into your 'home' and 'pi' folders to find your 'Downloads' folder. In there, we should see the .json file we downloaded, which should be titled something that starts with "client_secret". Right-click on this file, and click on the 'Copy Path(s)' button.
Go back to the Terminal on Raspberry Pi and run this code:
google-oauthlib-tool --scope <a href="https://www.googleapis.com/auth/assistant-sdk-prototype"> <a href="https://www.googleapis.com/auth/assistant-sdk-pro...</a"> <a href="https://www.googleapis.com/auth/assistant-sdk-pro...</a"> https://www.googleapis.com/auth/assistant-sdk-pro...>>> \ --save --headless --client-secrets [PASTE YOUR PATH HERE]
Remember to paste the .json path you copied where the code says [PASTE YOUR PATH HERE]. Remember to delete the brackets "[]".
If successfully done, the output of this code will be a URL. Click on that link and sign in with your Google Account (the same account you used to create your project on Google Cloud Platform). After you have logged in, copy the code it gives you, and paste that code into the terminal prompt where it says:
Enter the authorization code:
If the response is something like this, then you have successfully authenticated your Raspberry Pi to be used as a Google Assistant:
credentials saved: /path/to/.config/google-oauthlib-tool/credentials.json
4: Tie Everything Together to Enable Google Assistant
We are almost done here! One more text file and we will have Google Assistant online! On the terminal window on Raspberry Pi, ensure you are in your main '/home/pi' directory by running this command:
cd /home/pi<br>
Then, create a text python file called 'main' by running this code:
sudo nano main.py<br>
Once the text editor is opened, copy and paste this code:
#!/usr/bin/env python from __future__ import print_function import argparse import os.path import json import google.oauth2.credentials import RPi.GPIO as GPIO from google.assistant.library import Assistant from google.assistant.library.event import EventType from google.assistant.library.file_helpers import existing_file GPIO.setmode(GPIO.BCM) GPIO.setup(25, GPIO.OUT) def process_event(event): if event.type == EventType.ON_CONVERSATION_TURN_STARTED: print() #m = alsaaudio.Mixer('PCM') #m.setvolume(100) GPIO.output(25,True) print("hit the lights") print(event) if (event.type == EventType.ON_CONVERSATION_TURN_FINISHED and event.args and not event.args['with_follow_on_turn']): print() #m = alsaaudio.Mixer('PCM') #m.setvolume(0) GPIO.output(25,False) print("lights out") def main(): parser = argparse.ArgumentParser( formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--credentials', type=existing_file, metavar='OAUTH2_CREDENTIALS_FILE', default=os.path.join( os.path.expanduser('/home/pi/.config'), 'google-oauthlib-tool', 'credentials.json' ), help='Path to store and read OAuth2 credentials') args = parser.parse_args() with open(args.credentials, 'r') as f: credentials = google.oauth2.credentials.Credentials(token=None, **json.load(f)) with Assistant(credentials, "[YOUR SMART MIRROR NAME]") as assistant: for event in assistant.start(): process_event(event) if __name__ == '__main__': main()
The only text you need to edit in this code is in the second to last paragraph, where it says "[YOUR SMART MIRROR NAME]". Remember when we made the 'OAuth Client ID' on the Google Cloud Platform and I told you to name your project something along the lines of "[YOURNAME]smartmirror". Get that name and replace it with [YOUR SMART MIRROR NAME] (remember to keep the quotes "" surrounding this text, but delete the brackets []).
Once that is done, Control + X, type 'Y", and click Enter to save and quit this text editor.
Finally, go over to the Files app on Raspberry Pi, and find that 'client_secrets" .json file from before (it should be in /home/pi/Downloads). Right-click on it, and click on 'Copy.' Then, navigate to the '/home/pi' directory and paste it in there, by right-clicking and clicking 'Paste'.
5: Automate the Boot Process
The last step in making Google Assistant work is making a shell script (a smaller script that points to and runs the main code). This will make it easier to run this shell script at boot, so every time the Raspberry Pi restarts, Google Assistant will automatically initialize and work.
To make a shell script called 'google-assistant-init.sh', run the following command:
sudo nano google-assistant-init.sh<br>
Once inside the text editor, copy and paste this code:
#!/bin/sh<br>/home/pi/env/bin/python3 -u /home/pi/main.py
All this code does is point the Pi to activate our Python 3 environment and run our main.py text file that runs Google Assistant. Click Command + X, type "Y", and press Enter to save and quit the text editor. Next, we are going to expand the permissions of this Shell Script using chmod, to ensure we won't need to use the terminal and use admin privileges to run this script (because it needs to run automatically on your device). To do this, enter this command:
chmod +x google-assistant-init.sh
Now, open up the Folders app on Raspberry Pi. Navigate to '/home/pi' and right-click on some of the white space. Click on the 'Show Hidden' button. Find and open the text file titled, ".bashrc". This is a file that runs on boot on the Raspberry Pi. Be careful not to accidentally modify any of the text in this file; carefully navigate to the bottom of the file.
At the very bottom of this text file, click enter a couple of times to create some space between the code above it. Then copy and paste this code at the bottom:
echo Running at boot<br>sh google-assistant-init.sh
What this does is every time the Raspberry Pi boots up, it will automatically start up Google Assistant. Save this file and reboot your Raspberry Pi. When it restarts, Google Assistant should be working. Say "Hey Google, What's the weather?" or anything else you want. Google Assistant is a voice assistant that triggers anytime you say "Hey Google" or "Ok Google." Feel free to ask it whatever you want :)
And we are officially done with all the software coding parts of this Smart Mirror Project!!!
Troubleshooting Tips:
Something didn't work? Try the following actions below to see if they fix the problem:
1. Occasionally (every month or so), you might run into an error message which doesn't let your Google Assistant work. It's very easy to fix though. Refer to steps 1-4 in Google's SDK documentation to reauthenticate your device and enter the authentication code into the Terminal in Raspberry Pi. Once that is finished, reboot your Pi device and you should be ready to go with Google Assistant again!
2. Some packages take a while to install (~20 - 30 minutes), so don't worry if you think a progress bar is stuck. If it is taking an unusually long time, ensure your internet connection is good and try rebooting your device and rerunning that problematic code.
3. If all the code works but you are not hearing a response from Google Assistant, ensure your speakers are powered with the volume turned up. Clearly say the activation phrase "Hey Google" or "Ok Google". Make sure that you are near the USB Microphone so it actually picks up your voice.
4. As with any software/packages type of development project, if you run into any error messages that keep showing up, try Googleing that exact error message to see how other people solved that problem.
Smart Mirror Housing - Lasercuting Hardware
Action Summary:
Why: Now that we are finally done with the software elements of this project, we are on to the must more flexible hardware part. This is where you don't necessarily need to follow everything exactly how I did it, you can personalize your projects or put your own spin onto it! If something doesn't quite fit or work, it is much easier to just fix it and make it work with hardware. In this step, we will create most of the parts needed for our Smart Mirror housing using wood panels that are laser-cut into the shapes we need.
Toughness Scale: I thought this step was one of the easiest and most fun parts of this entire Smart Mirror project. It is somewhere where you can put in your own creativity and imagination to design the exterior of your Smart Mirror.
Instructions:
If you are using different parts than I am for this Smart Mirror (like a different sized screen or a different version of a Raspberry Pi), the sizing of my Smart Mirror housing will likely be incompatible to fit your components. Make sure you measure everything and ensure that parts will fit. If they need to be adjusted, make sure you appropriately scale up or scale down these panels below so they fit your parts.
Important Note: We will be using Adobe Illustrator to design each of these panels because that is the file format compatible with the Laser Cutter I will be using.
1: Overall Design Schematic (The End Goal)
The first thing I did, before making the laser cut paths on Adobe Illustrator, was creating a CAD Model of how I envisioned the frame of the Smart Mirror to turn out. You don't need to do this, however, if you are looking to redesign some elements, I highly recommend it. It will make it much easier to get the dimensions of individual faces later on to laser cut them, and it helps you visualize your end goal so if something doesn't look right, you can catch a problem beforehand. Also, it helps you build around the parts you use to ensure they will end up actually fitting in your housing; for example, for this CAD Model, I was specifically designing it with the size of my LCD Display in mind. Too small and it won't fit; too big and it will look like the actual smart mirror screen area is small. You can find this initial CAD model I made of the frame in the images above.
2: Quarter Inch Side Panels
After creating this CAD Model, we will move on to creating the Laser Cut paths on Adobe Illustrator. This path tells the laser cutter where exactly to cut and create your parts. In my project, I used 0.25-inch wood to create these pieces as it is a little more robust and can add more structural support. All the other parts we will be making are out of 0.125-inch wood panels.
Side the left and right panels are the most complicated elements, design-wise (all the others are just rectangles), I found the CAD model really helpful to get these dimensions. You can find these exact dimensions and angles for these side panels in a picture above as well.
The first Left Side Panel also has cutouts for the I/O ports on my Raspberry Pi. This is so the USB Mic can be on the exterior of the Smart Mirror, and if I want to plug anything into the Pi, I still will have access to these ports. To create these cutouts, I precisely measured these I/O ports using calipers and the spacing between them. It is essential you do this correctly to make sure your Raspberry Pi can fit into these holes. You may have a design of the I/O ports if you are using a different model/version of the Raspberry Pi (I'm using a slightly older Raspberry Pi 3 for this project). Images for this process are included above in this step.
Finally, for the Right Side Panel, I also have a cutout for my Mini AUX Speaker to go into. If you are using a different speaker than what I am, make sure to also accurately dimension the object so it fits. Images with further information are above.
3: Eighth Inch Panels (Top, Bottom, Back, and Front Frame)
Next, we are going to design the paths of the Top, Bottom, Back, and Front Screen Frame. These are going to be much easier as they are just simple rectangles. Every part in the section is going to be made out of 0.125-inch thick wood.
The top panel is a rectangle 2.883 by 14.25 inches. The bottom panel is a rectangle 5.3904 by 14.25 inches. The LED Bar is a rectangle 0.625 by 14.25 inches, which another rectangle 0.45 by 13.9 inches. More detailed information is available in the pictures above.
Finally, the Screen Frame goes behind the LCD Screen we will be using so the width of the part fits snug into our Smart Mirror housing. This is a rectangle 8.375 inches by 14.25 inches, with a hole for the data wires of the display to go through; this hole is 2 inches by 8 inches. Refer to the images above for more dimensioning details and information.
You may see extra platforms scattered around in these laser cuts, and this was just something I added proactively to be used in my project if I needed them (I ended up using a lot of these random parts). These include small pieces of wood that are super versatile and can be used to secure parts together, cable management, or anything really! For information of these extra platforms I used are in the images above.
4: One Way Mirror Acrylic
The last part we will be making a laser-cut oath for is the One Way Mirror Acrylic. As you bought it, it is highly likely that it is not the exact dimensions needed to fit in our Smart Mirror Housing. I cut the panel to 8.5 by 14.75 inches to perfectly cover the front face of our Smart Mirror Housing.
5: Laser Cut Everything
The final element to this laser-cut step is to actually laser cut all the parts we designed above. Check out the troubleshooting tips below if you need additional information about laser cutting these parts, including the settings that worked for me and some important information about laser cutters (if you are a beginner to laser cutting, please completely read the tips below).
Troubleshooting Tips:
Something didn't work? Try the following actions below to see if they fix the problem:
1. The laser cutter I used was the VLS3.50. If somehow, the wood is not cutting, the following laser cutting settings worked for me: Material - Wood > Natural Wood > Birch; Material Thickness - 0.125 inches or 0.25 inches depending on how thick the wood I used was.
2. For some laser cutters, you need to define vector paths at a specific thickness and color. For example, the cutter I used required all cut lines to be 'red' in color and 0.01 inches thick, otherwise it wouldn't read those lines in the Illustrator file.
3. Make sure to focus the laser on the laser cutter when you begin and every time you switch material thicknesses.
4. Because the laser cutter is probably the most dangerous instrument we will use for this entire project, make sure you are an expert in how to use it or are supervised by an expert. Wear safety equipment, and monitor the entire cut process to make sure no fires start.
5. When we laser cut the one-way mirror, we used the following settings: Material - Acrylic > Continuous Cast Acrylic; Material Thickness - 0.039 inches. We laser cut with both protective films on, we didn't peel them off.
Smart Mirror Housing - CAD Hardware
Action Summary:
Why: Next, we are going to 3D print some additional pieces to help us build a stronger Smart Mirror housing. This will include right-angle brackets to increase the surface area of our adhesive to glue our panels together stronger. We will also be 3D printing a magnet holder to house the magnets required to hold the top panel in place. Magnets make sure the piece is held somewhat securely, but also, if needed, we can take the top panel off to perform maintenance and fix things up if inside the Smart Mirror if they break.
Toughness Scale: This step is also relatively easy; we're not going to design anything super crazy on CAD. It will just be basic shapes to get the job done, and therefore, you can have no 3D printer experience but still do amazing on this step.
Instructions:
This step will require CAD software. I used OnShape, however, a free online alternative is TinkerCad. You will also need a 3D Printer Slicer downloaded on your computer, and the ideal slicer varies depending on what model/company 3D printer you are using; I used the free Prusa Slicer.
Feel free to use the images above to guide you through this process. I think pictures for the hardware steps can go miles to clear up any questions that may come across your mind.
1: Right Angle Bracket
First, we are going to CAD the Right Angle Brackets (to secure the laser cut panels together for the Smart Mirror). First sketch a 1 inch by 1 inch "L Shape" that's 0.18 inches thick. Then extrude this part by 0.25 inches. Finally, chamfer the outer edges by 0.1 inches (this is purely for design, the chamfer doesn't really add anything haha). Awesome, you are done with this part!! That was easy right?
2: Magnet Holders
Next up, we are going to CAD Magnet Holders to make the top panel of the Smart Mirror Housing magnetically attached. To create this part, sketch a square 1 inch by 1 inch. Extrude this by 0.5 inches. On the top face of this object you just created, sketch a circle with a diameter of 0.72 inches (the size and shape of this may vary based on what magnets you are using). Finally, cut a hole 0.225 inches into this rectangular prism (again, this depth may vary based on the size of the specific magnets you are using).
If anything didn't make sense, refer to the images above; this should have also been a relatively easy part to make :)
3: 3D Print The Parts
Awesome! Now that we CADed both parts, download the STL files and open up a 3D printer slicer (I used Prusa Slicer). The slicer is important because it converts your STL files into instructions that your specific 3D printer can understand and print. This is also where you can duplicate these parts to print more than one; I printed 20 L Shaped Brackets and 4 Magnet Holders (all of them fit onto 1 build plate on the Prusa Mini 3D Printer I used).
To make these parts print a little bit stronger, because they are going to aid the structural stability of the Smart Mirror Housing, I used 30% infill to create more dense and strong parts. Infill refers to how hollow your part is; by default, most slicers set this number to 15%.
Troubleshooting Tips:
Something didn't work? Try the following actions below to see if they fix the problem:
1. When you import the STL files into your Slicer, sometimes the object is imported with the wrong units (for example, if something is dimensioned 1 inch by 1 inch by 1 inch, the slicer loads it in with the dimensions 1 cm by 1 cm by 1 cm). To fix this, either change the units on the Slicer Software or scale up the object using the appropriate scale factor.
2. These prints have no overhangs, so you should not need to use supports.
3. If everything works and you are able to start the print on your 3D Printer, but it prints inaccurately or messily, you may need to refer to the troubleshooting tips of your specific 3D Printer. The problem can be an unleveled print platform, old filament, or something different.
Smart Mirror Assembly - Wiring Things Up
Action Summary:
Why: In this step, we will continue making hardware progress on our Smart Mirror, specifically the electrical component of it. We will build/wire up our LED indicator bar at the bottom, to show when Google Assistant is activated, and we will also configure our power supply to work with our 12V screen and all the other 5V components (wiring everything up to 12V is extremely dangerous, and could result in serious damage).
Toughness Scale: The electrical part of this project is fun, however, it is important to take special attention during this process (if you are up at 2 AM right now, it is probably best to take this one on tomorrow). Although everything is straightforward, making small mistakes can cost a lot, so take this step slowly and be thorough.
Instructions:
Remember, following along with the pictures above can also help if you ever get stuck or don't understand something!
1: Building the LED Bar
Take the LED Bar Frame that we laser cut from before (the long narrow and hallow rectangular part). After I laser cut it, it felt a little flimsy to me so I added some supports throughout the bar. Using some of those extra support rails we also cut (I knew they would come in handy!) I used my Stright Cut Snip to cut a rail to size (about 0.3 inches), and hot glued a few of them across the bar. This made it instantly feel much more rigid.
Next, using the diffusing paper, I cut it to size and hot glued a strip onto the LED Bar. This diffusion paper diffuses the light from our LEDs to make them softer instead of bright at a single point. Hot Glue them on one side of the LED Bar (this will end up being the flush side facing out on the exterior of the Smart Mirror).
Before we continue, we have to make sure our LEDs actually work (it would suck to glue them all in only to see they didn't work). To do this, I used a breadboard and connected them up to GPIO Pin 25 (positive) on the Raspberry Pi and a ground pin (negative). Refer to the picture of this step above to locate these pins. Previously, we have already set up our Google Assistant code to power these specific pins when Google Assistant is activated, so no further code is required. Once everything is hooked up into the Raspberry Pi, say "Ok Google" or "Hey Google" and the LEDs should illuminate (if they don't, make sure the negative and positive ends of the LEDs are plugged into the breadboard correctly). For this LED Bar, I am using 3 LEDs.
Once the LEDs are verified to work, hot glue them, evenly spaced, onto the backside of the diffusion paper (the non-flush side). Wait for them to dry, and then wire them up in a parallel circuit (negative terminals all connected, positive terminals all connected). Do not connect them in a series circuit or connecting negatives to positives to create one loop because then the LEDs will not be bright enough to see.
Once they are hooked up, we are done building our LED Bar!
2: Setting Up The Voltage Regulator
Next, we need to set up our Voltage Regulator to make sure it converts our 12V DC Power from the adapter we have into 5V to power everything in the Smart Mirror that's not the screen. To do this, we first need to power the voltage regulator by connecting the positive and negative input terminals in the voltage regulator to the positive and negative wires of the DC Power. Once we powered the regulator, the small LED panel should illuminate and tell you the output voltage.
Although this may vary based on the model of voltage regulator you have, to change the output voltage, you have to turn the left screw on the board counter-clockwise to decrease the voltage. Decrease it until it says a voltage between 5.0V and 5.1V. Now, put a dabble of hot glue on the screw to make sure nothing accidentally spins it to a different voltage. Awesome, you have set the voltage on the voltage regulator!
3: Testing Everything Electrically
Before doing this step, make sure to initially unplug your 12V DC Power Adapter from the wall.
Now, electrically hook up the Raspberry Pi and Speaker onto the positive and negative output terminals on the Voltage Regulator (5V Current) and hook up the LCD Screen Controller Board to the 12V current (positive and negative current before the input terminal of the Voltage Regulator). From the controller board, there is a 40 Pin wire that connects to the back of the LCD Panel that powers and provides an input signal to the screen. Plug this 40 Pin connector in. Also, run an HDMI cable from the Raspberry Pi into the LCD Controller Board.
This is all to electrically test if everything works from that single 12V DC Power input cable. Now, the moment of truth... Plugin the 12V power cable, and watch the LCD Screen and Raspberry Pi power up! The Magic Mirror software is set to automatically open when the Pi boots up, so once it loads up, you should see the Magic Mirror UI on our LCD Panel!
Anddd we're done with this step :) YAYY!! Only a couple more steps and we are finished with this Smart Mirror project!
Troubleshooting Tips:
Something didn't work? Try the following actions below to see if they fix the problem:
1. If your LEDs aren't working, make sure you tested them using the appropriate voltage (this varies by LED). A low voltage will not power the LED, but a high one may fry it.
2. If your LEDs are still not working, make sure the positive wires are connected to the right terminal, and the negative wires are connected to the right terminal. The positive terminal on an LED is the longer leg of the diode, while the negative terminal is on the shorter leg.
3. When configuring the Voltage Regulator, make sure you turn the screw clockwise to increase the voltage and counter-clockwise to decrease the voltage. Since the factory voltage is set at a high value (around 25V), you may need to turn the screw counter-clockwise a couple of times to decrease the voltage enough to display a change on the little LED Screen.
4. If an amber light appears on your Voltage Regulator device, make sure that none of your power cables (input or output) is cross touching each other, when the positive end in direct contact with the negative end.
Smart Mirror Assembly - Putting Everything Together
Action Summary:
Why: We are almost done with the project! Most of our pieces are created, now it is just a matter of putting everything together to create one cohesive and bomb Smart Mirror. That is what we will be doing in this step! From assembling the Smart Mirror to connecting all the wires to make this work, this is going to be one big step, but we'll get through it :)
Toughness Scale: This is going to be one of the hardest parts of the entire project. Remember to approach every step with real care because you will shape how your Smart Mirror will look now. The more careful you are, the more polished your Smart Mirror will look.
Instructions:
Like the previous couple of Hardware steps, pictures can go a long way to explain how to do something. If you ever don't understand anything, try to locate that step in the gallery of pictures above, and most probably, your question will get resolved :) This is the most fun step in my opinion because we finally put almost everything together; we have all the parts and everything works, now it's just a matter of putting it together!
1: Assemble Back and Bottom Panels
The first two parts we will put together are the back panel and the bottom panel of the Smart Mirror Housing (these are both 0.125-inch panels we laser cut before). Thread the 12V Power Cable through the notch we made for it in the back panel and remember to thread it in BEFORE gluing the 2 panels together. Once you put the cable of the 12V DC Power through the notch, use hot-glue to secure the panels together. Make sure to put the bottom panel against the back panel (DO NOT put the back panel on top of the bottom panel as our tolerances will be off then). Use as many of those "L-Shaped Brackets" we 3D printed to add support to this structure.
Keep in mind that it doesn't really matter if the inside is ugly, so you don't need to measure the spacing of the L-Shaped Panels or worry if the hot glue looks weird from the inside; just make sure the outside looks good.
2: Set Up And Add the Right Panel
Next, we are going to glue our speaker onto our Right Panel. Remember that speaker cutout hole we made onto it? The circular speaker should fit in there perfectly (put it in from the outside and slide it into the panel). Hot glue the edges of the speaker onto the panel to secure it in place. Make sure the speaker's I/O (charging port and AUX port) is pointing upwards so it is easier to connect up later in the project assembly.
Once the speaker is attached, connect this right panel onto the other 2 panels we secured together. Use the same process: Hot Glue and "L-Shaped Brackets" to adhere the panels together. Make sure you have made a solid connection between the right panel and the bottom panel AND the right panel and the back panel.
Right here, I took a small pause to quickly check if all the electronics are still working in order through the 12V DC Power we threaded into the housing. Make sure that the voltage regulator, Raspberry Pi, Speaker, and LCD Screen all work properly of that same 12V power supply because once we are done, they will have to all work of that same electric supply.
3: Glue the LCD Screen onto the Screen Frame Panel
After verifying everything works, take our laser-cut Screen Frame Panel and glue it to the back of our LCD screen. When you glue the screen onto the frame, make sure that the Screen's 40 Pin Connector can still be accessible through the hole we designed into the frame (THIS IS IMPORTANT because if you do it wrong, we can not power the screen and make it do anything). Refer to the pictures above to see this step clearly.
After the Screen and Panel have adhered with hot glue, precisely measure the thickness of the total part using calipers. My screen and frame part was about 0.362 inches thick (but yours might be different). Set your screen and frame part aside for now, and take your Left Panel (still not attached yet).
From the screen edge of the left panel (the part that slopes down), measure 0.362 inches away from the edge (or the measurement of the thickness of your screen frame part) and draw a line. Do this same process for the right panel that is already attached to the Smart Mirror Housing (it should be a little easier because we have not yet attached the left panel into the frame). We will use these markings to help us later on in the assembly process.
4: Attach the Left Panel
Not that you have made this marking, you can attach the left panel onto the Smart Mirror Housing assembly we have so far (use Hot Glue and "L Shaped Brackets). Next, insert the Raspberry Pi into the I/O holes in the left panel we made. For me, it fits very snugly and this fit was enough to hold the Raspberry Pi onto the frame surprisingly securely. To put it in, I had to remove the USB Microphone to make it fit, and then connect the USB Mic on the Pi again after it was in. However, just for added safety, I've added one of those extra platforms we laser cut before underneath the Raspberry Pi to provide more support, again using Hot Glue and L Brackets.
Please refer to the pictures for a better idea of what I'm talking about :)
5: Secure the LED Bar
You should start to see the Smart Mirror Housing taking shape now! Next up, we are going to adhere the LED Bar on the bottom slant of the housing. Secure the LED Bar we made in the previous step by hot gluing the part onto the left and right side panels as well as the bottom panel (since the bar is quite narrow, our L Brackets are too big, however, the hot glue holds it pretty tight by itself).
With all the pieces almost assembled, connect the LED Bar onto GPIO 25 Pin (the same pins we tested the LEDs with in the previous step). Run an AUX cable from the Pi to our Speaker. Glue our voltage regulator onto the base of our Smart Mirror Housing so it doesn't move, and power the Raspberry Pi and Speaker with the 5V output terminals of the voltage regulator. Using our DC Splitters we have, split our 12V DC Power into multiple outputs, one going directly into the input power of the voltage regulator. We will use the other split 12V DC output to power the LCD Screen.
Now, add in our LCD Screen Controller Board, and plugin that split 12V DC Power into it. Now, also run an HDMI cable from the Raspberry Pi into the Controller Board. The Controller board has a couple of bottoms that come of it, to change things like brightness and contrast. I glued this button panel onto the back panel of the Mirror Housing to make it accessible from the top (since the top will be magnetically held, it is our only outlet inside the Smart Mirror to debug).
Next, it may seem like there are a million cables going all over the place, so spend some time on that cable management to make it slightly less messy.
6: Attach the Screen Frame with the LCD Screen onto the Frame
Remember those markings we made 0.362 inches away from the edge of the left and right panels? Take some of those extra support rails we Laser Cut from before and glue them behind the line (closer to the back of the housing). This will support the LCD Screen and Frame on the housing and will ensure it will be flush with the surface of the Smart Mirror Housing.
Once you added those support rails, slide in the LCD Panel and connect it to the LCD Controler board with the 40 Pin Connector. We are not going to specifically glue this LCD Panel onto those support rails or onto any part of the Mirror Housing just to increase repairability should any part break. If everything is permanently glued on, if one part breaks, you might have to scrap the entire project :(, so we are going to avoid that as much as possible.
Next, I used a black permanent marker to shade in the white bezel of the LCD Panel to make it less visually apparent behind the one-way mirror (which we haven't attached yet).
7: Setup the Magnet Holders and Attach the Top Panel
We're almost done! Take those magnet holders we 3D Printed and hot glue magnets into them. Remember, the depth is two times that of a single magnet, so drop another one in there to ensure both have their non-repelling side touching each other. Repeat this step for all four of the magnet holders we 3D Printed.
Next, hot glue one magnet holder in each of the two rear corners, 1/8in inch under the top (to make sure when the top plate attaches, it is flush with the top of the housing). With the two extra magnet holders, hot glue each one onto the magnet holder already adhered onto the corner of the Smart Mirror Housing (so that the magnet holder has contact with another magnet holder and the back panel, not the side panel). In the end, one magnet holder has an edge touching the right panel and back panel, another one has contact with the left panel and back panel, and two have contact with on edge of a magnet holder and the back panel). Refer to the formation in the images to get a better idea of this.
Finally, put a healthy dabble of hot glue on the top of every visible magnet and swiftly place the top panel into place (put pressure on the places that make contact with the magnets). Wait for about 30 seconds, and pull the top panel off... you should see that four magnets have adhered to the top panel in the precise locations to connect up with the magnets held inside the magnet holders. You successfully made a magnetically attachable top panel.
8: Secure the One-Way Mirror
Finally, the last step you have to do to finish the Smart Mirror Housing is to attach the one-way mirror on top of the LCD Panel. Carefully peel of the protective films (there is one on both sides). The side with the blue film is the side that needs to be facing away from the LCD Panel, so position it in that direction. Use four blobs of hot glue, one on each corner of the LCD Panel, and adhere the one-way mirror onto the screen (do not adhere it onto the side panels at all, the only place it should be connected to is the 4 corners of the LCD screen bezel.
Once that is done, you should have a functioning Smart Mirror!
9: Plug It In!
The last step in this process is to plug in the 12V DC Power Adapter and see the magic happen! The only step we have left is to add the wireless charging, but that's super quick!
Troubleshooting Tips:
Something didn't work? Try the following actions below to see if they fix the problem:
1. If you did something wrong, and you can't undo it, like gluing the wrong piece to something, try to improvise. That's what I love about hardware, there are always a million different ways to do something or hide a mistake. The housing can be as elaborate or simple as you like!
2. Remember, we made the top panel magnetically attached. If something doesn't work, don't be afraid to pop the hood of the Smart Mirror to check what's wrong.
Smart Mirror Assembly - Wireless Charging
Action Summary:
Why: Now that we have a Smart Mirror completed and working, I wanted to take it to the next level with a built-in wireless charger. The Top Pannel of our Smart Mirror was made out of 1/8th inch wood, which makes it thin enough for a wireless coil to transmit energy through it. With many electronic devices coming with wireless charging nowadays, I thought it would be cool to have a wireless charger in the Smart Mirror to make its utility value even more.
Toughness Scale: This will be probably the easiest step in the entire project, so if you made it till here, this next one is a piece of cake. All we will be doing is unscrewing an existing Wireless Charger, taking out the coil, and gluing it into our Smart Mirror Housing.
Instructions:
Like before, refer to the pictures above to get a visual idea of what to do if you are ever stuck.
1: Disassemble an Existing Wireless Charger
First, take an existing Wireless Charger. I had an old one just laying around so it was perfect for this project. Unscrew some screws at the bottom (sometimes they are hidden under stickers) and the wireless charger coil and board should just fall out!
2: Attach onto the Bottom Face of the Top Panel of the Smart Mirror Housing
Our top place is only 0.125 inches thick, so we don't need to worry about the wireless charging not working through it. Hot glue the wireless charging coil onto the Top Pannel of the Smart Mirror Housing (the one that magnetically attaches). For me, I used small squares cut with the Stright Cut Snip to create a sort of even platform that the wireless charger can get adhered to, however, if your coil is flat enough to lat flat against the top panel, you can skip this step and glue it right onto the top panel.
3: Plug into the 5V Power Supply
Finally, plug your wireless charger into the 5V power supply which is the output terminals of the voltage regulator. I have a pretty old wireless charger, so 5V was the max power it can push, however, if you have a more recent wireless charger that's compatible of faster charging at 12V or above, you can hook up the power directly to the 12V DC Power Adapter to get faster wireless charging speeds.
Plugin the Smart Mirror and enjoy the wireless charging on the top panel!
And now, you have successfully completed all the steps in creating your Smart Mirror with Google Assistant and Wireless Charging built-in!
Troubleshooting Tips:
Something didn't work? Try the following actions below to see if they fix the problem:
1. If you put your wireless charge-capable device down on top of the Smart Mirror and it doesn't start charging, you may have to move it around a little bit so the coils align. I found that after a couple of days, my muscle memory kicked in and I was automatically placing the phone down in the space where the coils align. However, if this becomes annoying, feel free to put a marker down in the location where the coils line up so it is easier to use (a marker can be anything from a sticker to a pencil mark or anything else).
And We're Done!
🥳 🎉 Congratulations! You did it!!
You have successfully made a Smart Mirror with Google Assistant and Wireless Charging built-in. I'm genuinely proud of you!
If you want a complete picture of all the problems I encountered when I took on this project, I've made my engineering notebook for this project open for anyone to view. If you have any questions about this project, feel free to put them in the comments section below; I'd love to help :) If you would like to show me your creation, I'd love it; send me pics!
Once again, huge shoutout to everyone who put their resources and guidance online to help me complete this project—I wouldn't have been able to do this project without you guys.
Special thanks to Ms. Berbawy and my entire 2020-2021 Principles of Engineering Class at Irvington High School for your support! Learn more about what we're up to on our website.