First of all, thank you all for being awesome and helping Michaels project become bigger then he probably ever imagined.
As some of you might know, due to a different type of processor, the MagicMirror2 currently does not work out of the box on Raspberry Pi 1s and 0s. However, after I had my Pi0 sitting in it’s box for a year or so, my girlfriend decided she wanted a Magic Mirror for her birthday, with only 5 days left, I decided I would accept the challenge.
In hindsight, I would have been better of with just buying some nice candles or whatever and promising her the mirror for another time, but hey, captain hindsight is a bitch
So my research started here on this forum, with the post from user @evos in this topic:
However when I did the steps he did I ended up more confused and angry then I was before. After all, I saw all the right words flying by on my monitor, sadly all with a big red ‘Error’ message in front of it. Keep in mind that when I started this project my only experience with Linux, Raspberries and command lines was fiddling around a bit when I first got my Pi0 delivered to my house.
What I started out with:
-Raspberry Pi Zero
-8GB micro SD card with SD adapter
-Edimax WIFI donle with the N150 chipset
-Mini HDMI to HDMI adapter
-Mini USB to USB adapter
-My phones charger
-A cheap VGA monitor I got from a thrift shop for about 8 euros.
-USB keyboard, USB mouse and HDMI monitor from my PC
So what did I do (trying my best here to remember every step I took, my documentation is horrible to be fair):
- Installing Jessie Lite.
Installing Jessie Lite is probably the easiest step, just download the Image from https://www.raspberrypi.org/downloads/raspbian/ and follow the instructions found here https://www.raspberrypi.org/documentation/installation/installing-images/README.md .
Note: Jessie Lite is a command line based version of Jessie. In my imagination this was better to run a Magic Mirror from since it was lighter to run for the Pi since it didn’t include any unwanted programs like Minecraft. If you would like to have a ‘visual desktop’ on your Pi however, install the normal Jessie version. You might run into problems however when you follow this ‘tutorial’. Seriously, like a Pi is going to run all my mods for Minecraft
Setting up a WIFI connection.
Although this might be common knowledge, I had to do some research to get my Pi accessible via SSH (we will talk about that later) to get the work done. Your first step will be to connect the Pi to the monitor and plug in your keyboard. When you power on your Pi a list of fancy words will appear and at some point you will be greeted with green letters and the ability to type, and so we will type like our lives depend on it!
The first thing you want to type is:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
This opens a document called ‘wpa_supplicant.conf’, basically the place where we can tell our Pi to connect to our WIFI. In this document we want to insert the following text:
Replace ‘Your_wifi_name’ with the name of your Wifi Network and replace ‘Your_wifi_password’ with your Wifi networks password. Make sure to match both the name and password exactly, including capital letters etc. Also keep the name/password surrounded with the "s, without these it won’t work. If you have multiple networks you want your Pi to be able to connect to, you can add the inserted text multiple times. I only tested it with 2 at the moment, and that seems to work just fine.
When you’re done editting the file, press crtl+x to close the file, it will ask you if you want to save the changes you made, accept this by pressing ‘y’ and finally press enter to go back to your command line. At this point you can shut down your Pi by typing ‘sudo shutdown’ and waiting a minute.
Connecting from the comfort of your desktop
When your Pi is shut down, you can plug your keyboard back into your pc, and plug the WIFI adapter into the Raspberry Pi. When you power up your Pi it will connect to your WIFI network if everything went alright.
So now what?
We want to connect and work on our Pi from our PC, so we need to connect to it via an ‘SSH connection’. To do this we need a few things:
-A program to start such a connection
-The IP adres of our Pi
Personally I used the program ‘Advanced IP Scanner’ to scan my network for connected devices, the Raspberry was listed here. Later I learned that the IP adres of the Pi is also mentioned in one of the last lines you see when you boot the Pi with a monitor hooked up, the choice is yours!
For establishing a SSH connection, I just a program called ‘Putty’. When you install it it is basically entering the IP adres of the Pi and press connect, you will now be greeted by the same command line as before.
NOTE: Here is where my fuzzy brain is coming in. I firmly believe that my Pi had SSH enabled by default, but when writing this tutorial I read that as of late SSH is disabled by default on new releases. For more information and how to enable SSH in your Pi check: https://www.raspberrypi.org/documentation/remote-access/ssh/ . It is recommended to check this before disconnecting your Pi from keyboard/monitor, just to safe you the hassle of cables.
If you’re still with me: You’re as awesome as awesomnes comes!
Now lets get on with the fun stuf!
The installation of Node.js
As far as I can tell Node.js is basically a ‘motor’ for most of the fancy scripts Michael and others have written for the Pi. In any case it makes things work, so we want it!
The way of installing mentioned in the other post worked fine for me, so again credits to user @evos !
sudo wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb
NOTE: Interesting to know is that starting a command with ‘sudo’ makes you run the command ‘as the big boss’, basically bypassing most of the permissions systems of the Pi. Whenever a command gives you slack for not having permission, try adding ‘sudo’ to it. This will become relevant later on
sudo apt-get install npm
and watch the magic happen, and it happened!
NOTE: In all seriousness, from what I’ve gathered NPM is a ‘program’ that helps you install scrips that are made by other people, like Michaels Magic Mirror.
Installing the Magic Mirror with magic.
As per @evos tutorial, we simple put the 3 following commands in our command line, one after each other:
git clone https://github.com/MichMich/MagicMirror
sudo npm install
NOTE: The ‘cd’ command is used to go to a certain location in your files. When you simply put ‘cd’ in the command line and press enter, you will be taken to the ‘root directory’ of your file system. In easy words: ‘cd’ brings you to the stem of the tree, ‘cd /home/pi’ will walk you from the stem to the ‘home’ branch and finally to the ‘pi’ branch of the tree. In windows terms ‘cd /this pc/c/program files’ would bring you from your desktop to your ‘program files’ folder.
Installing a browser.
Normally installing the Magic Mirror would be a piece of cake and the command will just install everything for you. However on a Pi1 or Pi0, only the ‘server’ side of Michaels program works, the ‘browser’ will not work. Therefore we will install our own browser and take matters into our own hands!
While @evos suggested that we use ‘Kweb’ as a browser, I literally couldn’t get the damn thing to work. After a few moments of intense crying, I decided to go with user @darkeagl105 s suggestion and go with the ‘Midori’ browser. Working this out was literally half the battle for me. Installing Midori is a piece of cake via the following command:
sudo apt-get install midori
Now you’re the proud owner of a browser on your Raspberry Pi! Cake all around!
NOTE: ‘apt-get’ is a way to handle programs in Linux. It is basically a way for your Pi to look in a ‘phone book’ for a specific name/program and where to download it from. The ‘install’ part is so your Pi knows what to actually do with the files, in this case Install them. Other uses of ‘apt-get’ are e.g. ‘apt-get purge’ and ‘apt-get remove’. Of course you have to ‘sudo’ those commands, cause only the big bosses can install and removes programs, right?
- Begone cursor, begone!
What is worse then a non-working Magic Mirror? A non-working Magic Mirror with a silly cursor in the middle of the screen. Trust me, it was a horrible sight.
Now here is where I am a bit in doubt. @evos tutorial tells us to install ‘unclutter’ via the command:
sudo apt-get install unclutter
and while I DID install this, I’m not sure if this is needed in the end. When I tried to run my Mirror with just Unclutter, the cursor still showed up. I ended up disabling the cursor further in the installation process, which worked like a charm.If I where to make a Mirror once again, I would probably just install Unclutter again, just to be sure. Maybe someone can tell us if this is needed in the comments.
Pfew, that was a lot, wasn’t it? Now grab a drink and tell me a tale of raspberries and pies for you.
When you install Jessie Lite that means there is no graphical interface AT ALL available to you. just letters, numbers and about a handful of colors is what you get. This is the world of the ‘terminal’ where all the command lines life and work. Let’s call this world the 1.5D dimension. Basically it has some horizontal and vertical lines (which would make it 2D right?!) but due to the lack of color and pictures of cats, we deduct it 0.5 points and call it the 1.5D Dimension.
Now the Magic Mirror lives in the 2D Dimension, the world where pictures are the norm. Where clouds live on the right side of the screen, funky calendar icons live on the left, and the ‘Fish of the day’ module lives everywhere.
So how do we get our 1.5D stuff to the 2D world? Simple, we call superheroes to smash the barrier and create a nice piece of 2D land for our Mirror to live. In this case ‘Xinit’ is our ‘barrier smasher’, he breaks through the dimensions and opens it up for ‘Matchbox’ to claim and create our little 2D land.
Now for the people who don’t like tales and just want info: We’re going to use Xinit and Matchbox to get our stuff out of the terminal and into visual stuff on our monitor.
DISCLAIMER: This is roughly how my brother explained it to me. He probably said a lot more correct stuff as he made his job of Linux wizardry, but this is what I got from it. In case you read this, sorry for butchering your info Gokkie
Installing superheroes Xinit and Matchbox
Installing Xinit was rather easy to be honest. Simply use the command:
sudo aptitude install xinit
After that it was time to install Matchbox via the following command:
sudo apt-get install matchbox
To be fair, calling these heroes was rather easy. If only Commissioner Gordon could ‘apt-get’ Batman, would save him a lot of time in the rain I imagine.
No more passwords, yay!
We want our Magic Mirror to start when we boot the Pi ofcourse, so we have to tell the Pi to do so.
First of all we got to log in automatically. So we type:
we go to Boot Options -> B1 Desktop/CLI -> B2 Console Autologin
From now on our Pi should log in automatically, while SSHing into the Pi would still require a password.
NOTE: It is always recommended to at least change the password of your Pi in the ‘raspi-config’ file, since all Pies ship with the same login/password.
Setting up boot scripts
I personally use 2 different scripts for booting my Pi. The first one tells the Magic Mirror to start, wait for a bit, and then go on with the second script. These could probably be combined, but I’m just glad it all works
Let’s create script number 1:
sudo nano /home/pi/start.sh
In this file we want the following text:
node serveronly &
sudo xinit /home/pi/startMidori.sh
So what does this script do? Go to the MagicMirror folder, start the server, wait for 45 seconds (this could probably be lowered to 30, but let’s keep it on the safe side shall we?) and finally start the Xinit process and start the next script. Now please mind that I started the Xinit process with a ‘sudo’. If I recall correctly this is not recommended to do, however, I fell into a pit of permission problems when I didn’t use the sudo, so there we go. Probably not the safest, but it works like a charm.
Now we make sure the script is ‘executable’ aka the Pi can run the script (thanks @bhepler !) with the following command:
chmod a+x /home/pi/start.sh
Now to make sure the Pi actually does something with this fancy script, we have to tell him/her that. The Pi has a nice ‘to-do list’ it checks everything it boots, so we can add something there, right?!
sudo nano /home/pi/.bashrc
And add the following to it at the very bottom of the page:
We are so close now, I can almost taste the Mirror. Probably best to stop licking it.
My second script is to tell Xinit and Matchbox what to do. We create it via:
sudo nano /home/pi/startMidori
In this file I added the following:
xset -dpms # disable DPMS (Energy Star) features.
xset s off # disable screen saver
xset s noblank # don’t blank the video device
midori -e Fullscreen -a http://localhost:8080
The ‘http://localhost:8080’ can be changed to any site you want, by default this is the place to find your Magic Mirror.
NOTE: In this last part we used ‘nano’ a lot in the commands, as far as I am aware this command is used to open files in a text editor!
(thanks to http://www.instructables.com/id/Raspberry-Pi-Digital-Signage-Exchange-Rate-Display/step13/Start-the-Midori-browser-in-full-screen-mode/ for this whole last part btw)
Almost there, just a few more minutes!
The last thing I had to figure out was rotating the screen for my monitor and setting the right resolution.
This was done in the /boot/config file:
sudo nano /boot/config.txt
and adding the following to the bottom:
Change the ‘framebuffer_width’ and ‘framebuffer_height’ to the resolution of your monitor. After some fiddling it worked for me when I but the actual width of the screen as ‘height’ and vice versa, since the monitor is turned ofc. The ‘display_rotate=1’ makes the screen rotate 90 degrees. below are your choices for rotating (thanks to Lanewinfield in this topic: https://www.raspberrypi.org/forums/viewtopic.php?f=108&t=120793)
display_rotate=1 90 degrees
display_rotate=2 180 degrees
display_rotate=3 270 degrees
display_rotate=0x10000 horizontal flip
display_rotate=0x20000 vertical flip
A few things to remember:
-When you edit a file, always ‘crtl+x’, ‘y’, ‘enter’ to quit and save the file
-I might have missed some things in this ‘guide’, since it was a 48 hr struggle for me and I hardly documented anything, but I’m pretty sure these are the base steps to get it all working.
-I am in NO WAY an expert on this stuff, just an obstinate dutch student
-After these steps you still need to actually configure your Magic Mirror, this can easily be done by following the ‘Readme’ on the Github: https://github.com/MichMich/MagicMirror
-Seriously, Michael Teeuw and this community are amazeballs!
For everyone who read this to the end, thanks. To everyone struggling with this project, good luck!
Sadly I have no photos yet to post, since I’m waiting on a couple of cables to arrive (Damn you dutch post office!), but it all working on multiple of the screens around my house!
Thanks and good luck,