Raspberry PI Smart Mirror (ft. MagicMirror 2)

by luxymay_ in Circuits > Raspberry Pi

137 Views, 2 Favorites, 0 Comments

Raspberry PI Smart Mirror (ft. MagicMirror 2)

smart_mirror.JPG

Our smart mirror displays useful information like the time, weather, and news updates on its reflective surface. The Magic Mirror software allows full customization (open source) and plenty of APIS made by the community.

Our Purpose

The purpose of this build was to create a functional and visually appealing smart mirror that combines technology with everyday convenience. It was a fun and rewarding experience to program the features, such as displaying the time, weather, and even integrating Spotify for music control. The project allowed for creativity and problem-solving while working with hardware like a Raspberry Pi and software like MagicMirror. Not only was it an enjoyable learning experience, but the finished product is also a sleek and stylish addition to any room, offering both practicality and an impressive aesthetic.

Our Pitch Video

https://www.youtube.com/watch?v=5rERKMuSJwA&t=12s

Supplies

IMG_4273.JPG
IMG_4179.JPG
  1. Raspberry PI 4
  2. Micro-HDMI to HDMI
  3. Monitor
  4. Reflective Mirror Film
  5. Keyboard
  6. Mouse
  7. Micro SD Card
  8. USB-C cable and a Charger

Set Up the Raspberry Pi

restart.png
IMG_4274 2024-12-08 01_35_09.JPG

Set Up the Raspberry Pi

Download the Raspberry PI OS from the official website onto the micro-SD

https://www.raspberrypi.com/software/operating-systems/


Put the SD card into the Raspberry PI.


Connect your Raspberry Pi to a monitor, keyboard, and mouse.

  1. After connecting it to a power source. Allow the Raspberry PI to set itself up.


Set Up the Correct Time Zone

Open the Terminal

Launch the terminal on your Raspberry Pi.

Access the Raspberry Pi Configuration Tool

Type the following command and press Enter:

sudo raspi-config

Navigate to Localization Options

  1. In the configuration menu, use the arrow keys to navigate to "Localization Options" and press Enter.
  2. Select "Change Time Zone" and press Enter.

Select Your Time Zone

  1. First, choose your geographic region (e.g., "US").
  2. Then, select your specific time zone (e.g., "Eastern," "Central," "Pacific," etc.).

Exit the Configuration Tool

  1. After setting the time zone, press "Finish" to exit the configuration tool.

Reboot the Raspberry Pi (Optional)

If the time zone change does not immediately take effect, reboot your Raspberry Pi by typing:

sudo reboot


Download GitHub and Magic Mirror

what-is-github-1-1-1024x512.png
IMG_4062.JPG

Install Node.js

  1. Download and install the required version of Node.js. Refer to the official documentation for your operating system (Linux or others).

Check for Git

  1. Confirm that Git is installed by running git in the terminal. If it’s not installed, you’ll need to install it first.

Clone the MagicMirror Repository

  1. Use the following command to copy the MagicMirror files to your Raspberry Pi:
git clone https://github.com/MagicMirror/MagicMirror

Navigate to the MagicMirror Folder

  1. Enter the directory where the MagicMirror files are stored:
cd MagicMirror/

Install the Application

  1. Run the installation process with this command:
npm run install-mm

Set Up the Configuration File

  1. Copy the sample configuration file to create your own config file:
cp config/config.js.sample config/config.js

Start MagicMirror

  1. Launch the MagicMirror application with:
npm run start
  1. For server-only mode, use:
npm run server


Install Pm2

Install PM2

  1. Install PM2 globally using npm:
sudo npm install -g pm2

Navigate to Your Project Directory

  1. Use the cd command to navigate to the folder containing your Node.js project:
cd ~/MagicMirror


Start Your Application with PM2

  1. Start your application using PM2:
pm2 start npm -- start
  1. If your project uses a different script, replace npm -- start with the appropriate command, such as node app.js.


Save the PM2 Process List

  1. Save the current PM2 process list so it can be restored after a reboot:
pm2 save


Enable PM2 Startup on Boot

  1. Run the following command to set up PM2 to start automatically on boot:
pm2 startup
  1. This will output a command specific to your system. Copy and paste that command into the terminal and execute it. For example, it might look like this:
sudo env PATH=$PATH:/usr/bin pm2 startup systemd -u pi --hp /home/pi


Verify Auto Boot

  1. Reboot your Raspberry Pi to test that the application starts automatically:
sudo reboot
  1. Once the Raspberry Pi restarts, check if PM2 has restored your process by running:
pm2 list


