Smart Mirror complete walkthrough

Required Equipment:

Step 1: Setting up the Pi


The Raspberry Pi came with instructions on getting it up and running but to install the Meteor Platform I used for creating the app I had to follow this guide. Most other smart mirror tutorials don’t use Meteor so don’t have this step.


You need this web browser because it is easy to get it set up in “kiosk” (full screen) mode. It’s also useful since it has a javascript console so that made it easy to add documents into the Mongo DB. The link above was the best way I could find to get it installed. Next I needed to get Chromium to launch in kiosk mode when the Raspberry Pi boots up (without the spaces, wordpress won’t let me post that string of text for some reason):


sudo nano / etc / xdg / lxsession /  LXDE-pi / autostart


Disable the screen saver by commenting out the following line:

#screensaver -no-splash

Then add the following line to the end of the file:

@xset s off @xset -dpms @xset s noblank / usr / bin / chromium --noerrdialogs --kiosk --incognito "http://localhost:3000"

To get rid of the mouse cursor:

 sudo apt-get install unclutter

Rotating the display:

 sudo nano / boot / config.txt

At the bottom of this file add:


Where X is: 0, 1, 2, 3 corresponding to no rotation, 90 degrees, 180 degrees, 270 degrees of rotation.

Step 2: The application

The code for my application was based on the code from github user lambtron. The biggest change I made was to add the random compliment at the bottom of the mirror. The javascript to do this:

