Month: November 2015

Leveraging the power of Twitter for Internet of Things (IoT)

Today we are witnessing the era of Internet of Things (IoT) and how it is changing the lives of people. However there are very few success stories so far people are still  exploring the platform to be used for IoT. In this post we will discuss the challenges with the current available platforms and how twitter can be used as general platform for developing quick Internet of Things applications. Also we will   discuss how this platform will be used in future for establishing Social networks between the devices connected to Internet of Things.

Introduction to Internet of Things:

The Internet of Things (IoT) is the network of physical objects or things embedded  with electronics, software, sensors , and network connectivity, which enables these objects to collect and exchange data [1].It goes beyond the legacy M2M (Machine to Machine) communication in the sense that it covers different protocols, system, devices etc. According to Gartner, Inc. (a technology research and advisory corporation), there will be nearly 26 billion devices on the Internet of Things by 2020 [2].Due to this nature of IoT most of  the IoT vendors are trying to create a generic platform to handle different needs.

Challenges Involved in IoT Platform:

A.    Interoperability Standards:

There are number of open and proprietary IoT solutions available which creates a great deal of confusion over which platform to choose and which will fit the requirement. IoT Platform should be such that it should be interoperable and use standard protocol which makes it easy for different devices from different vendors to communicate easily.

B.    Data Rate:

Data Rate plays a very crucial role in IoT and is one of the major factor to be consider while implementing the IoT platform. Some devices connected in IoT continuously send data at a very high data rate while some only sends data at some event. IoT platform should be capable of  handling such kind of data rate.

C.    Security

Data security and access is very important in IoT as interconnected devices takes decisions based on the messages communicated between them. Adding security features to wireless systems requires more overhead in each packet sent. It also means adding components within the electronics. IoT platform should have a good authentication mechanism to avoid any unauthenticated device or user to hack the system and also have a less overhead at electronics. The level of security usually depends upon the application, which requires anything from maintaining consumer privacy to limiting cyber attacks against utilities.

D.    Complexity:

As IoT architecture is complex the platform should be implemented in such a way that it should be simple not only for the developers but also for the end users and analysts.

Twitter as IoT Platform:

Twitter is most popular micro blogging site where people post short messages of 140 characters called tweets. It has million of active users who post millions of tweets daily.It not only allow users but the applications to post messages on user behalf using Twitter API.If this API’s are used as the channel for sensors to communicate then it will becomes very easy and fast way of deploying IoT application.It will remove all the complexity involved in maintaining and deploying altogether a new IoT application.Also all the overhead of  high data volume and data rate will be taken care by twitter. Twitter will not only help the devices in one IoT to communicate with each other but also the other devices which are in different networks as well as human which will further increase the power of the entire IoT. The sensors involved in IoT will not only take decisions using the sensors but also consider tweets from people as the sources of information.This solution will also solve the problem of interoperability as it will provide as common platform for all.

Sample Prototype:

To prove whether this will work or not I have create a small IoT application using beagle bone .This application will continuously monitor a sensor on port “P8_14” and will tweet if it detects a HIGH on that port.Similarly on the receiver side there will be again another sensor listening to the twitter account on which device is sending the tweet and will print that tweet. Following is the setup of these system:

In order for beagle bone to connect to internet I have shared internet on my laptop with beagle bone (for more information on how to set internet please refer to this link <TODO:Add github link> ).After setting this lets do some code in python:

Code at sensor:

import Adafruit_BBIO.GPIO as GPIO
from twython import Twython
import requests
GPIO.setup("P8_14", GPIO.IN)
requests.packages.urllib3.disable_warnings()
USER_KEY="User key for twitter app"
USER_SECRET="User secret for twitter app"
ACCESS_TOKEN="Access token"
ACCESS_TOKEN_SEC="Access token secret"
client_args = {
 'verify': False
}
twitter=Twython(USER_KEY,USER_SECRET,ACCESS_TOKEN,ACCESS_TOKEN_SEC,client_args=client_args)
while True:
    if GPIO.input("P8_14"):
        twitter.update_status(status="Detected Sensor output")

 

Code at Receiver End:

In order for the receiver to continuously  listen to the twitter we need to use Twitter streaming api.For this we need to first create a subclass of “TwythonStreamer” as follows:

from twython import TwythonStreamer
class IoTStreamReader(TwythonStreamer):
 def on_success(self, data):
    print "Received Tweet from Sensor:"
    print data
def on_error(self, status_code, data):
    print status_code
    self.disconnect()

Now initialize IoTStreamReader and track for the keyword in stream as follows:

USER_KEY="User key for twitter app"
USER_SECRET="User secret for twitter app"
ACCESS_TOKEN="Access token"
ACCESS_TOKEN_SEC="Access token secret"
client_args = {
 'verify': False
}
stream = IoTStreamReader(USER_KEY, USER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SEC)
stream.statuses.filter(track='Sensor')

This code is comitted on github repository

Limitation of this solution:

This platform will not work for the use cases where data is critical as the data on twitter is available to all.

Also we have to totally rely on twitter for the data

Conclusion:

In this post we have seen how  Twitter can we used  in IoT and how it can help not only connecting devices in IoT but also help us to create social network of humans with sensors.

References:

1] https://en.wikipedia.org/wiki/Internet_of_Things

2] http://www.gartner.com/newsroom/id/2636073

Advertisements