This blog shows how to enable Smart Mirror using Raspberry Pi. It is used to convert your home/ room/ office work space/ commercial space into your personal assistant with the help of smart mirror that shows up your latest calendar events, weather forecast etc. It can be used as notice board with the help of a mirror.
Let’s dive into how to setup this up:
Components Required for this Project
- Raspberry Pi (Currently used version 2)
- SD Card
- Wi-Fi dongle
- Two-way Acrylic Mirror
Firstly, we need to setup basic installation for Raspberry Pi, you can refer to installation tutorials from https://www.raspberrypi.org/downloads/ /
Setting up the Raspberry PI
- Format the SD card with FAT32 as format and Copy the Noobs OS into that
- Connect Raspberry with HMDI Output monitor (LED/LCD TV or any monitor that takes HDMI input).
- Connect with the power and wait till Raspberry pi OS setup is completed and restart it.
Connecting with weather
Create an account with https://darksky.net/dev and get the API Key to call the weather API to get the weather info (Weather_api_token).
smartmirror.py is the python script which does the actual work of showing the events belonging to the signed up user.
Changes to the script
Replace the token in smartmirror.py script as follows:
Weather_api_token = ‘XXXXXXXXXXXXXXXXXXXXXXX’ #Replace with your token
Connecting with Google Calendar
Run the script “get_cal_events” available at /home/pi/Smartmirror the location.It will open the Browser and it prompts for Google account from which the calendar needs to be imported. Once the authentication is completed, the API key will be generated and stored locally. Please make sure you are connected to the internet while trying to execute this script. This script will update the events for every 20 minutes which can be modified.
It will create Image with weather, calendar, clock and run it.
Configuring Raspberry Pi
Open file “sudo nano /boot/config.txt”
Add the following code below
This will enable the rotation of the screen.
If the rotation needs to be disabled just change the value to zero like below.
Then reboot raspberry Pi using the following command
“sudo shutdown –r now”
These functionalities can be added in the future.
- Face recognition.
- Touch screen for viewing maps.
- Video playback.
- Control electrical components like lights, fans and others using voice commands.