Software for a smart mirror that informs the user of basic weather and calendar events, maintained with a PIR motion sensor that detects movement and maintains monitor display.
Table of Contents
- Running Software
- Hardware Set Up
- Customize Data
- Google Calendar
Smart Mirror Dashboard
Run in terminal:
cd [to the location you want to keep it]
git clone https://github.com/n3a9/smart-mirror.git
Go to localhost:1337 in a browser.
Motion Sensor Monitor Control
detect_motion.py to check that your motion sensor is properly connected and working.
monitor_control.py in the same directory as
monitor_off.sh, which will turn off the monitor after 10 seconds of no motion, and turn on the monitor upon new movement.
Hardware Set Up
Things you need:
- Raspberry Pi with an OS, like here
- An old monitor from which the casing can be removed
Motion Sensor Connection
Connect VCC (power - shown in pictures with black wire) to pinout 2 or 4 for 5V (3.3V will not work with sensor).
Connect OUT (output - shown in pictures with white wire) to pinout 7 for GPIO4 (where the code is looking for data).
Connect GND (ground - shown in pictures with grey wire) to pinout 6 to ground and connect the circuit.
This uses the OpenWeatherMap API found here.
You can change the units and location of the weather data that is being pulled.
In the function getWeather(), you will find
url: [long url to pull weather data].
To change Zip Code
Default location is Los Altos. Replace
Make sure not to add any spaces or underscores.
To change weather units
Default units is Fahrenheit.
For Kelvin, delete
For Celcius, replace
In the function
getNews(), you will find
url: [long url to pull news data].
To change source, change from
source=time to the source of your choice by removing time. In the news list, below the icons, is the parameter you should use to replace
time (Time was set as default).
In order to add Google Calendar, you have to create a client-id. To do this:
- Ensure the calendar you want to use with your smart mirror is publicly accessible.
- Go to https://console.developers.google.com/flows/enableapi?apiid=calendar and create a new project.
- Then click on Go to Credentials, then select Overview and then Credentials again until you reach this screen.
- Click on the second tab called OAuth consent screen.
- Select an email address, select a product name and then hit save.
- Then navigate to the original credentials tab, and select Create credentials -> OAuth client ID
- Select web application, then add
- It will then give you a pop-up, giving you your client-ID and client secret.
- Copy your client-ID.
- In the project directory, navigate to
- At the top of the file, replace
var CLIENT_ID = 'insert-client-id-here';with
var ClIENT_ID = '[YOURCLIENTID]'
- Run the project, and then authorize access to your public calendar.