Friday, May 6, 2016

Final Notes

It's going to be my last notes for this course and to Professor Paul Schragger too :)

From the bottom of my heart, I would like to thank two persons. One, Professor Paul Schragger, for building a perfect experience of a complete self-learned practical curriculum to 'Internet Of Things' course and made me think, research, exhibit and expose my hidden strengths to the world out there with this blog writing. Two, my friend, Prashanth who helped me right from the selection of this course till the end of the final project and its great experience working with him.

It's like I started this course 'Internet Of Things' just a few days ago. But to reality, it completed Century of days by now. Finally, Hurray! I have successfully completed my Course work after a great effort leaving behind with mixed feeling. This feeling right now I have is unexpressed. At this late hour of the night, I just felt like putting my feelings towards IoT on this blog. It's immaterial for me the grades but the more important is I had a complete set of varied experience in this course which helped me to increase my overall personality both at technical and management skills that need to be present in a person to fight with the world out there.

I would like to recall all the things starting from the selection of course till the end.

It's the start of the second half of my first semester, I need to register to the courses for Spring 2016. I just checked all the available courses and this Course 'Internet Of Things' catches my eye as it included some electronic stuff. I love Electronics and fun playing with IC's, Resistors, Diodes, Circuits. Missed them. It's almost 3 years I even thought of those.
As it's my first time to hear about a course like this, gone through some basic research, collected information from friends regarding the course structure and professor. I would like to thanks Prashanth for encouraging me to take the subject. Initially, I hesitate to take as its hard to balance 3 tough courses. But I took a step and decided I should face it and the battle started with the course registration :)

Then comes the first day of the class. Don't even  know what's will happen in this course. But I was full of excitement that I am going to play with the circuits again :) . The professor named Paul Schragger, really a cool person gave a perfect kickstart of the IoT. It's excited to hear about the kits we are going to use in the coursework. One the Raspberry Pi, and the other Arduino NodeMCU with ESP8266. And the rest of the story you can figure out from my Blog.

This course was really awesome. It's not something the same boring examination patterned course. It's something different, more practical, more self-learning with the Prof. guidance. There are hundreds of things I have learned in this course and its hard to point out all.

I have never thought I would write a blog, never think of my strength in self-learning, research, or in documentation and more. This course helped me in realizing my strengths and weakness, helped me to shape myself both technical and management skills.

Apart from the course work,

1.Attended few sessions on Arduino conducted by Engineering department at Villanova.

2.Participated in Arduino Hackthon dated 4/1,  where we build a project, inspired from an experiment conducted in china. It's about the automatic control of the car which can prevent the car accidents. In this hackathon, we formed a group of 5 persons - me, Prashanth, Sandeep, Jorge, Charan and worked with the Arduino UNO. We built a working Rover which worked based on the control of the accelerometer and predicted the obstacles using the ultrasonic sensor. Also, worked on the MQTT communications of the commands to operate the rover. Plan of the Hackathon:
https://drive.google.com/drive/folders/0B-7OVLV2uzmLMVlnbmlpaWFyZlU
We divided the project into 3 modules, me and charan worked on Rover operation from Arduino:  https://www.sparkfun.com/datasheets/Robotics/Rover%205%20Introduction.pdf 
and then controlling the movement based on the Ultrasonic sensor.


3.Volunteered for the Arduino workshop dated 4/23, but this time playing the role of Teaching Assistant for the 23 Indian students who had attended the Arduino workshop conducted by the Villanova Engineering department. It's really a wonderful experience of playing the role of teacher. In this, I helped the students to understand the Arduino and showed the example programs like LED blink, servo motor operation, LCD display of the Arduino SparkFun kit:  https://www.sparkfun.com/products/12060

And here comes the final Phase of the Course, the Poster Presentation of the final projects. It's really great to see different ideas. Here is the last day Picture captured for memories :)


Finally, the overall experience with IoT was ExtraOrdinary. Signing off - Jyothi.

Wednesday, May 4, 2016

Complete Final Project Report- Smart Blinds

Smart Blinds - A Home Automation Project

Here comes the final documentation of my IoT Project, 'Smart Blinds' - a home automation project.

Introduction:

