Difference between revisions of "Raspberry Pi MagicMirror"

From LVL1
Jump to navigation Jump to search
m
 
(9 intermediate revisions by one other user not shown)
Line 21: Line 21:
  
  
= Directions for building =
+
= Directions =
  
== Step 1 ==
+
== Step 1: Gather materials & select work area==
 
* Gather your materials and select a work area, each work area should have a screw driver and drill
 
* Gather your materials and select a work area, each work area should have a screw driver and drill
  
== Step 2 ==
+
== Step 2: Unpack the frame==
 
* Unpackage the glass from the document frame, discard frame (unless you want to keep it)
 
* 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
 
* 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
Line 57: Line 57:
 
* 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)
 
* 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
 
type the following to connect to the Pi
ssh pi@[IP ADDRESS in noted in step 6.1)
+
 
 +
<code>ssh pi@[IP ADDRESS] </code>
 +
 
 
Example:
 
Example:
 +
 
<code>ssh 10.0.0.7</code>
 
<code>ssh 10.0.0.7</code>
 +
 
Type YES If prompted that you want to connect
 
Type YES If prompted that you want to connect
Password when prompted: magicmirror
+
 
 +
Password when prompted:  
 +
 
 +
<code>'''Password:''' magicmirror</code>
 +
 
 
You are now connected to your Pi
 
You are now connected to your Pi
  
Line 68: Line 76:
 
Common linux commands we will use
 
Common linux commands we will use
  
cd XXXX: change directory XXXX where XXXX is the folder you want to  
+
<code>cd XXXX</code>: 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
+
<code>mkdir XXXX</code> make directory XXXX where XXXX is the folder you want to create
cd .. change directory to one directory above
+
<code>cd ..</code> change directory to one directory above
  
sudo XXXX super user do where XXXX is the command you want to run as a different user
+
<code>sudo XXXX</code> super user do where XXXX is the command you want to run as a different user
  
 
<code>sudo !!</code> [read as sudo bang bang] saves you time by executing the previous command as sudo
 
<code>sudo !!</code> [read as sudo bang bang] saves you time by executing the previous command as sudo
 +
 
<code>ls list</code>
 
<code>ls list</code>
 +
 
<code>ls -l</code> list with details
 
<code>ls -l</code> list with details
  
'''nano''' the program that we'll use to edit text
+
<code>nano XXXX</code> '''nano''' the program that we'll use to edit text where XXXX is the name of the file to edit or create (if it doesn't exist)
 +
 
 +
=== Editing Conky, the information that is displayed on the Pi's desktop ===
 +
to edit the 'misspelled ethernet' on the main page, type
  
to edit the mispelled ethernet on the main page, type
 
 
<code>nano ~/.conkyrc </code>
 
<code>nano ~/.conkyrc </code>
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
+
 
 +
'''Note''' 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
 +
 
 +
<code>#The computer ignores this because it starts with a pound/hash tag sign</code>
 +
 
 
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
 
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
+
Once edited from 2.0 to 5.0 press <code>CONTROL + O</code> to save the file to '''O'''utput
Type CONTROL + X to exit, you will be prompted to save the output, press N for No to discard changes
+
 
 +
An error should appear!  We should have started this with <code>sudo</code>
 +
 
 +
Type <code>CONTROL + X</code> to exit, you will be prompted to save the output, press N for No to discard changes
 
now you can type either
 
now you can type either
sudo nano ~/.conkyrc  
+
 
 +
<code>sudo nano ~/.conkyrc </code>
 +
 
 
or the shortcut is
 
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
+
<code>sudo !!</code>
Go back into the file and change the update_interval to 2.0 instead of 5.0
+
 
 +
The editor should open, make the same changes and press <code>CONTROL + O</code> to output, you should see a confirmation, press ENTER
 +
Go back into the file and change the  
 +
 
 +
<code>update_interval</code> 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
 
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)
+
Output your file, save and exit (<code>CONTROL + O</code>, enter, <code>CONTROL + X</code>)
 
You should now be back at the terminal screen and our Pi should be updated correctly
 
You should now be back at the terminal screen and our Pi should be updated correctly
  
Line 100: Line 126:
 
To start the magic mirror program, change to the MagicMirror directory created for you already before arrival by typing
 
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
 
To see where you are anytime, type
pwd
+
 
 +
<code>pwd</code>
 +
 
 
as in Print Working Directory  
 
as in Print Working Directory  
 
type ls to see a listing of the files
 
type ls to see a listing of the files
 
type ls -l to see a listing with details
 
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
 
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
+
<code>cd MagicMirror</code>
type ls to see a listing of the files
+
 
type ls -l to see a listing with details
+
Note: linux and the '''text in Raspberry Pi is case sensitive''', so pay attention
 +
type the following to see a list of the files
 +
 
 +
<code>ls </code>
 +
 
 +
type the following to see a listing with details
 +
<code>ls -l</code>
 
To begin the MagicMirror program  
 
To begin the MagicMirror program  
DISPLAY=:0 nohup npm start &
+
<code>DISPLAY=:0 nohup npm start &</code>
 
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!
 
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
 
We don't quite have enough ability to stop the Magic Mirror, so let's restart the Raspberry Pi by typing the following
Line 116: Line 150:
 
Read as "super user shutdown hyphen r now" with r being the restart option
 
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
 
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  
+
<code>ssh pi@X.X.X.X </code>
 
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
 
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
  
Line 123: Line 157:
 
When logged back into the Pi, type the following to edit the monitor preferences
 
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 
+
<code>sudo nano /usr/share/X11/xorg.conf.d/60-pluggable.conf </code>
  
 
You will see the following
 
