IoT Solution built using Arduino board and Raspberry Pi


Want to setup your own IoT solution easily? Want monitor the temperature, pressure, humidity, light, etc. in real time? Want to see real time sensor data in dash boards and setup custom alerts?

The Microsoft Open Tech team has released some sample code that enables you to create this IoT solution on Azure using Arduino boards and Raspberry Pi with sensors easily. Please refer to the following blog from MS Open Tech for details – http://msopentech.com/blog/2014/12/10/connecthedots-io/.

In the solution referenced in the MS Open Tech blog post, Azure Stream Analytics enables you to perform real time analytics such as aggregating information across all sensors, or setting up specific alerts. In this post we will show some sample queries for aggregations and the alerts in this IoT solution. End to end solution of displaying the results generated using Azure Stream Analytics is described in the MS Open Tech blog post.

  • What is the data coming from these sensors?
      Each sensor is sending data such as – {“time”:”2014-12-11T02:24:56.8850110Z”,”hmdt”:42.7,”temp”:72.6,”prss”:98187.75,”lght”:0.38,”dspl”:”R-PI Olivier’s Office”}. JSON document with sample data –

https://github.com/streamanalytics/samples/blob/master/SampleDataFiles/SampleSensorData.json

 

  • Aggregations – What is the average temperature across all sensors?

SELECT

    System.Timestamp AS DisplayTime,

    MAX(Temp) AS TempMax,

    MIN(Temp) AS TempMin,

    AVG(Temp) AS tempAvg

FROM

    DevicesInput TIMESTAMP BY time

GROUP
BY

    TumblingWindow(Minute, 1)

In this example the aggregations are done over the temperature reading coming from all sensors. We are computing the maximum, minimum and average temperature in a tumbling window of 1 minute.

 

  • Alerts – Send me an alert if the light is off

SELECT

    ‘LightSensor’ AS alerttype,

    dspl AS dsplalert,

    ‘The Light is turned OFF’ AS message,

    MAX(time) AS DisplayTime

FROM

    StreamInput TIMESTAMP BY time

GROUP
BY

    SlidingWindow(s, 5),

    dspl

HAVING

    AVG(lght) < 0.02

    AND COUNT(*) > 2

In this example we are raising an alert with a message ‘The Light is turned OFF’ if the average reading from the light sensor is less than 0.02 in the last 5 seconds, and we have got at least 3 readings.

 

Please refer to the following documentation for information on the query language and windowing functions – http://msdn.microsoft.com/en-us/library/dn834998.aspx

Additionally you can use the sample JSON document mentioned earlier in this post to test the queries using the query validation in portal functionality – http://blogs.msdn.com/b/streamanalytics/archive/2014/11/12/update-to-stream-analytics.aspx

 

If you have any questions or feedback, please visit our forum. We look forward to hearing from you!

Comments (0)

Skip to main content