Know Your Air (KYA) – Air quality platform using IoT

Know Your Air (KYA) is a cloud based air quality platform we created during the recent AT&T developer summit at Las Vegas. Air pollution (especially in urban areas) is increasing day by day, and knowing the air quality help us in taking preventive actions as well as travel planning.

KYA has three sub systems

  1. Hardware – Input sensors and Output display unit
  2. Data storage and analytics
  3. Prediction service

The following photo is taken during the hackathon demo.KYA_demo

Let me give a quick overview of each sub systems.

  1. Hardware – Input sensors and Output display unit: – We used three hardware boards, and each one represents the real life use case when we deploy similar solution in production.  Most of the public transit stations would have air sensors connected to KYA cloud end point, and in our demo we simulated a bus stop with Qualcomm Dragon board and Grove air sensors. Android is the default operating system for Dragon board, and we could easily wire up the sensors.   We also connected a 13 inch display unit also to the Dragon board so that it show the bus number, bus arrival time, local air quality details and AQI (Air Quality Index) of the approaching bus. Yes, you are reading it right. I meant the air quality inside the approaching bus. If you are concerned about the CO2 inside the bus, check it before boarding the bus  We had connected Intel Edison board with CO2 and Air quality sensor, inside the simulated bus. Here we have used the Intel XDK, and Node modules to push the air data to the KYA cloud. The third input was from a Drone. City officials might need to check the air quality on demand. If any construction site or any other events violates the city norms with respect to air pollutions, City authorities can use this method. We had connected Konekt board with air quality sensor on a drone. All the above-mentioned input methods feed air data along with GPS.
  2. Data storage and Analytics :- We used the AT&T M2X cloud for sensor data storage. M2X got pretty much stable client libraries, and integration with Node and Android was straightforward. M2X is great platform to manage the time series data. M2X also provides the built-in chart with historical data for any sensor, and we could use that with our dashboard. Air Quality Index (AQI) and the various gas (CO2, Methane etc) intensity were calculated for each geo coordinates, and REST end points will provide the nearby AQI for any geo coordinates.The Air Quality Index provides a number from 1 to 10+ to indicate the level of health risk associated with local air quality. On occasion, when the amount of air pollution is abnormally high, the number may exceed 10.We had also setup the air quality heat map on top of Google map, so that the consumers can visualize the air pollution for any location.
  3. Prediction service:- We used the IBM Bluemix predication service to predict the air quality for 6-12 months for given geo coordinate. Input data for the prediction service was coming from the IBM IoT hub, and we were feeding it from AT&T M2X.

Currently, Most of us plan our travel by checking the weather forecast, and in near future we might check the air quality of the destination city as well, and carry air bottles and masks.

Smarter overhead bin to reduce to flight boarding time or airlines delay

bin fullMost of the time the overhead bin capacity plays a major role in flight boarding time or even flight delay, especially in domestic flights in USA. What if the overhead bin is little bit smarter, and can inform the gate agent if it is getting filled. So that the gate agent can ask the passenger to check-in the bags there itself, and issue the check-in tags.  Hence the passengers don’t have to carry the bags till the flight, and at a later stage realize that there is no place in the overhead bin. It can be even smarter. For example, when I scan my ticket at the gate, and I  see the current status of the overhead bin right above my seat.

I tried to solve this problem with a cost effective technique using Intel Edison and Microsoft Azure.  Lets watch the demo video first, and then I can explain the technology behind this.

The display unit is supposed to be placed at the entry gate, so that gate agent can see the live update, and mobile employees can have the smartphone app.  I have used the Intel Edison Arduino expansion board for the demo. In production, this entire setup can be a tiny one. Gate agent only need the display unit along with the Edison chip, and the flight agent only need the Edison chip with a button.  All the bins should have a Edison chip and a light sensor. This is optional if we want to automate everything. If the flight agent / cabin crew member is pressing the button, we don’t need the Edison chip inside the bin.  All the devices are connected to WiFi, and it should go to airplane mode before the airline takes off, so that we are not breaking the existing regulations.

Implementation details

I have used the Intel XDK IoT edition with Node.JS to develop this prototype. All the devices are connected to Microsoft Azure cloud. I have configured the Azure Service Bus topic, and the devices connected inside the bin (and the device carried by the cabin crew member) are sending the message to the service bus topic. This article should provide the details on how to send the message to topic, and subscribe the messages.    We don’t have to create the topic as mentioned in the above mentioned article, instead create the topics using the Azure management portal, and initialize the service bus using the connection string as given below.

Then we can send the message to topic as give below.

Here is the code snippet for the LCD RGB display unit for displaying the status with background color.

Let us hope that our airlines become smarter and cabin crew members don’t have to use the walkie-talkie system to interact with the gate agents.

Smart green house with Intel Edison and Microsoft Azure

I have attended the Intel IoT Roadshow here in Silicon Valley during last weekend, and made this cool project – Smart Green House. Intel provided a bunch of sensors, and I thought of doing something with green house. We had done similar hack earlier during AT&T Developer summit hackathon at Las Vegas, but that was for industrial farming.

