Han Lu

Blog: Smart Mirror

March 26, 2023

Creating a Smart Mirror with Raspberry Pi 4 B

Recently, I constructed a small Smart Mirror from scratch. The material I used to construct this includes a Raspberry Pi 4 B (which sells at $35 MSRP, but easily goes for $100+ at the moment due to chip shortages...), a 21'' x 13'' two-way mirror ($150+), a 21.5'' 1920 x 1080 LCD monitor/screen, a black frame (might repaint or replace), a USB-C power supply, a micro-HDMI to HDMI cable, a USB-C to USB cable, mounting hooks, screws and a micro-SD card.

Honestly, getting started was a bit troublesome, since it was impossible to find RPi boards that were less than $100 that shipped within a month.

Prices

I ended up purchased the RPi4 4GB off of Canakit.com, in a bundle that included a preformatted micro-SD card. I connected the RPi to a monitor, an external keyboard and an external mouse.

LCD View 1

I flashed the Raspberry Pi OS onto the micro-SD card, and after setup/installation installed Node, MagicMirror and pm2. I configured MagicMirror's modules, creating API keys for WeatherBit and OpenWeatherMap to acquire real-time data for weather. I incorporated other third-party modules including a fact-of-the-day library, an SVG-image drawing module, and configured default modules for a more personalized experience. Additionally, I created a script to run the program on boot, using pm2 to save the script and relaunch on failure.

hidden

The project was not as hard as I had originally anticipated, with the hardware/construction being the greatest difficulty--precise physical engineering definitely utilizes a different skillset than software engineering--but nontheless, the project was enjoyable to put together. If you're reading this, and you've thought about making a smart mirror, you should absolutely go for it. Perhaps waiting out for Raspberry Pi board shortages to end or purchasing a used RPi/Arduino would be a more fiscally conscious way to approach this project. I had also been debating a larger mirror size, but opted for a more transportable (and affordable) weight.

RPi4

Though the software process was largely painless, orienting the screen from landscape to portrait was a bit annoying, as I could only rotate the entire Raspberry Pi OS rather than just the MagicMirror program. Also, using the mirror in a sunlit room or a room with the lights turned on is somewhat difficult:

Sunny

It's hard to figure out where to put this mirror in a tiny NYC apartment. There's not much space to construct anything too bulky, so I'm thankful I chose a smaller mirror/monitor size. I also considered using an RPi3, but those took even longer to get shipped compared to any of the RPi4 models... sheesh. I did encounter an unexpected problem, in which my screws and mounting brackets were deemed 'edible enough' by the curious canine. He came dangerously close to having metal deposits in his tummy.

Dog

This guy tried to lick the mirror clean before I recruited him to the photoshoot.

Dog

All in all, I'm pretty happy with my choice in hardware and the customized modules. The frame, mirror and screen fit snugly while remaining sturdy enough to withstand a bit of duress, but also have easy accessibility to the USB ports in case I want to quickly reconfigure or customize with a keyboard + mouse.

Dog

I still have a few things I need to troubleshoot/fix. For one thing, sometimes on boot the RPi does not connect to the wifi while starting the MagicMirror script. I also need to disable the screensaver so the mirror script can run continuously. Finally, I need to actually find a place to hang this up.

clear

On my to-do list for future features, I would consider purchasing the new Camera module to configure facial recognition, an IR/infrared sensor for gesture-based mirror navigation, a microphone for voice recognition, and perhaps incorporting more real-time data feeds. It might also be cool to incorporate touchscreen responsiveness, but probably not for awhile. I've messed around with the custom CSS, but I haven't found a particular color scheme or style that I like more than the default yet.

Thanks for reading! It was a lot of fun to make this, and I hope to make more IoTs in the future. I'm considering alternatives to Raspberry Pi, seeing as the current price is inverse to their mantra of making computational hardware accessible. Good luck if you try it out yourself, and feel free to reach out to me if you need help!