Internet of Things has been labeled as “the next Industrial Revolution” because of the way it changes the way people live, work, and businesses interact with the world. With the advancement in Technology, we can build our own secure and safe environment. This project ‘Smart Blinds’ that comes with the inspiration of the concept of ‘Green House’ which helps the plants to have a safe environment.


Abstract:
                 The project is about 'Smart Blinds'. The key point here is the opening and closing of the blinds made automatic and which depends on the intensity of the outside light. Also, can analyse the duration of opening and closing of blinds.In this project, I have built my own Home Automation Project for the safety of kids and pets at home when we are away from home. For this, I chose to automate the blinds operation based on the time of the day, temperature and intensity of light.

1.Project Report:

For my project 'Smart Blinds' which is like any other IoT project, I would like to provide a complete detail of the project with explaining all the specifications starting from the high-level overview which gives a picture of what's the project is all about and then down to low-level overview which gives all the minute details of the project so that anyone who will come across the post can do the project all on their own from the data and references I'm going to share about this project.

HighLevel Project Flow Representation


The above diagram shows a High-level idea of the project which is generic to all the 3 modules I have done in this project. Here, the user can manually control the blinds based on the temperature displayed on the Blynk application and then sends the message to the control Signal Processor, in my application Arduino acts as controller which sends signals to the servo motor to rotate the blinds either to open or close them based on the instructions it received and then the position of the blinds is again passed back to the control circuitry for future reference. This is a complete high-level design of the basic functionality in my project.

Project Requirements:

Hardware:

  1. Arduino esp8266
  2. Raspberry Pi 2
  3. BreadBoard
  4. Jumper wired
  5. Photo Resistor
  6. DHT11 sensor
  7. Servo motor
Software:
  1. Blynk app( auth token)
  2. Arduino IDE 
  3. Mosquitto installed in Pi
  4. Mosquitto configuration 
  5. NOde-Red
  6. External URL to connect to Wearther API
  7. Python working on platform 
Arduino Libraries:
  • SPI.h
  • BlynkSimpleEsp8266.h
  • Servo.h
  • ESP8266WiFi.h
  • PubSubClient.h
  • DHT.h
Python Libraries:
All code of my project will be available at this link:

IoT design methodology:

The complete design methodology is defined in a total of eight Specifications.
  1. Purpose and Requirements Specification
  2. Process Specification
  3. Domain Model Specification
  4. IoT Level Specification
Please follow the below link for these specifications of the project:
http://myiotblog.blogspot.com/2016/04/fundemental-parts-of-project.html

       5. Service Specification
       6. Functional View Specification
       7. Operational View Specification
       8. Device and Component Integration

Please follow the below link for these specifications of the project:
http://myiotblog.blogspot.com/2016/04/project-report.html

NOTE : Updated the links with more data than the one previously submitted as part of Assignments.

Architecture:

Blynk Service Integration:
Blynk Service

In this service operation, the user controls the operation of blinds using the Blynk App. Based on the commands from the Blynk application the NodeMCU controls the direction,speed and rotation of the servo motor which will either open or close the blinds. Once done, then this change in the blinds position is recorded and published to the topic 'BlindsPosition' through MQTT protocol to the MQTT server where the Pi acts as the MQTT broker. Simultaneously, a python program is running on Pi which subscribes to the 'BlindsPosition' topic and continuously checks for messages. If any message published to the topic it subscribes and streamed the data to the 'InitialState' Cloud Storage.
There in dashboards are created to constantly monitor the blinds position.



 Weather API Service Integration:
Weather API Service 

In this service operation, the controls of the operation of blinds made automatic which was based on the external climatic conditions. It's based on two factors. one the time of the day and other the temperature. The use case diagram for this as below.

First checks whether its day or night and then checks if the temperature is greater than the threshold.
Based on these conditions the operation of blinds made automatic. The external data is extracted from the open weather API which is secured as it required the authentication key. A python program is coded which is running on Raspberry Pi extracts data from weather API for every 1 minute. It streamed the data to the 'InitialState' Cloud Storage. Also, continuously checks the conditions and if the temperature exceeds the threshold then published to the topic the command 'close' to the topic through MQTT protocol to the MQTT server where the Pi acts as the MQTT broker. Simultaneously, a program is running on NodeMCU which subscribes to the topic and continuously checks for messages. Based on the message it sends the control signals to the motor and then publishes to topic 'BlindsPosition' through MQTT protocol the position of blinds.
There are dashboards also created to constantly monitor the external conditions.


