.NET Micro Framework, Azure Service Bus and your own IoT OBD Recorder
- Posted: Jun 06, 2014 at 6:00 AM
- 14,088 Views
- 1 Comment
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Today's Hardware Friday comes to use from Markus Horstmann and provides another example of hooking your Netduino, .Net Micro Framework project to the Cloud via the Azure Service Bus and the AMQP.Net Lite library.
This sample illustrates how to connect a .Net Micro Framework-based device to the Azure cloud using Azure Service Bus as a Device Cloud Gateway for telemetry and command & control.
The sample uses the AMQP.Net Lite library (http://amqpnetlite.codeplex.com) to implement bi-directional communication to Service Bus. It works with "Reykjavik" (a framework around Service Bus for large-scale device/IoT connectivity), but does also work with Service Bus on it's own.
Building the Sample
The sample requires Visual Studio 2012 (not 2013) because .Net Micro Framework is not supported on later versions at this time (May 2014).
You will need an SSL-capable .Net Gadgeteer compatible device with a networking module as well as an OBDII adapter (tested with GHI Electronics Spider board, Ethernet module, and OBDII adapter). If you don't have an OBDII adapter, the sample will generate simulated OBD data.
After downloading the sample you need to add a reference to the AMQP.Net Lite project, i.e. use "Add existing Project", remove the AMQP reference in OBDRecorder project and re-add a project reference.
You need to create a Service Bus namespace and update the namespace URLs and keys in OBDRecorder/program.cs (the keys in the sample are no longer valid).
The sample does not currently function in the device emulator due to a bug in the emulator networking libraries.
At the core, the device uses the AMQP.Net Lite to send messages and receive messages.
Source Code Files
- OBDRecorder project:
- program.cs - the main logic
- obdii.cs - reads data from the OBDII adapter, simulates data if no adapter is connected.
- amqpsender.cs - helper functions for message sending using AMQP.NET Lite
- amqpreceiver.cs - helper functions for receiving messages
- amqpsendreceivebase.cs - commun functions use by sender and receiver helper functions.
- obd II_42/Elm328.Core projects: patches to the .NEt Gadgeteer libraries to make OBD work, at least in a Prius 2007.
- Microsoft.ServiceBus.Micro - helper libraries for HTTP-based access to Service Bus (from http://ms.aka/iot2, with additions for SAS); only used when the sample is modified. Otherwise, the sample only sends via AMQP.