Magic Bathroom Mirror

My smart bathroom mirror based on MagicMirror². My goal was to create a thin, good looking mirror with following features:

  • Current time
  • Weather forecast
  • Internet radio player
  • Motion sensor to put the mirror on standby
  • Low power consumption

Components

  • Observation mirror
  • LED LCD laptop display with minimal power consumption
  • Compatible LCD controller board
  • Raspberry Pi Zero
  • SD-card
  • Wifi dongle
  • 12C Power Supply
  • 12V to 5V DC converter
  • 2 Speakers
  • PIR motion sensor HC-SR501

I made the case out of acrylic glass. I found an online shop where I could order custom cut pieces.

Software Setup

I started with a fresh installation of Raspbian Stretch Lite and made sure the system is up to date:

$ sudo apt-get update
$ sudo apt-get dist-upgrade

Then I rebooted the Pi to ensure the latest kernel is loaded:

$ sudo reboot

To rotate the screen I added a parameter to /boot/config.tx:

# Rotate screen
display_rotate=1

I enabled autologin for the pi user using raspi-config and selecting Boot Options -> B1 Desktop/CLI -> B2 Console Autologin

Then I manually installed the latest nodejs for ARMv6 from the official download page and Git and the Chromium browser using the package manager:

$ sudo apt-get install git chromium-browser

This should also install Xorg and all the dependencies.

I cloned the magic mirror repository and installed the npm dependencies:

$ cd /opt
$ sudo mkdir mirror
$ sudo chown -R pi:pi mirror
$ git clone https://github.com/MichMich/MagicMirror.git mirror
$ npm install

Then I created a systemd script /etc/systemd/system/mirror.service to start the magic mirror server on boot:

[Unit]
Description=Magic mirror nodejs server
After=network.target

[Service]
WorkingDirectory=/opt/mirror/
ExecStart=/usr/local/bin/node serveronly
Type=simple
User=pi
Restart=on-failure

[Install]
WantedBy=multi-user.target

I enabled the service:

$ sudo systemctl enable mirror.service
$ sudo systemctl start mirror.service

I then added some lines to /home/pi/.bashrc to start Xorg as soon as the magic mirror server is up and running:

if [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]]; then
  until nc -z localhost 8080; do
      echo "Waiting for mirror ..."
          sleep 1
  done
  exec startx -- -nocursor
fi

To start chrome I modified /home/pi/.xinitrc as follows:

#!/bin/sh

xset s off # disable screensaver
xset -dpms # disable DPMS
xset s noblank # don't blank the video device

exec chromium-browser --incognito --no-first-run --ignore-certificate-errors --disable-translate --disable-infobars --disable-suggestions-service --disable-pinch --overscroll-history-navigation=0 --kiosk http://localhost:8080

Modules

Previous Post Next Post