External Climate Parameters Storage Data

2. Project Poster:


Smart Blinds - Final Poster

Results:

Output Results in the InitialState Streaming DashBoard for all the information

This dashboard above will show the line graph details of each of the measurements stored in the cloud. Also, it adds new tiles with the information of the last value of the blind(like 'Open' or 'Close') , Histogram results of blinds position and lastly the pie chart results of the blinds position.
Line Graphs for all the measurements saved in the cloud


Blinds Position data Saved in the cloud and can be extracted as CSV file format

External and Internal Temperature, Humidity readings stored in cloud



The above diagram depicts the UI in the BLYNK app from which the user is able to control the blinds operation. It has new features like a big closet. A User can even set the timer based on which the particular operation is performed. The user will have an option to view the current position, temperature and heatsink of device.

3. Demonstration:







4.Link to Software:

Blynk Software: It is used to interact and communicate with the Arduino to perform control actions so that user can remotely operate the blinds. It provides an interface as a mobile application where the user can give the inputs and can provide commands for the actions to be done. This one is secure as it provides a secure Auth Key for each and every project we created and with this access key only we can communicate securely.
1. We can track the position of the blinds using the display widget- 'Labeled Value'
2. Also, can continuously view the room temperature and the heat sink values which are displayed on the 'LCD display'.
3. Used the 'Menu' Widget to select the actions to either open or close of the blinds.
4. Provided the user with the option to preset the control of blinds at a particular time using the 'Timer' widget.


  1. Blynk Docs : http://docs.blynk.cc/
  2. Blynk Start Guide : http://docs.blynk.cc/#getting-started-getting-started-with-the-blynk-app
  3. Blynk Hardware Setup: http://docs.blynk.cc/#hardware-set-ups
  4. Labeled Value Display: http://docs.blynk.cc/#widgets-displays-labeled-value
  5. LCD Display Widget: http://docs.blynk.cc/#widgets-displays-lcd
  6. Menu Widget: http://docs.blynk.cc/#widgets-other-menu
  7. Timer Widget: http://docs.blynk.cc/#widgets-controllers-timer
Initial State:
http://blog.initialstate.com/category/arduino-2/


Raspberry Pi2:

NodeRed:


Arduino:

ServoMotor:

DHT11 Sensor:

Weather API:

5. Project Sites used in creating the project:
http://www.instructables.com/id/Arduino-controlled-automated-blinds-with-Web-UI/
https://www.hackster.io/cyborg-gibson-11/automated-blinds-by-cortana-7bfaff

6. Future Work and Project Enhancements:
  1. I would like to extend this further by providing SMS or EMAIL notification to the user which would be more helpful for continuous update and notification.
  2. I would like to further extend this work to the predict persons wish of blinds position based on the various factors (temperature, time of day).  
  3. Need to apply linear regression, decision tree using R programming for the predictions.
  4. Also, I would like to the monitor and analyze the health of the crops based on the different climate conditions like the wind, humidity, temperature and varied parameters which affect the plants growth.
  5. I would like to further extend it by handling all the blinds in the home by Integration.
  6. Monitoring the health of plants based on different climate conditions.

Thursday, April 28, 2016

Parts of Project Report

Smart Blinds- A Home Automation Project - Specifications-II

In my previous post, https://myiotblog.blogspot.com/2016/04/fundemental-parts-of-project.html
I have discussed the first four specifications of my 'Smart Blinds' IoT project.
In this post, I would like to discuss the remaining specifications of my IoT project.

5.Service Specification:

The fifth step in the IoT design methodology is to define the service specifications. Service Specifications define the services in the IoT system, service type, it's input/output, endpoint,schedules, preconditions and finally service effects.

There are two services in my project:
1.The Blynk service, which is used for change of modes of the blinds between open and close
2. A weather API service, for getting information about the temperature, luminosity etc., based on which the automation of the blinds controlled.

Blynk Service:

 In this service, the Blynk Application installed on the mobile phone from which the user is able to control the blinds operation. It is used to interact and communicate with the Arduino to perform control actions so that user can remotely operate the blinds. It provides an interface as a mobile application where the user can give the inputs and can provide commands for the actions to be done. This one is secure as it provides a secure Auth Key for each and every project we created and with this access key only we can communicate securely.

1. We can track the position of the blinds using the display widget- 'Labeled Value'
2. Also, can continuously view the room temperature and the heat sink values which are displayed on the 'LCD display'.
3. Used the 'Menu' Widget to select the actions to either open or close of the blinds.
4. Provided the user with the option to preset the control of blinds at a particular time using the 'Timer' widget.

The below diagram is the pictographic representation of the Blynk Service:



Weather API service:

 In this service, from the openweather API we can get information about the wind, humidity, and the temperature at our place using the python programming from Raspberry pi.
Based on which the operation of the blinds is automated. If the temperature is beyond the threshold then the blinds will be closed or else opened.

The below diagram is the pictographic representation of the Weather API Service:




Functional View Specification:

Goals:
1. To remotely access the control of blinds when we are away from home.
2. To automate the position of blinds based on the external climatic factors
3. To automate the position of blinds based on the internal room conditions.

Targeted Area:
Home and work area where it's needed to control the process remotely and automate the process to avoid any sort of risk to the kids, pets, and plants.

Modules:

The overall project is divided into three modules:
1. Remote control of the blinds by the user on his wish.
2. Automatic control of the blinds based on the information of the external climate from the openweather API.
3. Automatic control of the blinds based on the room temperature extracted from DHT11 sensor.






Device: The devices that are used for this project include the raspberry pi2, NodeMCU with ESP8266, Rotational servo motor, a Photo Resistor, DHT11 sensor.

Communication: The communications used in this project include the serial communication, restful web services, MQTT communication to transfer information about the blinds position to Raspberry pi where this streams data to the InitialState cloud server through the HTTP communication which is secured with the Authentication keys. Also used the HTTP protocol for extracting information from the open weather API.

Services: The different services in this project are the monitor, control services which are explained in the above  Service Specification section.

Management: The different managemental things include the installations, configuration of all the different software's that are needed which includes the BLYNK app, the blynk libraries that are needed for the communication to and from NodeMCU. The different python packages to communicate with the weather API and InitialState Cloud server.

Security: The security for the project is minimal as it operates under the secured home network, but still should have the basic user authentication for the BLYNK application, access to the OpenWeather API, and the InitialState Cloud server. All these require the authentication key in order to have access to them in my project which results in a secured environment.

Application: In my project, the application deployed locally on the NodeMCU, python programs on Raspberry Pi2 device and can be accessible remotely from BLYNK app and also can set timers to control the blinds.


Operational View Specification:

From this specification, we can have a clear view of project how it is realized based on various factors like the service hosting, storage, devices etc.,

Services:


  1. Blynk Service: Service used to control the blinds position from Blynk, a Mobile application
  2. Weather API service: Service which is used to extract the data (temperature, humidity, wind speed) from Open Weather API based on which the blinds position is automated.


Storage: All the data is stored in the InitialState cloud and there only dashboards are created to analyze the different factors which are extracted from weather API and data valuesfrom the sensors.

Devices: 

  1.  Raspberry pi2
  2.  NodeMCU with ESP8266
  3.  Rotational servo motor
  4.  Photo Resistor
  5.  DHT11 sensor


Application:


  1. Mobile Application - Blynk app
  2. Web API - OpenWeather API
  3. Web Dashboard - InitialState
  4. MQTT Server - Mosquiito Interface 


Communications Protocols:


  1. Link Layer:  Wireless LAN(802.11)
  2. Network Layer: IPv4 
  3. Transport: TCP
  4. Application: HTTP, HTTPS,MQTT


Security: 

Authentication and Access keys for:

  1. BLYNK app
  2. InitialState Dashboards
  3. OpenWeather API.

Management:


  1. Mobile Application Management : Blynk App
  2. Web Application Management : Initial State Dashboard
  3. Device Management: Raspberry Pi2, NodeMCU with ESP8266, Servo motor
  4. Server Management: MQTT server, Mosquitto for MQTT UI.
  5. DataBase Management: Initial State Cloud
