Building Netduino-based HID Sensors for WinRT

In the March issue of MSDN Magazine, Microsoft’s Donn Morse wrote a feature titled “Building a Netduino-based HID Sensor for WinRT." The feature looks at how developers can take advantage of the new API in the Windows Runtime to let developers write Windows Store apps for low-cost devices using JavaScript, Visual Basic, C# or C++. More recently, Donn worked with Channel 9 at Microsoft to publish a pair of videos about working with HID devices. Building a HID Motion Sensor and Supporting Both Digital and Analog Devices with Microsoft’s HID Platform. I caught up with Donn last month to discuss his article and the videos.

What motivated you to write your March feature article "Building a Netduino-based HID Sensor for WinRT?"
There are two general categories of sensors in the hobbyist or maker sphere: digital and analog. I’d written an earlier sample on the MSDN samples gallery demonstrating the integration of a digital sensor. So, in the March article, I wanted to describe how a developer could build an analog-based device and render real-time data in their store app.

As you you've noted, a great deal of activity among hobbyists and academics is currently based on open source tooling and software. What benefits does the new HID API in WinRT offer to this community?
The new HID API lets a maker, industrial engineer, or hobbyist integrate their device with the Windows platform. Since this API supports the Windows Runtime, they can integrate their HID device with hand-held tablets, in addition to the large universe of notebooks, laptops and desktop machines. And, because the API supports WinRT, a developer or maker can choose their language: Javascript, VB, C# or C++.

You may have noticed that our Windows Azure Insider column in the same issue walks through a Windows Azure implementation that includes programming an Arduino device that executes commands sent remotely by mobile clients. Coincidence? Or does this simply reflect the reality that there are a lot of cool applications to be built around low-cost, Arduino-type hardware?
At first glance, I think the HID API for WinRT and the Azure Service Bus are complementary. Let’s say I’m a fitness device manufacturer creating a competitor to the FitBit or Nike Fuel Band. I’ll want a store app so that the user can configure their device and, likely, so that they can collect data after each workout (or at the end of each day). But I may also want to create an online community for my users, where they can opt-in and compare workouts, status, etc. For this community, the Azure solution appears to be a viable option.

4. Were there any specific issues or challenges you had to work around in the course of your article?
There were two challenges that come to mind. First, the LM35 requires a very “clean” input voltage, but the voltage source on the Netduino contains a bit of noise. As a result, I needed to incorporate software filtering in the firmware, where I maintain a running average of readings.

The second has to do with the sparse documentation for the .NET Micro Framework, which isn’t as robust yet as, say, Microsoft’s .NET Framework. To work around this, I relied heavily on the Netduino forums and the experience and knowledge of the makers and developers there.

5. What advice would you give developers interested in getting started with app dev around Arduino-type devices? Are there any common misconceptions that should be avoided?
I believe they’ll find Netduino devices to be reasonably priced and well designed. In addition, the Netduino forums are a great source if ideas for projects as well as input and advice from other developers. And, you can’t beat being able to author firmware in C# with a free version of Visual Studio Express.

You just published a video on Channel 9 highlighting Microsoft's HID platform and WinRT API support for analog and digital Netduino-based devices. How widely known is the new support in WinRT for HID devices? What kinds of opportunities does it create for developers?
Great question: Our first video, for the motion-sensor appeared on Channel 9 in late January and has had over 10,000 views. The second video, for both projects appeared a day ago and has generated over 2,400 views. So, I believe we’re getting the word out.

In terms of opportunities, these projects give the Maker, the academic and the industrial engineer a sense of what they can do with a programmable microcontroller like the Netduino and one or more input devices. The first project, based on a motion sensor, shows the power of combining multiple APIs in a Windows Store app. This sample uses the HID WinRT API to monitor the PIR sensor and then, with minimum code, uses the media capture API to capture video using the camera on a tablet or PC.

Prior to the HID WinRT API, developers needed to pound out a COM/Win32 app in C++ to interact with a HID device. But, using the new WinRT API, they can write far less code in the language of their choice, be it Javascript, VB, C#, etc.