Raspberry Pi MagicMirror

From LVL1
Revision as of 17:00, 22 February 2017 by Dpjohn02 (talk | contribs)
Jump to navigation Jump to search

Materials 1x USB Female to Female 1x MicroSD with adapter 1x Element 10 LCD 1x Element 10 power 1x custom wooden frame 1x document frame with glass (11"x8.5") 1x 12"x12" privacy mirror film 2x self tapping screw

Supplies Sandpaper (for fitting the glass) Adhesive (for adhering the glass to the frame)

Tools Screw driver with phillips head (to remove screws on Element 10 LCD case Powered drill 1/16" bit for pilot hole



Step 1 Gather your materials and select a work area, each work area should have a screw driver and drill

Step 2 Unpackage the glass from the document frame, discard frame (unless you want to keep it) With your wooden frame, fit the glass in and if necessary use sandpaper to make a perfect fit by sanding any edges that prevent it full sitting in the lip Set the glass aside and be careful not to break it. You may want to label it with your name

Step 3: Disassemble the LCD from the frame Remove 4 screws from the back of the frame then pry off the plastic casing. Remove 2 screws from the top of the LCD (where the green circuit board isn't), save the se 2 screws Remove 5 screws from the green circuit board to uncover 2 addition screws in brackets for the LCD identical to the top. Remove 2 screws from the plastic case and the LCD should now pop out. Add the 5 screws back to the circuit board connecting it to the LCD Remove the USB like device in the circuit board that says "CONNECT TO WUSB"

Step 4: Attach the LCD to the wood frame Pre drill pilot holes with the drill and small bit by placing the LCD tabs at the top of the frame (note 2 tabs are inaccessible due to the green circuit boards) The top of the frame with the 2 notched out areas we will call the top from this point forward With the 2 self tapping screws, screw these with a hand screw driver, angling slightly toward the top of the frame The LCD can now freely hang from the wood frame

Step 5: Connect your Pi to the LCD Move into the classroom for this step, take your laptop, LCD, frame, power supply and USB Cable Connect your Pi to the ethernet and a USB cord from the Pi to the LCD in the port that is labeled "CONNECT TO WUSB" Connect your Pi to a power source The Pi should now boot and you should see the Pi desktop You should see that the desktop is inverted and we need to login and change that in the next step

Step 6: Configuring the Pi You can connect with a keyboard and mouse directly to the Pi or you can connect from any other computer With the Pi powered on you should see the IP address at the top right of the stats on the desktop, note the IP address under the mispelled "Eithernet" that should say Ethernet On your desktop with a SSH client such as the MacOS built in Terminal (click on search and type in TERMINAL to load it) or PUTTY on Windows (ChromeOS you may want to Google) type the following to connect to the Pi ssh pi@[IP ADDRESS in noted in step 6.1) Type YES If prompted that you want to connect Password when prompted: magicmirror You are now connected to your Pi

This terminal window allows you to copy and paste commands from this tutorial

Common linux commands we will use cd XXXX: change directory XXXX where XXXX is the folder you want to mkdir XXXX make directory XXXX where XXXX is the folder you want to create cd .. change directory to one directory above

sudo XXXX super user do where XXXX is the command you want to run as a different user

sudo !! [read as sudo bang bang] saves you time by executing the previous command as sudo ls list ls -l list with details

nano the program that we'll use to edit text

to edit the mispelled ethernet on the main page, type nano ~/.conkyrc not that anything that starts with a # is commented and the computer doesn't do anything with that line, so you can always type notes to yourself Let's change the update interval from 2.0 seconds to 5.0 seconds and note how the display flashes with updates every 5 seconds instead of every 2 Once edited from 2.0 to 5.0 press CONTROL + O to save the file to Output An error should appear! We should have started this with sudo Type CONTROL + X to exit, you will be prompted to save the output, press N for No to discard changes now you can type either sudo nano ~/.conkyrc or the shortcut is sudo !! The editor should open, make the same changes and press CONTROL + O to output, you should see a confirmation, press ENTER Go back into the file and change the update_interval to 2.0 instead of 5.0 CONTROL + W is a search feature for "where is" type Eithernet (it is case sensitive) and press enter; correct this spelling to Ethernet Output your file, save and exit (CONTROL + O, enter, CONTROL + X) You should now be back at the terminal screen and our Pi should be updated correctly

Step 7: Displaying your first magic mirror To start the magic mirror program, change to the MagicMirror directory created for you already before arrival by typing To see where you are anytime, type pwd as in Print Working Directory type ls to see a listing of the files type ls -l to see a listing with details you should be in an area that lists common folders such as Music, Documents and you should see one named MagicMirror, enter that folder by typing cd MagicMirror Note: linux and the Raspberry Pi are case sensitive, so pay attention type ls to see a listing of the files type ls -l to see a listing with details To begin the MagicMirror program DISPLAY=:0 nohup npm start & Look at your display and in about 15 seconds your first screen should appear, but it is upside down in the frame! Let's fix that! We don't quite have enough ability to stop the Magic Mirror, so let's restart the Raspberry Pi by typing the following sudo shutdown -r now Read as "super user shutdown hyphen r now" with r being the restart option You will now lose connection to the Raspberry Pi, in about 1 minute, log back into the Pi by typing ssh pi@X.X.X.X from our first attempt at connecting to the Pi from Terminal or PUTTY, enter your password then return, type pwd to see the working directory where you are

Step 7: Rotating the screen

When logged back into the Pi, type the following to edit the monitor preferences

sudo nano /usr/share/X11/xorg.conf.d/60-pluggable.conf 

You will see the following Section "Device"   Identifier "displaylink device"   driver "fbdev"   Option "fbdev" "/dev/fb1"   Option "ShadowFB" "off" EndSection

Add the following before the 'EndSection' as a new line   Option "rotate" "UD" What you're doing here is telling the screen to rotate up down

It should now read as

Section "Device"   Identifier "displaylink device"   driver "fbdev"   Option "fbdev" "/dev/fb1"   Option "ShadowFB" "off"   Option "rotate" "UD" EndSection


Save the file by pressing CONTROL + O enter, then CONTROL + X Restart the Pi by typing sudo shutdown -r now

Step 8: Really starting the MagicMirror Now let's get started with the MagicMirror

Further Documentation can be found for your review after the class by visiting https://github.com/MichMich/MagicMirror

Change directories to the MagicMirror/config directory by typing cd MagicMirror To see the folders & files type ls Change directories to the config folder cd config To see the folders & files type ls The previous directions when we started said we needed to copy the config.js.sample to our own config.js file; to do this type cp config.js.sample config.js go back to the MagicMirror folder by typing cd .. now start the MagicMirror and you should see a correctly oriented time, date, etc. DISPLAY=:0 nohup npm start &

Step 9: Editing the display Let's display LVL1's upcoming events so you never miss another workshop like Arduino 101 or Raspberry Pi 101 Find a calendar you like, maybe your own, maybe an organization's. To find a calendar of your own or a public one like LVL1: In Google Calendar, click on the arrow to the right of LVL1 and select Calendar Settings Under Calendar Address, grab the ICAL link by right clicking and select copy link address Find the calendar module back in your Terminal window and opening up the config.js file we created by navigating to MagicMirror/Config cd MagicMirror cd Config and typing sudo nano config.js Use your arrow keys to scroll down until you find the area for module: 'calendar' Here you'll see an area called calendars with a URL as an attribute Edit the url: 'webcal://www.calendarlabs.com/templates.....' to the link you copied or the LVL1 one listed below; you can go to the end and press backspace or be in front of the text and deleted out everything inside of the two apostrophes so that it only says url: and the make it url: 'YOUR STUFF PASTED HERE KEEP THE APOSTROPHES'

Save, exit & restart the MagicMirror program CONTROL + O CONTROL + X DISPLAY=:0 nohup npm start &

Your magic mirror should now bring in this new calendar!

So what's next? That's up to you, see documentation here: https://github.com/MichMich/MagicMirror Modules & more info: https://magicmirror.builders/ and click on Modules at the top to see documentation

Show your skills: For this new calendar, instead of it saying US Holidays, make it say something more reflective of the calendar you selected to display For this new calendar instead of the relative time until the events, make it say the time by adding a new property to the calendar that changes it from the default of relative (IE: 2 days away) to 'absolute' Review some of the 3rd party items and install one to see how you can write your own or bring in someone else's module


Step X: Make and adhere your 2 way mirror to the frame

Homework Part 1: Autostarting the MagicMirror https://github.com/MichMich/MagicMirror/wiki/Auto-Starting-MagicMirror