Device and Component Integration:

Blynk Integration:
Blynk Basic operation

Rotational Servo Motor:

Rotational Servo Motor

DHT11 Sensor
DHT11 sensor connection with the raspberrypi2 


Blynk Service Integration:



In this service operation, the user controls the operation of blinds using the Blynk App. Based on the commands from the Blynk application the NodeMCU controls the direction,speed and rotation of the servo motor which will either open or close the blinds. Once done, then this change in the blinds position is recorded and published to the topic 'BlindsPosition' through MQTT protocol to the MQTT server where the Pi acts as the MQTT broker. Simultaneously, a python program is running on Pi which subscribes to the 'BlindsPosition' topic and continuously checks for messages. If any message published to the topic it subscribes and streamed the data to the 'InitialState' Cloud Storage.
There in dashboards are created to constantly monitor the blinds position.

Blinds Dashboard
Blinds Positon Data




Weather API Service Integration: 



In this service operation, the controls of the operation of blinds made automatic which was based on the external climatic conditions. It's based on two factors. one the time of the day and other the temperature. The use case diagram for this as below.

First checks whether its day or night and then checks if the temperature is greater than the threshold.
Based on these conditions the operation of blinds made automatic. The external data is extracted from the open weather API which is secured as it required the authentication key. A python program is coded which is running on Raspberry Pi extracts data from weather API for every 1 minute. It streamed the data to the 'InitialState' Cloud Storage. Also, continuously checks the conditions and if the temperature exceeds the threshold then published to the topic the command 'close' to the topic through MQTT protocol to the MQTT server where the Pi acts as the MQTT broker. Simultaneously, a program is running on NodeMCU which subscribes to the topic and continuously checks for messages. Based on the message it sends the control signals to the motor and then publishes to topic 'BlindsPosition' through MQTT protocol the position of blinds.
There are dashboards also created to constantly monitor the external conditions.
External Climatic Conditions Dashboard

External Conditions Data 


This Concludes the Specifications of my project. In my next post I would report a complete report of my project which also includes my further enhancements and anticipation of this project extension to the 'Green House'.

Code:
My entire project code is present at this link:
https://github.com/jyothi-lanka/IoT/tree/master/SmartBlindsProject


References:

TextBook: 

  •  Internet of Things: A Hands-On Approach By Arshdeep Bahga, Vijay Madisetti
  • Enabling Things to Talk- Designing IoT solutions with the IoT Architectural Reference Model Editors: Alessandro Bassi, Martin Bauer, Martin Fiedler, Thorsten Kramp, Rob van Kranenburg, Sebastian Lange, Stefan Meissner
Links:

Fundemental parts of project

Smart Blinds - A Home Automation Project


Here comes the final phase of my course. The final project which comes with the inspiration of the concept of 'Green House' which helps the plants to have a safe environment. Likewise, I would like to build my own Home Automation Project for the safety of the kids and pets at home when we are away from home. For this, I chose to automate the blind operations based on various factors like the time of the day, temperature and intensity of the light.


1.Purpose and Requirements Specification

Purpose: A home automation project for automatic controlling the operation of blinds based on the intensity of light, temperature, and time of the day. This can be based on the information from the weather API. Also, provides an option for the user to control the operation of blinds from his phone and can set the timer for the same.

Behaviour: The information about the light intensity, temperature, and time of day is collected from the weather API based on which the operation of the blinds is controlled. Later, the data about the blinds position is tracked, stored in local and cloud database and can be used for further analysis.

System Management Requirement: The system should provide remote control functionality to operate the blinds between open and close modes or should provide timer functionality to automate the process.

Data Analysis Requirement: The system should report data to the cloud database where the data will be analysed.

Application Deployment Requirement: The application should be deployed locally on the device, but can be accessible remotely or set timers to control the blinds.

Security Requirement: The security requirements for the project are minimal as it operates under the secured home network, but still should have some basic user authentication.


2.Process Specification:

The automation system can be performed in three different ways.

1. Using mobile application for remote control of blinds and can even specify the time frame to automate the control.




