MyDriving – An Azure IOT and Mobile sample application

Building IoT and Mobile solutions is fun and exciting. This year at //Build, we wanted to show the amazing scenarios that can come together when these two are combined. So we developed a sample application. The MyDriving Azure IoT and Mobile sample application enables you to record trips in your car using the MyDriving mobile application and off the shelf OBD devices. It uses Azure Services in the backend to analyze car telemetry data for both real-time insights like fuel consumption, and long term patterns and trends like driver rating.

The IoT device in MyDriving

This solution uses On-board diagnostics (OBD) data from your car to analyze your driving. Most modern cars have a standard OBD-II Data Link Connector in the cabin. By plugging in an OBD-II compliant dongle, vehicle data can be made available to other local devices via USB, Bluetooth, or WiFi. Depending on the make, model, and age of your car, you can collect various types of OBD telemetry such as speed, fuel efficiency, and engine RPM.

One of the goals of this exercise was to enable developers to try this solution out on their own with cheap off the shelf OBD devices, hence your Phone itself is used as the Field gateway here and used to send the data collected from the OBD device to the Azure IOT Hub through the MyDriving mobile application. To find the right device for your car, take a look at our getting started article here.

Powering the backend with Azure

Within the backend—the heart and soul of MyDriving—we sought to showcase how multiple Azure Services combine into a meaningful whole without the need to write a lot of code or build such services from scratch. We built the backend primarily through the configuration and interconnection of services like IoT Hub, Stream Analytics, SQL databases, HDInsight, Machine Leaning, and App Services, along with external services like Power BI.

We also wanted the design to be extensible so that you could customize it for additional scenarios that are not included with MyDriving. An example of this in MyDriving is a micro service that does a VIN lookup for a vehicle. The following architecture diagram gives you a complete view of the MyDriving solution. The Azure Services you see here what you’ll get when you run the ARM template in your own Azure account as described in the Getting Started guide.

Mobile Apps for iOS, Android and Universal Windows Platform

While it is possible to develop a native app for each platform individually and deliver a great user experience, the costs of doing so can be prohibitive both in terms of time to market and total cost of ownership across the app’s lifetime. We choose to build the mobile apps part of the solution with our Xamarin platform.

Xamarin enables you to build native iOS and Android applications with C# and .NET with components that provide full access to platform APIs. Furthermore, we were able to share a significant amount of code (over 70%) between iOS, Android and Windows versions of the app using portable class libraries. Our reference guide (Chapter 3) gives a detailed overview of how we went about structuring our code for maximum reuse and the various components and technologies used to deliver the mobile experience. For a detailed overview of the end user scenarios available in the mobile apps, refer to our getting started guide here.

Mobile DevOps

While building the MyDriving solution, we utilized a rapid DevOps cycle to build, test and distribute the app. Furthermore, we were able to monitor usage, get crash logs and verbatim feedback from the users, and use that insight to better plan and execute future developmental cycles. We set up builds and testing on Visual Studio Team Services for continuous integration. This means that every code commit in our repository hosted in GitHub, triggered a build for all platforms and runs tests on each. The results of all the this is shown on the project dashboard below.

When the build is successful, tests are executed for iOS and Android using Xamarin Test Cloud enables automatic mobile application testing on thousands of mobile devices. When the app packages successfully pass all tests, with the HockeyApp plugin for Visual Studio Team Services, it’s a simple matter to send the built app packages that has passed its to tests to HockeyApp for distribution to testers. The app itself is instrumented to gather and report both user feedback and telemetry using the HockeySDK.

Try out MyDriving

Over $6 trillions dollars will be spent on IoT solutions over the next 4-5 years. The total revenue across all app stores is estimated to reach $100 billion dollars. The opportunity is amazing – but even if you’re not enticed by the business – it’s really fun to play with gadgets!

We want you all to go and try this solution out. We hope you will be pleasantly surprised by how easy it is get started on building your own IoT and Mobile solutions. To recap, here are some resources that will get you started on trying out and building your own solution.

We want to hear from you!

We created MyDriving to help jumpstart your own Azure IOT and Mobile solutions, and we want to hear from your about your experience. Let us know if you run into difficulties or challenges, or if you have any other suggestions for improving MyDriving. Within the MyDriving Mobile app, you can use the built-in HockeyApp feedback mechanism.

On iOS and Android just give your phone a shake, or use the Feedback menu command in Settings. You can also file an issue on GitHub or leave a comment on this post or our getting started documentation.