Project description :- I have placed various sensors inside the green house, and the system will monitor current condition (soil Smart Green Housetemperature, moisture, light, ph level, ultra violet, water et ), and report to the back end cloud.  Backend knows the current profile of the green house(I have used radish plant for demo), and if there is anything abnormal, green house system will adjust the settings. For example, if the temperature is high then the system will turn on the fan. If the water level is low, then the system will automatically turn on water pump. I have placed the LCD display unit outside to see the current health level, and if anything unusual with green house then the display will be red, and notification will be send as SMS.  Let us dive into more technical details. Following diagram shows the hardware pieces used in this project.Smart Green House components

Implementation details:- Core of this project is the Intel IoT developer kit which they have provided to the first 150 attendees, and I was lucky enough to get one. In addition to the default kit, I have managed to get the mini water pump, water flow control, fan, light etc.  I have used Intel XDK IoT edition for the development and used the Node.JS / Java script to read/write to hardware/sensors.  Intel SDK team did pretty decent job in documenting everything, and enough sample codes, and I could set up the first sensor up and running in couple of hours including the XDK and drivers installation.  Here comes the code sample to read the temperature value from the sensor connected to the analog pin.

Similarly, I have read values from all the sensors, and sent the same to Azure Event hub. I couldn’t find any AMQP 1.0 node package to connect to the Azure event hub, hence I used the REST api to post the reading in every second.    During the start of the app, green house system will connect the Azure backend to retrieve the profile for the current plant, and in this case it got the profile for radish plant.  Since the green house system already got the plant profile at the start, any reactive action (eg:- turn on water pump, turn on fan etc) don’t require network/backend connectivity. Hence we don’t put the plants on risk incase if there is any network outage.

Once I get the sensor values at Azure event hub, data gets forwarded to Stream Analytics service, and then the output of the stream is directed to the Power BI for dashboard. dashboardHere is a dashboard from my demo.

Even though I am an electronics engineer by degree, I didn’t seriously worked with the electronics components after the course. IoT hackathons are really helping me to do some amazing things, and I am enjoying it. Hope to write some more articles pretty soon on IoT.


Connected car with Microsoft Azure ( CAN Gateway to Stream Analytics)


Couple of months ago, I had attended the Toyota hackathon here in Silicon Valley, and learned about the new capabilities Toyota is building in their car. Recently I spent sometime with Azure Stream Analytics as well, and thought of connecting the car with Azure cloud. Once we get the live car data (eg:- engine speed, location, vehicle speed, fuel level etc) to cloud, possibilities are end-less. This article will provide simple visualization using Power BI, and we can extend this use-case to any of the telemetry  platform use cases (eg:- travel safety, predictive maintenance etc).

CAN-Gateway ECU System

The CAN-Gateway ECU allows users to read data – including GPS location, fuel cCan_Overviewconsumption, engine revolution speed, odometer and more – from various sensors in the vehicle. The CAN-Gateway ECU has Bluetooth LE interface, and smartphone application can send the signals to the CAN-Gateway ECU, the Gateway provides the data requested by the application.

CAN Gateway to Android Application

For this demo, I will be using drive simulator application( on Android) which acts as CAN Gateway ECU system.  I have another Android application to read the data from the Gateway (or Simulator).  Here comes the snippets about the data buffer formation, and reading the signal.

Android Application to Azure Event Hub

Please refer my earliest post about Android to Event Hub interaction, and I am using the same approach here as well. Here I am adding many more attributes as part of the JSON as given below.

 Azure Event Hubs to Stream Analytics

Create the new Stream Analytics from the Azure portal as shown below. We could save some data transfer cost if we keep both Event Hubs and Stream Analytics in same region.  NewStreamAnalyticsOnce we create the new stream analytics, its time to add the input, output and query.

Input:- Click on “Add Input”, and select “Data Stream” and “Event Hub”, and select your Azure subscription and Event hubs name.  Select “JSON/UTF8” as event serialization format, and test the connection.

Output:- Stream Analytics provide different output options ( including Power BI), and in this demo, I am using the Table Storage option, so that I can play around the data at later stage as well.

Query:- Query is integral part of the Stream Analytics, and this is where the live data filtering really happening.  In this demo, I am selecting all the attributes from the event hub.  But we can do all sort of filtering here (eg:- find the cars who are crossing speed limit in specific area)

 See it in Action (Demo Time)

Now we have connected all the required pieces for this demo.

  • Start the Stream Analytics by clicking “Start” icon at the bottom portion in Azure portal.
  • Start the car simulator in Android phone
  • Start the sample app in another Android phone and connect the app to simulator via Bluetooth
  • Check out the Table Storage Explorer to see the live data or even Power BI dashboard


You might be wondering what is the big deal in getting the car live data to Azure table storage / Azure SQL and this can be even done easily with Azure Mobile Service. Then you are missing the point.  Think about a vehicle fleet system, where hundreds of car data (read it as Uber car data) coming to the Event Hubs, and fleet administrators configure various queries in Stream Analytics service to process the live data, and take further action.  With Azure Event Hubs and Stream Analytics, Connected Things (IoT) got better future, and looking forward to see many more awesome apps.