Click here to Skip to main content
12,824,299 members (40,697 online)
Click here to Skip to main content
Add your own
alternative version


9 bookmarked
Posted 28 Apr 2013

Home Automation Using Smart Connector

, 12 May 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
This article explains how to create Smart Home which is controlled by RaspberryPi devices connected via SmartConnector.

Editorial Note

This article is an entry in our Windows Azure Developer Challenge. Articles in this sub-section are not required to be full articles so care should be taken when voting. Create your free Azure Trial Account to Enter the Challenge.

Table of Contents


This article will explain how to use <a href="" target="_blank" title="Smart Connector">Smart Connector</a> to connect various devices to create connected system. This article will also explain how to make your home a Smart Home by making use of Open Source Hardware and connecting them together by the greatest cloud platform The Azure. In today's world we have many open source hardware platform available eg. Raspberry Pi which are cheap and by making use of this platforms we can build a always connected environment which can make our day to day tasks easy.    


There are various open source hardware devices which are cheap and if we get this devices connected via simple process which provides real time communication then it will be great system. So this is idea behind SmartConnector which provides simple process to connect various devices together.  

Why Azure

To make the always on connected world which communicates in real time, Azure provides just the things needed, like WebSockets, without having to worry about scalability, performance, infrasturcture etc.

How It Works 

As explained in above diagram we can see that Smart Connector Server is the heart of the system which provides communication between all the devices. Users have to signup on SmartConnector and create apps. Once the app is created click on it to get details related to that app which also includes API key for the app. Once logged in you can click on users link and you will be directored towards user managemenent pages wherein you can add users who will be using your apps. Once all the subusers are added then you can associate users to apps which you want them to be accessible. When any subuser will log in to the SmartConnector then he will provided with the list of apps to which he has access and once he clicks on any of the app he will be provided with the list of devices which are connected to this app. Now user can send & receive data from the device if he have been given right to do so.

All the raspberry pi devices are configured to connect to perticular application by using its API key and once it is connected to app then it can be controlled by anyone who have access to it.

Below image describes brifely about the how a user will interact with Smart Connector.

Below image describes brifely about the how a sub-user will interact with Smart Connector.

Now lets understand how the user is going to use the client application to make use of Smart Connector.

1. Log In: User logs into the system by using his/her username and password.
2. List of Devices: User will be provided with the list of devices for which he have access.
3. List of Operation: When user clicks on any device he will be provided list of operation he can perform on device.
Eg. Turn the bulb connected to GPIO pin 16 on or off is one operation provided by the device.
4. Details of The Operation: When user selects any operation he will be provided with details UI for that operation.
Eg. Current state of bulb connected to GPIO pin 16 and button to toggle the state of this bulb.
5. Charts for Operation: User can also see the status of any sensor connected to raspberry pi.
Eg. If thermostate is connected to Raspbery Pi then user can see the status of it in temperatures for whole day/week/month.
6. Dashboard: User can also see the status of all the sensor connected to any perticular device for last one day/week/month.


The Server:
The server acts as a middle person between all the devices which wants to communicate with each other. The server keeps track of all the registered users, their apps and the devices which are registered to be used with particular app. It provides the communication between all the connected devices via WebSockets if available other wise the connection will fallback to long polling so that maximum number of clients will be able to communicate.

The Clients:
The clients can be the Raspberry pi device which is connected to server or a mobile/laptop/desktop device which wants to control the connected device or get the status of connected device.
The clients can be of two types

1. As a Device:
This role is applicable to Raspberry Pi which connects to server and waits for messages from server. As a device role raspberry pi will be configured to send commands to its GPIO pin when any respective message is received from server. It can also send the status of any GPIO pin back to server to show the current state of any particular GPIO pin.
Eg. When raspberry pi receives a message from server as "PIN16-ON" then is send the high value to it's GPIO pin number 16 and when it receives message as "PIN16-OFF" it will send the low value to it's GPIO pin number 16.

2. As a Controller:
This role is applicable to user who want to control any of the connected device using mobile app or laptop/desktop browser.
Eg. If there are three raspberry pi devices connected to server and user want to send a low command to GPIO pin number 16 of first raspberry pi then he can use mobile or desktop browser to do so by clicking on first raspberry pi device from list and clicking on toggle button for it.

Using The Code

To start using SmartConnector you have to Sign up on SmartConnector website and get your application key. You can add various devices in your application by logging into administrator account and can give a unique device ID to each device so as to use it to send and receive message from this device. Once you have your app-id and device-id with which you want to connect then you can follow below tutorial to get it connected. 

Include the SmartConnector JavaScript library  

<script src=""></script>

Open Connection to SmartConnector 

var smartConnector = new SmartConnector('YOUR_APP_KEY');  

Get the list of devices that you have added in your app 

var deviceList = smartConnector.GetDeviceList(); 

 Subscribe to a device using it's ID.  

var raspberryInLobby = smartConnector.subscribe('RASPBERRY-PI-IN-LOBBY'); 

Listen for messages from the device.  

raspberryInLobby.bind('my-message-type', function(data) {
  alert('A message was recieved from the device: ' + data.message);

Send data to Raspberry Pi in Lobby

    type : "my-message-type",
    message : "PIN16-ON"


1. Real time communication using WebSockets.

2. Raspberry Pi.


It is very easy to setup a always on connected network using Smart Connector and as explained above the making a Smart Home is the type of example using Smart Connector.

Future Plans

In future support for some more open source hardwares will be provided to take advantage of Smart Connector which includes BeagleBone, pandaboard etc.


May 2 : Updated "How It Works" along with examples.
April 30: Created Initial Draft


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Sagar B. shelar
Software Developer
India India
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
Humayun Kabir Mamun13-Mar-15 1:00
memberHumayun Kabir Mamun13-Mar-15 1:00 
Questionthis link is broken u gave Pin
Tridip Bhattacharjee9-Jul-14 22:13
memberTridip Bhattacharjee9-Jul-14 22:13 
Generalgreat idea ... Pin
Swapnil Shrikhande16-May-13 4:00
memberSwapnil Shrikhande16-May-13 4:00 
GeneralMy vote of 5 Pin
Swapnil Shrikhande16-May-13 3:55
memberSwapnil Shrikhande16-May-13 3:55 
GeneralMy vote of 5 Pin
roscler29-Apr-13 2:45
memberroscler29-Apr-13 2:45 
GeneralRe: My vote of 5 Pin
Sagar B. shelar29-Apr-13 22:28
memberSagar B. shelar29-Apr-13 22:28 
GeneralRe: My vote of 5 Pin
roscler29-Apr-13 23:03
memberroscler29-Apr-13 23:03 
GeneralRe: My vote of 5 Pin
Sagar B. shelar29-Apr-13 23:57
memberSagar B. shelar29-Apr-13 23:57 
GeneralRe: My vote of 5 Pin
roscler30-Apr-13 0:06
memberroscler30-Apr-13 0:06 
GeneralRe: My vote of 5 Pin
Sagar B. shelar30-Apr-13 0:15
memberSagar B. shelar30-Apr-13 0:15 
GeneralRe: My vote of 5 Pin
roscler30-Apr-13 1:02
memberroscler30-Apr-13 1:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170308.1 | Last Updated 12 May 2013
Article Copyright 2013 by Sagar B. shelar
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid