Wiki/SmartRoom

From eLinux.org
Jump to: navigation, search

thumb‎ Embedded Linux Class by Mark A. Yoder


Team members: Mohit Sharma[B12006], Siddharth Gangal[B13232], Ankur Sardar[B13108], Pushpender[B13132]

Executive Summary

The goal of this project was to build a smart room that captures the happenings in and out the room and performs certain assigned functions accordingly. The first in the list is an automatic door lock system for the room. For this one there is be a camera overlooking the door. Whenever someone approaches and is in the pre-required range of the camera, it clicks a photo and sends it to the concerned owner who then can approve and then the door would automatically unlock. Second one covers the fact that if the door is left open for more than an assigned period, a message will be forwarded to the owner regarding the same.

Packaging

Components are cheap and easy to find online. Consider this Fritzing diagram for circuit diagrams.

Final project can be a small box, with external camera and control wires.

Installation Instructions

Give step by step instructions on how to install your project.

STEP 1 Install the WiFi adapter

STEP 2 First set the time (just to be sure)

/usr/bin/ntpdate -b -s -u pool.ntp.org

STEP 3 Install socket.io

cd /var/lib/cloud9 npm install socket.io

STEP 4 Install nodemailer

npm install -g nodemailer

This takes a few minutes, wait until installation is complete.

Fina step: Installing the Javascript and HTML code Find smart_home.js and index.html code on:

https://github.com/mohitsmr/CS404-Project.git

User Instructions

We encourage you to use the Cloud9 IDE as often as possible to program your BeagleBone. First read the previous part: Cloud 9 IDE on the BeagleBone Black.

With the Cloud9 IDE open, you can create a folder and file in your workspace. Follow these steps:

Right-click the cloud9 folder and choose New Folder from the shortcut menu. Name the new folder Projects. Right-click the Projects folder and choose New File from the shortcut menu. Name your file index.html. Repeat step number 3. and name your new file smarthome.js.

Creating your Web Server Your smarthom.js file is the last piece of the puzzle. First you have to load all the required modules and configure your BeagleBone Black’s pin. You also initialize a web server on port 8888. Then you establish the communication between server.js and index.html files using socket.io. the code is in this following link:

Launching your web server Launching your web server is easy. You simply save all two files. Click the green button “Run” in the Cloud9 IDE, and you should see a message in your output window that says “Server Running . . . “.

That’s it, your web server is up and running! Open a tab in your web browser, and type http://192.168.7.2:8888.

This web page only opens only if your computer is connected directly to the BeagleBone Black by USB. If that’s not the case, read the next section to see how to access the BeagleBone through a device connected in your workspace network.

Accessing your Web Server with another device To access your web page in any device inside your network, you need your BeagleBone Black’s Ethernet IP address. Open your terminal and type the following command: ifconfig

Now you can type your Ethernet IP address followed by the port number (example http://192.168.1.80:8888) in a web browser of any device. Now you can control any outputs remotely!

Highlights

1. To open or not to open? :

  Camera captures live video feed and sends it to the owner using Nodemailer who can now decide whether to open solenoid valve lock.

2. Security:

  If door is left open for long, or is keft open unauthorized, a message is sent to the owner with links to view the camera. 
  Now he may call his neighbours or in bad situations, the police.

There are hundreds of other applications we can add for further 'smartening' of a room.


Demonstration

Link 1: https://youtu.be/GccdcySIm4w Link 2: https://youtu.be/CfDhARbQEDI

Theory of Operation

Give a high level overview of the structure of your software.

1. MaxBotic Ultrasonic sensor

Link: http://beagleboard.org/support/BoneScript/Ultrasonic_Sensor/

Used this to ascertain the position of a door, and to whether it was open or not.

2. Relay ULN2003LV Low Power 3.3V

  http://www.mouser.com/new/Texas-Instruments/ti-uln2003lv/ 
  Used this to use beagleBone logic to drive a higher voltage and power hand crafted solenoid using external power source.

3. Solenoid

  Handcrafted a 8 Ohm solenoid to close or open door using digital logic.

4. Motion Software

   we need to install the “motion” app. Command line is as follows:
   sudo apt-get install motion

Now to configure the software to work the way we want to we have to change a few settings, Command line is as follows:


sudo nano /etc/motion/motion.conf


This will bring you into the settings of the “Motion” app, take some time to get to know your way around here as it will help in the future when you want to make personalized changes to the system.


Scroll through and turn Daemon from Off to On also turn webcam_localhost from Off to On


    • CTRL X will allow you to exit the settings, be sure to save.


One more setting must be changed before we can use the camera. Run the Command Line as follows:


sudo nano /etc/default/motion


Then change the value “start_motion_daemon=no” to “yes”. We are now ready to get started! Run the Command Line as Follows:


sudo service motion start


after a few seconds through your internet browser go to your Beaglebones IP address followed by :8081 ex.. 192.168.*.***:8081


5. Nodemailer To use the email service in beaglebone, first you need to set-up a gmail account, if you don't already have one. Next, install nodemailer. bone# npm install -g nodemailer

Then go to the main program, and edit your program, and add your own id password in that code to send an email 6. Servers To create a server in bone You have to install a Node.js package called socket.io.

7. TMux We have used TMux to run several programs parallely at a same time. we are using tmux to run multiple tasks. One js file forms a server for a camera feed(always running) and one is the door alert file with the utrasonic sensor checking if the door open state exceeds a particular set time. They interact with each other by calling each other.

Work Breakdown

We all worked collectively on the project, so we all have an idea of all the workings. Responsibility was divided as follows:

  • Processing of image, sending to user over a webpage using HTML, message to user and the model to demonstrate - Ankur and Mohit
  • Proximity Sensor for door open and close, circuits for relay, making a solenoid, sourcing components and wiring and code for sensors and actuators ready - Siddharth and Pushpendra

Future Work

We can include voice recognition features to control speed of fan, turning lights ON and OFF inside the room, have coffee automatically made in the morning and even include features for colorful ambient lighting, such as the Philips smart lighting systems that depend on mood we can see nowadays.

Conclusions

This was an interesting project to work with. We learned how to make and use servers, use the openCV library, operate motion and t-mux. In electronics, we use relays to power a solenoid using a beaglebone and used temperature sensors, switches, ultrasonic sensors and many more components.

We had a few unexpected snags along the way, and we dealt with them efficiently.

We got to learn a whole lot of new things working with BeagleBone and it was a great experience.




thumb‎ Embedded Linux Class by Mark A. Yoder