Interactive Smart Mirror (Intel IoT)

by AmolDisale in Circuits > Electronics

4311 Views, 29 Favorites, 0 Comments

Interactive Smart Mirror (Intel IoT)

IMG_20160522_130632.jpg

This project is about how to make your mirror smart. We will add sensors and use api’s to make the mirror smart. The basic idea is to make the light near mirror automatically controlled depending upon the presence of user (using PIR sensor) and light conditions (using LDR based Light Sensor) and then to display the current weather conditions of the city (on LCD). Also a touch sensor is added so that you can see weather forecast. Using touch sensor you can add feature’s such as Social Media Notifier which will notify you about your latest gmail mail, Facebook & Twitter notification (This feature is not present yet but we will add this feature soon).

Components Required

Components.jpg
Components2.jpg
grove i2c rgb LCD.PNG
grove IR reflector.PNG
Grove IR sensor.PNG
Grove Ldr.PNG
Grove led Socket.PNG
grove touch.jpg
  • Intel Edison
  • Intel Edison Arduino Breakout Kit
  • Grove Base Shield
  • Grove 16X2 LCD RGB Backlit
  • Grove PIR Sensor
  • Grove Light Sensor
  • Grove Touch Sensor
  • Relay
  • Power Adapter
  • Two way Mirror
  • Wood Block to hold the Mirror
  • Black Colored Cardboard Paper

{Note: For Demonstration purpose we are going to use Grove IR sensor instead of PIR Sensor and Grove Blue LED instead of Relay}

Basics and Connections

IMG_20160522_132238.jpg

We are going to use Node.js Language for Programming Intel Edison. This is our first time coding with Node.js so bear us if the code is not efficient.

Why Node.js?

  • Node.js is a very powerful JavaScript-based framework/platform built on Google Chrome's JavaScript V8 Engine.
  • It is used to develop I/O intensive web applications, single-page applications, and other web applications. Node.js is open source, completely free, and used by thousands of developers around the world.
  • Node is all about non-blocking, asynchronous architecture. This means any activity taking a long time to finish, such as file access, network communication, and database operations, are requested and put aside until the results are ready and returned via a callback function.
  • Instead of asking to read a file and waiting for the operating system to come back with a file handler or buffer, the callback function is invoked when the operation is completed, freeing the server to handle additional requests.
  • When discussing Node.js, one thing that definitely should not be omitted is built-in support for package management using the NPM tool that comes by default with every Node.js installation. A full list of packaged modules can be found on the NPM website https://npmjs.org/.
  • Being single-threaded means that Node.js programs can only do one thing at a time, so it is important to understand how to properly work with the event loop in order to take full advantage of the platform and avoid common pitfalls.

For accessing Weather data of any place, we need to have an account on: https://www.wunderground.com/weather/api

First of all install Yocto Linux in Intel Edison

For more information visit:

https://software.intel.com/en-us/iot/hardware/edis...

Install Intel Edison drivers and Latest Intel XDK IoT Edition IDE for programming Intel Edison using Node.js

For Getting Started with Intel Edison visit:

https://software.intel.com/en-us/iot/library/edis...

Connections:

  • Connect Intel Edison on the Arduino Breakout Kit and then on top of it in Arduino style headers insert Grove Base Shield
  • Grove Touch Sensor Connected to Pin D7 of Grove Base Shield
  • Grove Blue LED Connected to Pin D8 of Grove Base Shield
  • Grove Light Sensor Connected to Pin A0 of Grove Base Shield
  • Grove IR Sensor Connected to Pin D5 of Grove Base Shield
  • Grove 16x2 LCD RGB Backlit Connected to I2C of Grove Base Shield

Weather Accessing From Weather Underground

Wunderground.JPG

It’s very easy to get current weather conditions and weather forecast of any place using wunderground api. If you have opened your account of wunderground get an API key which is needed to get weather data. API requests are made over HTTP. Data features return JSON or XML. We will usen JSON format.

So if you want suppose current weather condition of City:Mumbai in Country: India

Then you have to make following HTTP API request:

http://api.wunderground.com/api/Your_API_Key/condi...

If you want forecast of the above city:

http://api.wunderground.com/api/Your_API_Key/forec...

Multiple API features can be combined into a single HTTP request. This is an easy way to economize your requests.

http://api.wunderground.com/api/ Your_API_Key/geolookup/conditions/forecast/q/India/Mumbai.json

For more information visit:

https://www.wunderground.com/weather/api/d/docs?d=...

Now since we are using Node.js the task is very much simplified since we are going to use npm module built specifically to call the above API and get JSON data from it. We are going to use wunderground-api-client npm module. To install it just specify it inside package.json under dependencies it will get automatically installed on Intel Edison.

The attached node.js file contains code to extract temperature data from Wunderground API. But you can make changes to it and extract a lot of other informations also like humidity, pressure, wind speed and a huge amount of other data as required by you.

Sensors and Actuators Interfacing With Code

IMG_20160522_130801.jpg
IMG_20160522_130618.jpg
IMG_20160522_132626.jpg

We read IR sensor (PIR sensor incase if you have it) sensor value if it's high then we read Light Sensor's value and if it's low below a threshold we switch on Blue LED (Relay incase if you have it to switch on the Light).

For weather conditions and forecast we are reading it after every five minutes and retrieve the data like temperature. humidity, etc. from the JSON response using JSON.parse. We display current weather condition on the LCD when the user is near to the Mirror which is checked using IR Sensor (PIR sensor incase if you have it).

If you click on the touch sensor then it will display the weather forecast of the next day on the LCD.

Downloads