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.
Run in terminal:
cd [to the location you want to keep it]
git clone https://github.com/n3a9/smart-mirror.git
cd smart-mirror
npm install
npm start
Go to localhost:1337 in a browser.
Inside py_scripts
, run detect_motion.py
to check that your motion sensor is properly connected and working.
Then run monitor_control.py
in the same directory as monitor_on.sh
and monitor_off.sh
, which will turn off the monitor after 10 seconds of no motion, and turn on the monitor upon new movement.
- Raspberry Pi with an OS, like here
- An old monitor from which the casing can be removed
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.
Navigate to smart-mirror/public/app/weather/weather.service.js
In the function getWeather(), you will find url: [long url to pull weather data]
.
Default location is Los Altos. Replace ?zip=94024,us
with ?zip=[yourzip]
.
Make sure not to add any spaces or underscores.
Default units is Fahrenheit.
For Kelvin, delete &units=imperial
.
For Celcius, replace &units=imperial
with &units=metric
.
News API allows for us to change the source of our news from this list.
Navigate to smart-mirror/public/app/news/news.service.js
.
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
http://localhost:8000
andhttp://localhost:1337
as Authorized Javascript origins, and select Create. - 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
smart-mirror/public/app/calendarAPI.js
- At the top of the file, replace
var CLIENT_ID = 'insert-client-id-here';
withvar ClIENT_ID = '[YOURCLIENTID]'
- Run the project, and then authorize access to your public calendar.
MIT