Please read the release notes carefully since this update requires adjustments to your Raspberry Pi configuration!
Complete Setup Tutorial
What will follow this post will be a series of steps to go from taking a brand new raspberry Pi 3 out of the box to having MagicMirror² up and running. I will try to keep things in order but that’s no guarantee. I will however link each post back into this one in the correct order, so you’d be able to just click on the link and jump straight to that specific post.
The Raspberri Pi setup is as follows:
Note: I have no affiliation with the listed vendors. I list them because that’s where I got the parts from. You can buy them wherever you buy your daily dose of electronics.
- Raspberry Pi 3 - Model B - ARMv8 with 1GB of RAM (Adafruit)
- 5V/2.4A Power supply (Adafruit)
- 8GB Sandisk Ultra Class 10 MicroSDHC card (Amazon)
- ASUS ProArt PA248Q Monitor (Amazon)
- Belkin 6’ HDMI Cable (Amazon)
- Mini 2.4G Wireless Keyboard & Mouse Combo (eBay)
- The Raspberry Pi 3 needs a hefty power supply to run. You don’t need a 2.4Amp one, but I wouldn’t go below 2Amps.
- You want a high speed SD card. Since the entire OS runs off of it, get a fast one. eLunix.org has a comprehensive list of what’s tested and works. You can find the list here.
- Monitor and choice of cable is obviously up to you.
- I use a mini keyboard for any/all of my projects that require a temporary solution. Even those that need a permanent one. They’re smaller than a regular sized one. And this one in particular is also rather thin. And I like that they are wireless. it cuts down on the cords needed to be connected to the device itself. These ones have a miniature USB dongle. Again, personal choice.
- I will be running this wirelessly and will make a note of it again in the setup part.
- I will be using my Windows 10 system for the initial setup of the card containing the operating system. What you use is up to you, however keep in mind that any screen captures I take and any software I use during this process will be from a Windows 10 platform.
- DO NOT INSTALL MagicMirror² as the
rootuser! Always do it as the regular, non privileged
piuser and learn to use the
sudocommand instead. “But why?”, you ask, “… if it’s in my house, and on my network, and not on the internet.” That’s all fine, however we don’t control every possible module that others contribute and someone, or something, could expose your Raspberry Pi, or your entire network to the outside world. Just don’t do it.
- This entire tutorial is based on you having physical access to the Raspberry Pi. After all, you will need that to set it up, but even at the end, installing MagicMirror², it is assumed you are doing that directly on the Raspberry Pi, and not through a remote SSH login.
Section 1: Preparing the SD card with the operating system
Section 2: Booting up the Raspberry Pi and configuring it
Section 3: Configuring wireless networking
Section 4: Cleaning up and updating the operating system
Section 5: Installing MagicMirror² & Configuring Raspberry Pi for MagicMirror²
Section #: … beer?
Preparing the SD card
This may seem dumb but if not done properly, you may end up with a card showing you less available storage than it actually has on it. Specially if you are trying to redo it because you made a mistake and have to start over.
(I will leave the installing of these as an exercise to the user. I’m not going to cover that here.)
7-Zip: http://www.7-zip.org/ (because Window’s builtin Zip facility is extremely slow)
SD Card Formatter: https://www.sdcard.org/downloads/formatter_4/
Win32 Disk Imager: https://sourceforge.net/projects/win32diskimager/
Download the operating system from the Raspberry Pi Foundation web site:
As of this writing, the most recent version is Jessie, released May 27th, 2016. You want to pick the full Jessie image.
Once you’ve downloaded the file, find it in whatever location you saved it and right click on it. On the context menu, pick 7-zip -> Extract Here.
While the file is extracting, you can start preparing the SD card itself. Pop it into your reader and open SDFormatter. Make sure the drive letter is the correct one. The
Volume Labeldoesn’t matter since it will get overwritten anyway. (In the screen capture, you can see the Size at 60MB. That’s because I had previously used this card on a Raspberry Pi, and since Windows can’t read that partition, it only lists 60MB. In order to fix that, you must perform the following steps!)
Click on Option and select
FULL (erase)as the FORMAT TYPE
Under FORMAT SIZE ADJUSTMENT, pick
Next click on the
Formatbutton and wait a few seconds. You may get an error about something being unsupported, that’s fine, you can ignore it. If all went well, at the end of the format, the screen will look like this:
Notice the Size, it should list the approximate size of the card, in this case it’s an 8GB card, so that number is correct.)
Now it’s time to write the operating system image onto the card. It should be done extracting by now and you should have an
.imgfile now. For the May 27th release, the file name is
2016-05-27-raspbian-jessie.img. For this step, you’re going to use the Win32 Disk Imager software. It must be run as the Administrator user, otherwise it will fail.
Click on Start, find the program in your menu, right-click on the name of it and select Run as Administrator. On my Windows 10 system, the menu looks like this:
When the program launches, click on the tiny folder icon to the right of the empty field, then browse to where your Raspbian Jessie image is located and select it. Again, verify the drive letter to the right of that! While the program will only pick external drives, if you happen to have something else in your reader, it will happily list it and possibly write to it if you don’t check that.
Once you’ve checked the correct drive, click on Write and wait for it to finish.
Once completed, Eject the card. I know that sounds silly, but I know way too many people who don’t know to Eject any cards or USB thumbdrives.They simply yank them out. There’s only a small number of brands on the market that will be fine if you yank them out, however the majority should be ejected first. That will signal any latent process to finish writing to the card or drive before unmounting it from the operating system. You are now ready to insert the card into your Raspberry Pi and boot it up for the first time.
Booting up the Raspberry Pi and configuring it
Now that we have the operating system on the card, we’re ready to boot up the Raspberry Pi (rpi). Put the card into the slot on the bottom of the rpi, plug in your monitor cable, turn the monitor on. Whether you are using a wired or wireless keyboard and mouse, make sure those are plugged in, then plug in power to the rpi itself.
The first boot up takes a bit longer than usual because it’s reconfiguring itself and setting all the defaults. If all went well, it should boot straight into the graphical interface. I apologize but I forgot to take a screen capture of this, but in the upper menu, click on the Terminal icon. It looks like a black monitor. This opens up a black terminal window, logged in as the
We are now going to run through the basic configuration of the rpi itself. This will result in a rather long post with lost of screen captures. You’ve been warned.
In the terminal window, type in
sudo raspi-configand hit return/enter. This will launch the Raspberry Pi Software Configuration Tool. (Navigation is done with the
arrow keys, the
TABkey allows you to jump from the selection menu to the buttons on the bottom, and the
space baris used to select or un-select menu items.)
The first item,
Expand Filesystemis already highlighted for you, so just hit enter/return on that. This will instruct the rpi to resize the partition to use the full size of the card.
You do not need to immediately reboot, so let’s move on.
Now we’re going to configure the
Internationalisation Options. This will configure your rpi to use the correct language, timezone, and others. Select that option (5) and hit enter/return.
Select the first option,
Now scroll to your preferred language using the up/down arrow keys. In my case, I’ll be using
US Englishas opposed to the default
GB English. Press your space bar to select your preferred language, and don’t forget to un-select the default. one. And I specifically picked the
UTFversion because it supports any Unicode character.
ISO-8859-1only supports the first 256 characters.
Once you complete that step, you’re back at the main menu. Select the
Internationalisation Optionsagain, and go to the second option,
Start by picking your region, then the respective timezone that you’re in. In my case, I’m in the
US, living in the
Once again, when you finish that, it takes you back to the main menu. Get back to the
Internationalisation Optionsand pick the third option,
Change Keyboard Layout(I3). The default is a standard UK, full size keyboard. If that’s what you’re using, then you don’t need to do this. However, it’s still worth looking at in case you do happen to have a different keyboard. I wanted to change mine to a US keyboard instead.
By default the
Generic 105-key (Intl) PCversion is selected. For most cases, that’s fine, just hit enter/return on that and it will take you to the layout option. Note the default UK settings:
Since I wanted a US layout, I selected
On the next screens, I picked the
English (US)for the country, again
English (US)for the layout,
The default for the keyboard layout, and
No compose key
At the end of this, it will ask you what you want the
CTRL-ALT-Backspacecombination to do. Normally it does nothing, but it can be configured so that if you hit that combination, it instantly kills the X-Server (and depending on the OS setup, will restart it fresh.) This was a more applicable when X11 was still in its infancy and things crashed a lot. Over the years, things became more stable, threads started getting removed from the main process, so applications could be killed and restarted without needing to completely kill the X-Server itself. However, it’s still around today. I have yet to have the X-Server on my rpi crash on me, ever. And if things really get completely bogged down, I just restart it remotely. Specially since this isn’t going to have a keyboard on it, there’s no sense in configuring this option, so I left it as
Ok, one more time, go back into
Internationalisation Optionsand pick the last item,
Change Wi-fi Country(I4). This will set the correct channel frequencies available. In the US, channels 1 through 11 are common. Channels 12 and 13 are allowed, but for low power only, and channel 14 is forbidden. For the rest of the world, channels 12-13 are not restricted. And for those in Japan, well aren’t you guys special … you get to use channel 14 as well (only specific protocols.)
Scroll down to
Advanced Optionsand select it. Pick the second option,
Hostname(A2). Here you will give your rpi a name. By default it’s
raspberrypibut why be like the rest of the world? You can change that.
Make sure you read the warning that pops up, then set the name to whatever you want. For example, I changed mine to
magicpi… after all, it will be running MagicMiror! (the screen shot shows the default setting)
Once back at the main screen, pick
Advanced optionsagain and scroll down to
SSH(A4). I like having the SSH server running because it allows me to connect to the rpi from anywhere on my network using a terminal program. So I don’t need to have a keyboard and mouse connected to the rpi itself, I can log into it using a different machine. But if you don’t need/want this, you can turn off/on the
SSHserver. In this case, I wanted mine turned on
Optional Camera Step
Are you using a Raspberry Pi specific camera? If so, you need to enable the rpi to work with it. Scroll down to option 6,
Enable Cameraand turn it on.
Done! When you’re back at the main screen after the last step, press the
TABkey and highlight
Finishat the bottom and hit return/enter. It will ask if you want to restart to which you will say
Tired of the mile long posts? Well, here’s a short one. As I noted earlier, I will be running my rpi wirelessly. If you are physically connecting it to your network using a cable, you can skip this post.
Once your rpi reboots and you’re back at the graphical desktop, launch the Terminal program (it’s a black monitor icon on the menu bar at the top.) Edit the
wpa_supplicant.conffile to add your network information
At the bottom of the contents, add your network information. Note the quotation marks as this is specially important if you have a space in your wireless network name. Same for the password part. When you’re done editing, press
CTRL-Xto exit, saying
Y(es)to saving the changes.
Time to reboot and make sure the rpi comes up and successfully connects to your wireless network.
If all went well, when the rpi reboots and comes back to the graphical desktop, in the upper right corner you should see a familiar blue WiFi icon.
And if you want to make double sure that it connected, you can open a Terminal window again, and type in
ifconfigand look for the
You’re looking for it to have a valid IP that belongs to your network. The specific private network that this rpi is connected to is in the 192.168.25.x range, so this validates that the rpi connected and received an IP from the DHCP server.
If you are physically connecting the rpi to a network hub or router, you need to look at the
eth0section at the top.
So what if it failed? Then you’d want to check a few things:
- Did you enter the corect information in the
wpa_supplicant.conffile above? Go back and check again.
- Is your wireless router set to block unknown hosts? In a secure environment, it could be (mine is.) Make sure you allow it to connect and receive an IP from the router.
- Are you in range of the wireless router?
- Did you enter the corect information in the
Cleaning up and updating the operating system
Ready for some fun? Let’s clean up the rpi OS and remove some of the big packages and a few things that we won’t need. This is but a small list of apps, but they are by far the biggest ones aside from the X-server itself.
First, let’s look at the current state of the storage:
dfcommand will show you storage across the entire file system (or it can be restricted with specific options.) The
-koption shows the values in 1K block format, while the
-hoption refers to the
human readableoption, which prints the sizes in powers of 1024. So we can see the
/dev/root/file system is at 48% full. That’s just the default Jessie installation!
Now, for all intents and purposes, this is just fine. It still has over 50% of the file system free and if you aren’t doing anything else with it, this is fine, you can leave it alone. However, I run all of my systems lean, meaning I will remove all (or most) of the stuff I won’t be using for the specific application. And in this case, I only removed the big space hogs that I know I will never use. There are a lot of packages that you could remove, since MM does not need them, but I didn’t care to do that … yet. So let’s move on.
Remove unnecessary software packages. I started with the stuff I know I won’t be using and the big stuff!
idle3 java-common libreoffice minecraft-pi scratch nuscratch penguinspuzzle python-minecraftpi python3-minecraftpi smartsim sonic-pi wolfram-engine
The command I used to remove all of them is:
sudo apt-get remove --purge idle3 java-common libreoffice* minecraft-pi scratch nuscratch penguinspuzzle python-minecraftpi python3-minecraftpi smartsim sonic-pi wolfram-engine
libreofficeI added a star at the end, making it
libreoffice*. This is because there’s a single
libreofficepackage, as well as several
libreoffice-*packages, and if you don’t add the star, it will only remove the one, while leaving all the rest.
When you run that, it will collect everything that needs removing and present you with a
[Y/n]question. Notice the amount of space that’s about to be reclaimed:
You’re reading that right, a whopping 1,112MB, or 1.1GB worth of space. Let that run and remove all those packages.
Once completed, we’ll also remove those that aren’t needed anymore:
sudo apt-get autoremove
It will present you with a list of packages that aren’t used anymore (since you just removed all those other ones above). Again, say
Y(es)to the question:
Now, for comparison, let’s look at the storage usage again:
Look at that, we went from 48% full, down to 30%, or from 3.3GB down to 2.1GB used. That’s a lot of space reclaimed!
Moving on. It’s time to run an update/upgrade on the system packages. You do that by entering the following commands:
sudo apt-get update
sudo apt-get upgrade
Or if you want to do them both together:
sudo apt-get update ; sudo apt-get upgrade
First the update:
Followed by the upgrade:
So why two separate commands? The
updatecommand will refresh the mirror list and available packages from the distribution mirrors. This sets up the next command,
upgrade, with the necessary files to compare against. Then the
upgradecommand will compare all the packages that are currently installed with the mirror lists and show you all the ones that need to be upgraded. You did say
Y(es)to that, right?
The last thing we need to do is make sure the firmware on the rpi is current. Performing a
sudo apt-get upgradedoes not always trigger this (in fact, I have yet to see it do that), so we’ll do it manually. The command for that is:
Note that it requires a reboot once that’s completed. A
sudo rebootwill get that done for you.
Now let’s look at the storage usage once more:
That’s not too shabby at all. 2.3GB out of 7.2GB used … I’m happy with that.
You are now ready to start installing MagicMirror²!
Thanks to @MichMich and his outstanding installation script, installing MagicMirror² is pretty straight forward.
After you’ve configured and updated your Raspberry Pi and rebooted, launch a Terminal window again and type in
bash -c "$(curl -sL https://raw.githubusercontent.com/MichMich/MagicMirror/master/installers/raspberry.sh)"
This will start the installation process for you:
A few configurations still need to be done on the Raspberry Pi, specific for MagicMirror². Let’s start with rotating the display vertically. For this, you’ll need to edit one of the boot configurations. (Please note: If you plan on running MagicMirror² as a landscape (or wide) display, you do not need to do this.)
sudo nano /boot/config.txtand add the following to the file. Where you add it doesn’t really matter:
# Rotate display vertically display_rotate=1
CTRL-Xwhen you’re done, and say
Y(es)to saving the changes.
Let’s disable the screen saver and screen blanking as well. This needs to be done in two places. First in the autostart configuration:
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
And add the following to the bottom of the file:
@xset s noblank @xset s off @xset -dpms
Next in the X-windows manager configuration:
sudo nano /etc/lightdm/lightdm.conf
Scroll down to the
[SeatDefaults]section and look for the
xserver-commandline below that. Change the line to look like this:
xserver-command=X -s 0 -dpms(so you’re removing the # on the front, and adding the missing bits at the end.) Again, hit
Y(es)to saving the file.
A Raspberry Pi is configured to automatically shutdown parts of the hardware that aren’t actively in use. This includes the WiFi driver. This will cause MagicMiror² to occasionally fail to fetch updates for things like the newsfeed, weather, and others. You can disable the power saving feature for the WiFi from the interfaces configuration file:
sudo nano /etc/network/interfaces
wlan0section and add
wireless-power offbelow it:
Once you’re done with that, reboot the rpi one more time with
sudo rebootand when it comes back up again, open a Terminal window and type in
iwconfigand you should see that the Power Management is now off:
At this point you have completed the basic install for MagicMirror². The next step is to create a valid configuration file for it so you can test it out. You can do that by going into the MagicMirror’s
pi@magicpi:~ $ cd MagicMirror/config pi@magicpi:~/MagicMirror/config $ cp config.js.sample config.js
You can now try to start MagicMirror².
pi@magicpi:~/MagicMirror/config $ cd $HOME/MagicMirror pi@magicpi:~/MagicMirror $ npm start
If everything went well, your screen should load up the MagicMirror² interface. The weather module will tell you that you don’t have a valid APPID, but once set, your screen should look like this: