Why this mirror is better than the others available on the web.

  • Because it is cheaper and came from recycle elements. It costs me less than 100 €
  • Because if you know a bit of Python script and a bit of HTML/PHP, you can tune it easily.
  • Because you can control the power of the mirror and schedule the power on specific hours when you are here.

Drawbacks:

  • I didnot made any voice control system, because I didnot see any use for me and I didnot want to speak to my mirror (it is happening only for snowwhite :)
  • Since I don't use a real mirror, the reflexion is bit less good than a real mirror, but still ok.
  • Since I don't use a big screen inside the frame, the data cannot be set every in the frame, only the top.

 

 

Needed

 

Here, you will see how to create your own smart mirror. I have made it by recycling at maximum.

  • One old laptop screen (for free)

     

  • One photo frame (40€)

       

  • A running raspberry (30€)

    

  • Two way-mirror film (5€)

       

  • one HDMI to screen converter (25€)

  • (optionnal) schedule the power (10€)
    • arduino nano
    • relay reed
    • PCB board

       

Hardware

You need to remove completly the screen from the rest of the laptop. There is a common connector for theses laptop screen the LVDS.

Then connect the converter through the LVDS connector in the screen.

Then connect the HDMI to the raspberry.

On the plexiglass in the photoframe, you need to set the two way mirror. You will need to use a bit of water and be carefull about the durst.

Some help

When it is done, you can set the screen and the converter inside the frame. you can fix them with some glu or some screws.

 

Software

You have now a running system.

If you start the raspberry, you should see the screen starting inside the mirror and displaying the desktop after few minuts.

For the software, I am using a local webpage displayed in full screen.

Setting a webserver

Please refer to this page to setup nginx, php and a database.

 

Setting the webpage in fullscreen at each start of the system

  • Script

TODO

 

  • Cron scheduler

0 */3 * * * python3 /var/www/html/Smart-mirror/news.py
*/10 * * * * python3 /var/www/html/Smart-mirror/bahn.py
0 */3 * * * python3 /var/www/html/Smart-mirror/weather.py
0 */3 * * * python3 /var/www/html/Smart-mirror/stock.py
1 */1 * * * python3 /var/www/html/Smart-mirror/screen-control.py

 

Creating the website

For this part, I will let you check my github project.

You can download it and reuse it.

This is modular, so it is easy to adapt one module.

Each module consist of:

  • A python script scheduled cyclicly
  • A php file which is used to display the data properly.
  • Between them there is a database table.

 

Optionnal: Power supply

In order to avoid too much energy consumption (during the night or during the day when you work), there is a way to automatically start and stop the screen.

On the screen, there is normally a board for the buttons.

You can connect the reed relay to the power on button.

Then the relay to the arduino

Then the arduino ot the rapsberry.

 

Here is a example of the software on the arduino which control the relay and comunicate with the PI in serial.

#!/usr/bin/python3

import serial
import time
import sys

test= serial.Serial( port='/dev/ttyUSB0', timeout=0, xonxoff=False, rtscts=False, dsrdtr=False)

time.sleep(2)
test.write(sys.argv[1].encode('ascii'))
test.readline()
test.readline()
test.flush()
test.close()

time.sleep(3)

 

Here is a example of the python script for the raspberry which send command to the arduino:

import os
import requests
import urllib.request
import mysql.connector as mariadb
import re
import datetime
import time

print("screen update")

def toogleRelay():
print("toogle_display")
os.system("python3 /etc/my_relay.py 1_on")
os.system("python3 /etc/my_relay.py 1_off")
return

# 1.Database connexion
mariadb_connection = mariadb.connect(user='root', password='password', database='Smart-mirror')
cursor = mariadb_connection.cursor()active_hours = [[0, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23],
[0, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23],
[0, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23],
[0, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23],
[0, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23],
[0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
[0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]]

# 2. get current status
cursor.execute("SELECT data FROM parameters WHERE name = 'screen_state' ")
result=cursor.fetchone()

status = False
if("1" in result[0]):
status = True
print(status)

datetime.datetime.now().hour

# 3. proceed
if ( datetime.datetime.now().hour in active_hours[datetime.datetime.now().weekday()]): # active
if(status == False ):
toogleRelay()
status = True

else: # not active
if(status == True):
toogleRelay()
status = False