if (Meteor.isClient){
   var ONE_MIN = 1 * 60 * 1000;
   var chooseRandom = function() {
   var compliments = Compliments.find().fetch();
   var randomComp = Random.choice(compliments);
   Session.set('currentComp', randomComp);
   compliment: function() {
      var c = Compliments.findOne(Session.get('currentComp'));
      return c.text;
Template.compliments.created = function() {
   this.handle = Meteor.setInterval(chooseRandom, ONE_MIN);
Template.compliments.destroyed = function() {

I’ve been running the app locally on the raspberry pi and just pointing the browser to localhost:3000. I can update the app via ssh when I am at home on my local wifi but I don’t seem to be able to ssh to the pi from anywhere else. I’ve also had problems adding content to the database from a command prompt. I can however attach a mouse and keyboard and update the database through a javascript console in the browser.

So far this has been working well but I have since updated the app to include an admin panel and I could move it to a digital ocean droplet for $5/month which would give me better access to the database.

Motion sensor

I purchased a motion sensor from Lee’s Electronics in Vancouver for ~$15.

Connecting the sensor to the Pi was simple enough with some female-to-female connectors. The three wires plug into Pin 2 (5V), Pin 6 (ground) and Pin 7 (GPIO 4). GPIO 4 is then monitored by the Pi to detect motion. I followed an online tutorial for creating a Python script to detect motion and turn on/off the monitor. I made a few modifications to the script for my own purposes:

import sys

import time

import RPi.GPIO as io

import subprocess


SHUTOFF_DELAY = 60 # seconds


def main():

io.setup(PIR_PIN, io.IN)

io.setup(LED_PIN, io.OUT)

turned_off = False

last_motion_time = time.time()

while True:

if io.input(PIR_PIN):

last_motion_time = time.time()


if turned_off:

turned_off = False



if not turned_off and time.time() > (last_motion_time + SHUTOFF_DELAY):

turned_off = True


if not turned_off and time.time() > (last_motion_time + 1):

io.output(LED_PIN, io.HIGH)


def turn_on():“sh /home/pi/mirror/”, shell=True)

def turn_off():“sh /home/pi/mirror/”, shell=True)

if __name__ == ‘__main__’: try: main() except KeyboardInterrupt:


SSH and a Monitor

I had been having problems setting up SSH on the Raspberrypi but then one day it started working. Sort of. I can ssh into the pi as long as I am at home on the same network. Trying from work or anywhere else and it times out. Oh well at least being able to get into the pi from my computer at home will allow me to update the app and reboot if needed. I also found a handy app that will let me ssh from my phone:

IMG_1665I also found a relatively cheap ($65) monitor from a local used computer part store called Free Geek.

IMG_1666Finally I also ordered the mirror online from Tap Plastics. I wasn’t able to find anywhere local that sold two-way mirrors. With the shipping and exchange rate the mirror turned out to be about $120. Once the mirror arrives I just need to build a frame.


Setting up the Pi

Over the last little while I have managed to get the Raspberry Pi setup and got Meteor installed and running. I moved the app over to the Pi and initially it ran but wasn’t updating the weather. I eventually realized that it was the Epiphany (Gnome) web browser that was the culprit. After a few failed attempts I was eventually able to get Chromium installed and viola the app worked perfectly. Using Chromium also solved another problem where I was unable to access the database from the console. Running meteor mongo just keeps giving me an error. At least with Chromium I can use the javascript console to edit the database.

I’ve also got the browser to autostart in kiosk mode with the localhost page but still need to get the meteor app to run automatically as well.

Mirror Website

I’ve managed to make a Meteor application that displays the current day, time, weather and a random compliment:

Screen Shot 2016-01-07 at 3.37.12 PMGetting the random compliment took the most time. I spent a lot of time trying to find out how to return a random document from the compliments collection I created. I found quite a few posts online but none seemed to work. I could return an object but it was not displaying the text of that object. In the end it was as simple as changing from find() to findOne().

Next I want to have it check the date and display custom messages such as “Happy Birthday”, “Happy Anniversary”, “Merry Christmas”, etc.

I also set up the Raspberry Pi this week. I want to see if I can get Meteor running on it. If so I can just have the application running locally on the Pi and point its browser to the localhost. I did find this walk-through online.  If not I can deploy it to Digital Ocean which may be the better choice in the end as I can update the database easily that way.

Raspberry Pi, Littlebits and Meteor

So I haven’t been teaching for the past few years due to lack of enrolment in continuing education (SD38 continuing ed has stopped offering all math and science based night school courses!) hence the lack of any new posts on this blog. Since I haven’t been teaching I started learning new skills, did some online Python tutorials and then got interested in Meteor. When I first started teaching full time in Powell River one of the classes I was given was Information Technology 11/12. Part of this was teaching basic HTML which I was comfortable with but the other part was Javascript which I wasn’t. It was a quick and steep learning curve. Since meteor is based on JS I thought it would be a good way to revive that forgotten skill set. So far it has been going well and I’ve even made a few apps.

Then for Christmas I was given a Rasperry Pi and some Littlebits. After looking through some possible projects I’ve decided to try and build a Magic Mirror. I can build the site using Meteor and it can run on the Pi and perhaps make use of some of the Littlebits to act as motion sensor to activate it.

This project should be a lot of fun and documenting it here will be a good excuse to revive this blog.


The first two weeks of class are over. So far the class seems pretty engaged with the content and are doing a few more labs/investigations than last year but still most of them tend to watch the videos in class rather than at home. (Note that one student with a Windows 8 tablet was unable to watch the embedded videos in the moodle pages but could watch them directly from youtube???).

A couple of students tried to do the internal resistance lab during the first week. When I asked them why they said because it seemed to be the hardest and they wanted to get it over with. They did not seem to understand the concepts so I encouraged them to view the videos first or start with the uniform motion lab.

Another student who has already completed physics 12 once jumped around the whole course. First asking questions about torque, then conservation of energy, conservation of momentum, and then finally projectile motion. At first I was concerned that he was unfocused but then I realized that this is why I designed the course this way. If he wants to start looking at torque on the first night so be it.

I still struggle with not lecturing. It just feels like I’m not teaching. A few students ask questions throughout the night but so far no one has taken my offers of tutorials on specific topics. Perhaps things will change next week after the first test.

Moodle Rubrics and Scales

This year I decided to adjust the weight I placed on lab reports. Last year it was graded out of 6 and this year I graded them out of 18. Both times I used the rubric grading in Moodle. Last year I scaled the grade down but this year I decided to just leave it at the full 18 total possible points. However I noticed that when I graded a sample lab report and gave it a grade of 6 out of 18 on the rubric it would show up as 6.67 for total score for that objective in the grade book. I still don’t understand why but it had to do with the grade setting for each lab activity. Since I wasn’t scaling things down I changed the grade to just 18. When I modified the scale so that it went from 0 – 18 and reset the grade setting to the lab scale things worked out again. The category total in the grade book also had to be set to use the scale.


  • adjust the scale in the grade book settings
  • adjust the category total to ensure it is using the scale
  • make sure that each lab activity is using the scale

Attempt Number 2

Tonight was the first class this semester. 16 registered students but only 14 showed up tonight. It was close, the class was canceled again earlier last week but a couple of last minute registrants saved the day.

Tonight I went over the course structure with the class and got pretty positive feedback. With such a small class size the school district is concerned about attrition. We need to retain as many students as possible to get funding for them. So the district administrator came to the class to emphasize that point and to check to see if there were any students worried about the format and wanting to drop out.

So far it seems like a good start.