Sometimes you do need to be Pushy... "Near Real Time Sensor Data with Windows Azure Mobile Services, .NET Micro Framework, Pusher and ASP .NET MVC"
- Posted: Mar 29, 2013 at 6:00 AM
- 5,543 Views
Today's Hardware Friday project by Nick Harris.
Here's a summary that says it all...
This is a little demo pulled together over the weekend to demonstrate that we can do some really cool things using Mobile Services and embedded devices! - the dataflow is basically the following:
- Temperature and Humidity data captured on using .NET Micro Framework 4.2 on Gadgeteer GHI FEZ Spider
- Data is then inserted into mobile services using a thin slice of the Mobile Services SDK that i ported to .NET MF. It was slow going as in the .NET MF there is no support for generics, json serialization, no linq and limited reflection capabilities sort of like coding back in .NET 1.1
- Mobile Service Insert Script sends collected data to this browser via Pusher - one of our store partners
- Windows Azure Web Site Web client subscribed with Pusher and shows update live data on graph in near real time
It’s no surprise to people around me that I have a strong desire to code more, so I did just that on a Saturday several weeks back and here is what I built – a new devices + services scenario using a Gadgeteer, the .NET MicroFramework, Windows Azure Mobile Services and Pusher and Windows Azure Web Sites.
Capturing Sensor Data
For this scenario I am using the GHI Gadgeteer FEZ Spider and I have already installed all the pre-req software from GHI An embedded device that runs the .NET MicroFramework and has a bunch of plug and play sensors for rapid prototyping. To collect the sensor data is quite straight forward
Storing the Sensor Data in Mobile Services Ok the first thing that you will need to do is Create a Mobile Service. Within the Windows Azure Portal Click New+
Sending the sensor data to listening clients using Pusher
This is where things get pretty sweet. I wanted to visualize my sensor data in a graph as it arrived in my Mobile Service. Recently we announced a new Windows Azure Store partner – Pusher a WebSocket Powered Realtime Messaging Service. Within the Windows Azure Store you can quickly provision a Pusher account and utilize it from Mobile Services within minutes as follows.
Graphing the data received via Pusher in a web client running on Windows Azure Web Sites
So now we had our sensor data collected, inserted and stored in Mobile Services and then pushed using pusher to any listening clients. What I wanted was a web client to visualize the data in a graph as it arrived. You can learn how to create a free Windows Azure Website using ASP.NET MVC and deploy it to Windows Azure here – http://www.windowsazure.com/en-us/develop/net/tutorials/get-started/
If you read through the code you will see pretty clearly that the Pusher implementation is 3 lines of code only – to me this is extremely cool. Itty bitty amount of code, phenomenal cosmic power!
So that’s it now we have live graphs on our website, you can checkout a running version of this code and it live graphs that I deployed to a Windows Azure Web Site here – http://microframework.azurewebsites.net
How much does it cost
Everything that I did here can be done for free with Windows Azure Windows Azure Free Trial and/or the great free tier offerings for Windows Azure Web Sites, Windows Azure Mobile Services and Pusher.
Where’s teh codez?
This is unofficial, is not supported – I did it in my free time and it Works on my machine! disclaimers all being said I really hope that this does open up a lot of doors for you for building out a whole new range of devices + services scenarios using Windows Azure and our Store Partners You can download the .NET MF lib and sample code from this github repo
I hope this has opened the door to great new devices+services scenarios you can build out for your .NET MicroFramework solutions. With few lines of code and powerful services like Windows Azure Web Sites, Windows Azure Mobile Services and Pusher you can make working in the emerging embedded devices + services space a lot easier then it has been in the past. Please do let me know if you have built something awesome in this space on the Twitterz @cloudnick
Check, check, check! Got to love that you can do all this cloud stuff for free!
So what are you waiting for? Get building your cloud connected projects!