You will see the following
 +
<code>
 
Section "Device"
 
Section "Device"
 
  Identifier "displaylink device"
 
  Identifier "displaylink device"
Line 132: Line 167:
 
  Option "ShadowFB" "off"
 
  Option "ShadowFB" "off"
 
EndSection
 
EndSection
 +
</code>
 +
 +
Add the following before the '<code>EndSection</code>' as a new line
 +
 +
<code>  Option "rotate" "UD"</code>
  
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
 
What you're doing here is telling the screen to rotate up down
  
 
It should now read as  
 
It should now read as  
  
 +
<code>
 
Section "Device"
 
Section "Device"
 
  Identifier "displaylink device"
 
  Identifier "displaylink device"
Line 144: Line 183:
 
  Option "fbdev" "/dev/fb1"
 
  Option "fbdev" "/dev/fb1"
 
  Option "ShadowFB" "off"
 
  Option "ShadowFB" "off"
  Option "rotate" "UD"
+
  '''Option "rotate" "UD"'''
 
EndSection
 
EndSection
 +
</code>
  
 +
Save the file by pressing <code>CONTROL + O</code>, then <code>CONTROL + X</code>
 +
Restart the Pi by typing
  
Save the file by pressing CONTROL + O enter, then CONTROL + X
+
<code>sudo shutdown -r now</code>
Restart the Pi by typing
 
sudo shutdown -r now
 
  
Step 8: Really starting the MagicMirror
+
== Step 8: Really starting the MagicMirror ==
 
Now let's get started with the MagicMirror
 
Now let's get started with the MagicMirror
  
Line 159: Line 199:
  
 
Change directories to the MagicMirror/config directory by typing
 
Change directories to the MagicMirror/config directory by typing
cd MagicMirror
+
 
 +
<code>cd MagicMirror</code>
 +
 
 
To see the folders & files type
 
To see the folders & files type
ls
+
 
 +
<code>ls</code>
 +
 
 
Change directories to the config folder
 
Change directories to the config folder
cd config
+
 
 +
<code>cd config</code>
 +
 
 
To see the folders & files type
 
To see the folders & files type
ls
+
 
 +
<code>ls</code>
 +
 
 
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
 
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
+
 
 +
<code>cp config.js.sample config.js</code>
 +
 
 
go back to the MagicMirror folder by typing
 
go back to the MagicMirror folder by typing
cd ..
+
 
 +
<code>cd ..</code>
 
now start the MagicMirror and you should see a correctly oriented time, date, etc.
 
now start the MagicMirror and you should see a correctly oriented time, date, etc.
DISPLAY=:0 nohup npm start &
 
  
Step 9: Editing the display
+
<code>DISPLAY=:0 nohup npm start &</code>
 +
 
 +
== 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
 
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.
 
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
 
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
 +
<code>https://calendar.google.com/calendar/ical/1n5qvjga6i4t6lde35vq5dg8ds%40group.calendar.google.com/public/basic.ics</code>
 
Under Calendar Address, grab the ICAL link by right clicking and select copy link address
 
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
 
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
+
<code>cd MagicMirror
and typing
+
 
 +
cd config
 +
 
 
sudo nano config.js
 
sudo nano config.js
 +
</code>
 
Use your arrow keys to scroll down until you find the area for module: 'calendar'
 
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
 
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
+
Edit the <code>url: 'webcal://www.calendarlabs.com/templates.....'</code> 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: ''
 
url: ''
 
and the make it
 
and the make it
url: 'YOUR STUFF PASTED HERE KEEP THE APOSTROPHES'
+
<code>url: 'YOUR STUFF PASTED HERE KEEP THE APOSTROPHES'</code>
  
 
Save, exit & restart the MagicMirror program
 
Save, exit & restart the MagicMirror program
CONTROL + O
+
<code>CONTROL + O
 
CONTROL + X
 
CONTROL + X
 
DISPLAY=:0 nohup npm start &
 
DISPLAY=:0 nohup npm start &
 +
</code>
  
 
Your magic mirror should now bring in this new calendar!
 
Your magic mirror should now bring in this new calendar!
Line 209: Line 266:
  
  
Step X: Make and adhere your 2 way mirror to the frame
+
== Step X: Make and adhere your 2 way mirror to the frame ==
  
 
Homework Part 1: Autostarting the MagicMirror
 
Homework Part 1: Autostarting the MagicMirror
 
https://github.com/MichMich/MagicMirror/wiki/Auto-Starting-MagicMirror
 
https://github.com/MichMich/MagicMirror/wiki/Auto-Starting-MagicMirror
 +
 +
[[Category:HOWTO]]

Latest revision as of 19:55, 19 February 2019

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


Directions

Step 1: Gather materials & select work area

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

Step 2: Unpack the frame

  • 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]

Example:

ssh 10.0.0.7

Type YES If prompted that you want to connect

Password when prompted:

Password: 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 XXXX nano the program that we'll use to edit text where XXXX is the name of the file to edit or create (if it doesn't exist)

Editing Conky, the information that is displayed on the Pi's desktop

to edit the 'misspelled ethernet' on the main page, type

nano ~/.conkyrc

Note 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

#The computer ignores this because it starts with a pound/hash tag sign

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 text in Raspberry Pi is case sensitive, so pay attention type the following to see a list of the files

ls

type the following to see a listing with details ls -l 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, 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 https://calendar.google.com/calendar/ical/1n5qvjga6i4t6lde35vq5dg8ds%40group.calendar.google.com/public/basic.ics 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

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