Stopping and Managing PM2 Processes

  1. To stop a process:
pm2 stop <process-name-or-id>
  1. To delete a process from PM2:
pm2 delete <process-name-or-id>

This will allow you to keep MagicMirror running all the time.

Adding Modules

IMG_4075.jpg

For our project, we added MMM-Spotify.

https://github.com/skuethe/MMM-Spotify


Install MMM-Spotify

cd ~/MagicMirror/modules
git clone https://github.com/skuethe/MMM-Spotify
cd MMM-Spotify
npm install


Setup Spotify


Be a premium member of Spotify

  1. Go to https://developer.spotify.com
  2. Navigate to DASHBOARD > Create an app (fill information as your thought)
  3. Setup the app created, (EDIT SETTINGS)
  4. Redirect URIs. : http://localhost:8888/callback
  5. That's all you need. Just save it.
  6. Now copy your Client ID and Client Secret to any memo

3. Setup your module


cd ~/MagicMirror/modules/MMM-Spotify
cp spotify.config.json.example-single spotify.config.json
vim spotify.config.json


Edit the spotify.config.json with the editor of your choice. Modify the entries as hinted below, then save it.

[
{
"USERNAME": "A_NAME_TO_IDENTIFY_YOUR_ACCOUNT",
"CLIENT_ID": "PUT_YOUR_SPOTIFY_APP_CLIENT_ID",
"CLIENT_SECRET": "PUT_YOUR_SPOTIFY_APP_CLIENT_SECRET",
"TOKEN": "./USERNAME_token.json"
}
]


Add it to the Config.Js file for MagicMirror

{
module: "MMM-Spotify",
position: "bottom_left",
config: {
debug: false,
}
}


Install Reflective Film on Your Monitor

Installing Reflective Film on a Monitor


Prepare Your Workspace

  1. Clean a dust-free, flat surface to work on.
  2. Make sure the monitor screen is clean and free of dust or fingerprints.


Measure and Cut the Reflective Film

  1. Measure the dimensions of your monitor’s screen using a ruler or measuring tape.
  2. Cut the reflective film to match the screen size, leaving a small margin (about 1–2 mm) for easier application.


Clean the Monitor Screen

  1. Use a lint-free cloth and a screen-safe cleaner to remove dust and debris from the monitor.
  2. Allow the screen to dry completely.


Apply the Reflective Film

  1. Peel off a small section of the film's backing from one corner.
  2. Align the exposed edge with the top edge of the monitor.
  3. Gradually peel the backing while smoothing the film onto the screen using a credit card or a squeegee to remove air bubbles.
  4. Work slowly to ensure the film adheres evenly across the screen.


Smooth Out Air Bubbles

  1. If air bubbles remain, gently lift the film and reapply, using the squeegee to press out bubbles as you go.
  2. Trim any excess film with a craft knife or sharp scissors if needed.


Final Check

  1. Inspect the monitor under different lighting conditions to ensure the film is applied smoothly and evenly.


Using a Two-Way Acrylic Mirror Instead of Reflective Film (Optional)

If you prefer a sturdier and more professional look, use a two-way acrylic mirror:

Measure your monitor and purchase 2 way acrylic mirror to its dimensions

Attach the Acrylic Mirror to the Monitor

  1. Use double-sided adhesive tape or mounting strips around the edges of the monitor bezel.
  2. Carefully align the acrylic mirror with the monitor and press it firmly into place.

Ensure Proper Viewing

  1. Test the monitor display to ensure the acrylic mirror does not obstruct the visibility of the screen.
  2. Adjust the brightness and contrast settings on your monitor, as the mirror may slightly dim the display.

Secure the Edges (Optional)

  1. For additional stability, you can use a thin frame or clips to hold the acrylic mirror in place.


Connect Your Raspberry Pi to the Setup and Enjoy!

Customize and Test

  1. Adjust module settings to fit your preferences and test your smart mirror.
  2. Ensure all features, including Spotify, are functioning correctly.


Improvements After Completing the Project

This Magic Mirror was designed and put together by our Introduction to Engineering Group. Due to our limited time outside of class (we all work full/part time jobs), we weren't able to integrate many features we wanted to add. For example, we can add a PIR sensor in the future for a sleep-mode to save power. The PIR sensor could also be used to program an LED strip that wraps around the mirror for automated lighting. We also want to measure and add a frame to make it more visually appealing. Also, the film we chose wasn't as reflective as we expected and has some visual warping so be mindful when shopping for a reflective surface.

Thank you to the Circuit Critters team for their resilience this semester! We made it. :3