The 1st ever Internet of Things (IoT) DevCamp by Microsoft in India
Last month we conducted the 1st ever Internet of Things Camp in India. It was indeed a great experience as this was Hands-on, and attendees enjoyed getting their hands dirty with Development boards, Sensors, Azure, etc.
Why is everyone talking about IoT these days?
Well for those who are new to the IoT world, this is the next big computing revolution and is expected to be bigger than all previous computing markets. IoT is a basically networking of various devices/ machinery, that helps gather data and do analysis on top of that. For Enterprises this helps them cut down on their operating cost, optimize performance, build better customer connect. I am sure you would love to get a call a week in advance (before your engine breaks down) from your car manufacturer letting you know that you car needs servicing based on Engines’ sensor data! Many such scenarios can be stiched through with the Internet Of Things!
In case you would like to understand how you could use it for your IT you can find more details here.
You can find Microsoft’s vision on IoT here.
About the Event:
We had the event in Bangalore and Mumbai on 25th and 26th of June. We had an awesome audience across both the locations, and their willingness to cling onto the new technology/ platform was great.
Agenda:
- IoT overview, architecture, Microsoft platform
- Event Hubs
- Devices (Arduino UNO, Raspberry Pi, etc.), Sensors (Sparkfun weather shield)
We mostly leveraged the Open Source Project published by Microsoft Open Technologies. This is pretty cool and the code repository is quite frequently updated; hence adding more supported devices to the existing scenario. You can find the source code here.
We used a Gateway Architecture, Gateway being the Raspberry Pi running Linux (yes you heard it right; welcome to the new and open Microsoft), which collects data from lighter single threaded Arduino UNO boards with sensors. Most importantly using a Gateway we were able to secure the communication channel between our on premise data collection system and the cloud! Also Raspberry Pi might not directly support Analog sensors as it has digital ports.
1. We started off with connecting the Sparkfun Weather Shield to the Arduino Uno board. Deployed code to Arduino Uno to Read the sensor data from the Weather shield (Data collection).
2. Once we were able to send the Weather shield data in JSON format to the serial port, we connected it to Raspberry Pi. Here we deviated a little from Connecting the dots implementation to save some time. Instead of deploying .NET code using Mono on Linux, we used crowds favorite - Python, to directly read and send the data to the cloud from Raspberry Pi. This was fairly simple using the Azure SDK for Python (documentation) . Just a single Line to execute:
1 sudo pip install azure
*Assuming pip is installed
3. Using the Azure SDK for Python life becomes easier interacting Azure. This piece is very important as we will be doing the real time analysis on the Cloud. But before we start sending the Data we need to create Events Hub under Azure Service bus, which is capable of ingesting millions of data per second. Post which we can run Stream analytics Job to figure out meaningful insights of the real time data.
The name of the Events Hub, Policy Name, Primary/ Secondary key is what we will need to put it in the code to establish connection with the Events hub.
1 import serial
2 from azure.servicebus import ServiceBusService
3
4 key_name ='RootManageSharedAccessKey' # SharedAccessKeyName from Azure Portal
5 key_value='wTjYCKkPpP109gzHP49i0WCxPVfvMgHol5eOSO/TBrM=' # SharedAccessKey from$
6 sbs = ServiceBusService('dxiotdemosb', shared_access_key_name=key_name, shared_$
7 sbs.create_event_hub('hubcreationfromlinux')
8
9 deviceId = "device-10"
10 serialport = serial.Serial("/dev/ttyACM0", 9600)
11
12 while True:
13 try:
14 command = serialport.readline()
15 sbs.send_event('hubcreationfromlinux12', str(command))
16 print 'hubcreationfromlinux', str(command)
17 except IOError:
18 print "Error"
19
20
If you look at line 7, we are instantiating Event Hub named ‘hubcreationfromlinux’, so all you need to do before is to setup Service bus namespace.
4. Analysis of the Data received by the Events Hub – The details can be found in the connecting the dots repository here.
At the end of the day, everyone loved the experience of playing with development boards, and being able to run their code to connect and send data to Azure. In real world the same scenario gets multiplied millions of times to produce tons of data from machinery, devices, etc. But now the attendees understood the basics of Internet of Things a lot better!
In case you missed the excitement this time, do keep in touch with us by following the DX India blog for updates on more such events!
Regards,
Abhishek Narain
Technical Evangelist