2. Using the temperature sensor reading at home and make the process automate by closing the blinds if the temperature is beyond the specified temperature threshold.







3. Based on the information about light intensity, temperature, and time of the day from the weather API can automate the blind control.






3. Domain Model Specification:

Physical Entity: The physical entity of my project is the blinds, which is my focus object that is controlled based on various factors like the time of the day, temperature, light intensity.

Virtual Entity:  The virtual entity of my project includes the various parameters I'm tracking for the control of the blinds. They are the time of the day, temperature, light intensity.

Device: The devices being used in my project are Raspberry pi 2, Arduino esp2866, servo motor, DHT11 sensor.

Resource: Raspberry pi 2, NODE-RED, mosquitto MQTT server on the device, Arduino IDE on the laptop.

Service: The service in my application includes the blynk cloud service, which is used for change of modes of the blinds between open and close and a weather API for getting information about the temperature, luminosity etc., based on which the automation of the blinds controlled.



IoT Level Specification:


My project was based on the Iot Level-2 with the following details.

Single device/node
Sensing or actuation
Remote/cloud datastore
Local analysis
Control via Rest
Central/cloud rest services for
Monitoring
Control

IoT Level -2








Sunday, March 20, 2016

Project Proposal Abstract

IoT Smart Blinds


The project is about Smart Blinds. The key point here is the opening and closing of the blinds made automatic and which depends on the intensity of the outside light. Also, can analyse the duration of opening and closing of blinds.

Things Required:

Light Sensor, DHT11 Sensor, Servo Motor, Raspberry pi, Arduino


Data:

The intensity of light is collected using the Light Sensor.

Process:

The data collected from the light sensor sends to raspberry using the MQTT which stores data. From the collected data the PI will make the motor rotate to either close or open the blinds based on the data.

People: 

It can be used by people to operate blinds automatically  either by light intensity or as per the user wish.

Monday, February 22, 2016

Communication with Pi via MQTT using Arduino

Experiment: Communication with Pi via MQTT using Arduino 


1. Installed all the required packages: SPI, PubSubClient
2. Tested the example program 
It connects to an MQTT server then:
  - publishes "hello world" to the topic "outTopic" every two seconds
  - subscribes to the topic "inTopic", printing out any messages
    it receives. NB - it assumes the received payloads are strings not binary
  - If the first character of the topic "inTopic" is an 1, switch ON the ESP Led,
    else switch it off.
3.Tried communicating with pi by using it as the server.
4. Read the messages in from the topic "outTopic" using mosquitto.


Code: https://github.com/jyothi-lanka/IoT/blob/master/mqtt/mqtt_esp8266.ino


Video:





Whom I helped:

Helped my classmates( Hema, Prashant, Sandeep) in
1. Trying to install packages.
2. Working on the Arduino programming to connect to the MQTT server.
3. Solving the issues during the connection.


Who helped me:

Prashant helped me in connecting to the Pi using the Arduino programming and also using mosquitto.


References:http://m2mio.tumblr.com/post/30048662088/a-simple-example-arduino-mqtt-m2mio


Friday, February 19, 2016

Node-RED

Node-RED is a visual tool for wiring the Internet of Things - hardware devices, APIs and online services in new and interesting ways.


INSTALL Node-RED


sudo apt-get update
sudo apt-get install nodered

To start Node-RED, you can either:

on the Desktop, select Menu -> Programming -> Node-RED.
or run node-red-start in a new terminal window.
To stop Node-RED, run the command node-red-stop


Adding nodes


To add additional nodes you must first install the npm tool, as it is not included in the default installation. The following commands install npm and then upgrade it to the latest 2.x version.

sudo apt-get install npm
sudo npm install -g npm@2.x
cd ~/.node-red
npm install node-red-{example node name}

Extra Nodes


To install extra nodes make sure you are in your user-directory, by default this is ~/.node-red.

For example the Pibrella node can be installed as follows

npm install node-red-node-pibrella

You then need to stop and restart Node-RED to load the new nodes, and then refresh the flow editor page in the browser.

node-red-stop
node-red-start


This guide will help you get Node-RED installed and running in just a few minutes.
  1. Installation
  2. Upgrading
  3. Running
  4. Creating your first flow
  5. Creating your second flow