Installing Magic Mirror² on a Raspberry Pi Zero

The MagicMirror² platform isn’t designed to run on a Raspberry Pi Zero out of the box, but it’s definitely possible to get it working. I’ve used it on one of my Magic Mirrors in the past. It did take some tinkering, and wasn’t as easy as the 5 minute setup is, but it’s not an unmountable task! So here’s how to do it.

This guide will only look at how to install the platform onto the Pi, so I if you haven’t already set up an OS on the Pi, connected it to Wifi, etc, please go through steps one to five steps in this guide, and then come back to finish here.

1. Install Node.js

start by opening up Terminal (if you’re on a Mac) or Command Prompt (Windows) and connect to the Pi through SSH (replace the part after @ with the correct IP address:

1
ssh pi@192.168.X.X

Type in the password when prompted, the default is raspberry.

Install Node.js by copying and pasting or typing each code snippet line below one by one:

1
2
3
4
5
wget https://nodejs.org/dist/v4.4.5/node-v4.4.5-linux-armv6l.tar.gz
tar -xvf node-v4.4.5-linux-armv6l.tar.gz
cd node-v4.4.5-linux-armv6l
sudo cp -R * /usr/local/
sudo reboot

2. Install NPM & Git

After the Pi has booted up again, connect to it again via SSH and install NPM and Git by putting in the following commands one by one:

1
2
3
sudo apt install npm

sudo apt install git

go back to the home folder by typing cd

3. Install the latest Magic Mirror repo and a lot of other stuff

1
git clone https://github.com/MichMich/MagicMirror

Go into the magic mirror folder and install Magic Mirror. This step will take a long time, be prepared to wait for at least 15-20 minutes. Just be patient!

1
2
3
cd MagicMirror

sudo npm install

Next you have to install a browser. The browser that’s recommended is called Midori. Type in the following command:

1
sudo apt-get install midori

Installing the Midori browser will take some time as well, so just sit back and see what’s happening on Reddit or something!

Next you have to set up AutoLogin on the raspberry pi. If you didn’t the pi would stop booting up until you’d type in a password.

1
sudo raspi-config

Go to Boot Options, then B1 Desktop/CLI and B2 Console Autologin and enable it.

Now Install xinit, a program that allows you to manually start a display server:

1
sudo apt-get install xinit

Install Xorg, which is a display server:

1
sudo apt install xorg

Now Install matchbox, a window manager for Linux:

1
sudo apt install matchbox

Since you’re making a Magic Mirror, you don’t want the cursor to be visible. To hide it, install Unclutter:

1
sudo apt install unclutter

Now you’re nearing the end. Make two script files, to autostart the Magic Mirror on boot.

First make a script called mmstart.sh. This script will start the MagicMirror platform as well as xserver/midori on startup

1
sudo vim mmstart.sh

Put the following code into the file, and save it:

1
2
3
4
5
#!/bin/bash
cd ~/MagicMirror
node serveronly &
sleep 30
sudo xinit /home/pi/midori_start.sh

Now make a script called start_midori.sh. This script will start the xserver display server and the midori browser.

1
sudo vim midori_start.sh

Put the following into the file and save it:

1
2
3
4
5
6
7
#!/bin/sh
unclutter &
xset -dpms # disable DPMS (Energy Star) features.
xset s off # disable screen saver
xset s noblank # don’t blank the video device
matchbox-window-manager &
midori -e Fullscreen -a http://localhost:8080

Finally, make both scripts you just created executable

1
2
$ sudo chmod a+x mmstart.sh
$ sudo chmod a+x midori_start.sh

Your Magic Mirror should be ready to go by now. But, there are quirks that make it more difficult to run MM on a Pi Zero.

Someone suggested running the npm install command again inside the MagicMirror folder, so try that if you can’t get it working.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *