Visual Studio Toolbox

Programming the Internet of Things with Visual Studio

Internet-connected devices in every home and Windows on every device? We're getting there, and you can develop for most of these IoT devices in Visual Studio.

Computers rule everything around me. It seems like every electronic device today features not only computing power, but wireless connectivity, as well. Thermostats, security cameras, locks and lights, vacuum cleaners ... even toasters. All containing tiny computers, and all interconnected via the Internet.

The "Internet of Things" (IoT) is a bit of a loaded phrase these days. Many of these devices include the ability to access the Internet -- it opens a world of possibilities, but also a world of new security threats -- hence, the _Internet_ of things. Generally speaking, however, what I want to address here is the ability to program a huge and growing world of lightweight computing environments.

Once upon a time these were specialized embedded processors requiring electronics know-how and proprietary languages. These days getting started can be as easy as picking up an Arduino and writing a few lines of script. But you can do oh so much more ....

Target Environments
There's a huge and growing universe of off-the-shelf, programmable, networkable microcontroller devices available now. At a very low level you have a variety of simple 16- and 32-bit devices from a variety of traditional chip makers like Texas Instruments. (I played a bit with the SensorTag development kit and it's a lot of fun, making me think the Watch DevPack might be a great learning toolset, too.)

Some better-known microcontroller devices include Arduino, BeagleBoard and Raspberry Pi. These environments all have extensive community support and are ready to plug in to a huge number of ready-made external sensors, motors, servos and whatever else you might imagine. Adafruit, the electronics learning superstore founded by Limor "Ladyada" Fried, provides all sorts of peripherals for these boards, along with its own line of lightweight Feather development boards.

Tibbo is another company providing devices for the "Industrial Internet of Things." It offers a full menu of microcontroller devices from the Tibbo Project System combining Tibbit blocks for dedicated I/O functions into tailored automation controller systems, down to individual programmable serial controllers, self-contained IoT boards and embedded IoT modules (see Figure 1). Tibbo uses its own BASIC and C embedded programming languages and provides a dedicated Tibbo IDE for Windows-based development.

[Click on image for larger view.] Figure 1. Combine Tibbit Blocks into Custom IoT Controller Systems

For robotics, aside from the controllers I've already mentioned, there are the TRIK robotics design kits that include controllers and the supporting mechanical parts to build the robots themselves.

There are many other robotics offerings, but I always come back to LEGO Mindstorms. It's not just a toy; it's a very sophisticated robotics toolset that gives you many options for programming and can be plugged in to a huge number of LEGO or third-party parts. And many people probably don't know this, but the MINDSTORMS EV3 LEGO Education products are available to anyone, not just schools and homeschoolers.

Let's not forget Amazon's All-New AWS IoT Button (2nd Generation). It's not just for buying dish soap. The new buttons have full development APIs and deep hooks into Amazon Web Services resources.

The most interesting universe of devices for developers familiar with the Microsoft .NET Framework and Visual Studio may be Windows 10 IoT Core-compatible environments. These are x86 and ARM-powered devices that support Universal Windows Platform (UWP) apps written in a variety of languages including C#, Visual Basic, Python and Node.js/JavaScript. Windows 10 IoT core supports devices including Raspberry Pi, Arrow DragonBoard 410C, Intel Joule and Compute Stick and MinnowBoard. There are also interesting product platforms, such as the Askey TurboMate E1 wearable.

Visual Studio Extensions
While most of the target devices I just mentioned have their own IDEs -- and pretty good ones at that -- there are a few great extensions that let you work from the familiar Visual Studio environment and its extensive coding and testing tools.

Microsoft's own Visual C++ for Linux Development and Visual C++ for IoT Development are good extensions to start with if you're doing low-level development work on Linux-based micro-environments. On the downside, the latest versions still only support Visual Studio 2015. On the upside, development and issue support are active on their GitHub repositories and it seems a Visual Studio 2017 update is on its way.

If you're working on C++ code for devices with Intel processors, take a look at Intel System Studio, which is provided in versions tailored for Linux, Windows, and Android-based devices, microcontroller-based devices, VxWorks for Wind River, and FreeBSD-based devices.

Visual Micro provides the Arduino IDE for Visual Studio and Arduino GDB for Visual Micro 2017 for C++ development, testing and deployment on Arduino and similar devices (see Figure 2). Visual Micro tools ship with project templates, built-in configurations that match the Arduino IDE, and the ability to use Visual Studio debugging tools, such as breakpoints, watch windows and more.

[Click on image for larger view.] Figure 2. Debugging Arduino Projects with Visual Micro

TRIK-Upload is a simple Visual Studio extension for remote deployment and communication with microcontroller environments like Raspberry Pi devices and TRIK robotics controllers. It requires Mono on the remote device and an SSH connection to the device and enables interacting with the remote microcontroller like any Linux environment.

Finally, Microsoft's Windows IoT Core Project Templates for Visual Studio 2017 provide UWP templates for writing Windows IoT Core applications in compatible environments. Templates are provided for Visual Basic, C#, C++ and JavaScript development, as well as Arduino Wiring sketch templates for running sketch code on any IoT Core devices.

Speaking of Windows and Arduino, check out Windows Remote Arduino, a remote Arduino Wiring interface to control an actual Arduino compatible device from a UWP app (see Figure 3).

[Click on image for larger view.] Figure 3. Windows IoT Core Includes Templates for Running Arduino Sketches on Other Devices

Azure IoT
Networked devices are nice, but they're better if you have a cloud-based control application to configure your IoT devices, help them communicate and gather their data. Azure IoT Suite provides easily deployed Microsoft Azure applications to handle the networked aspects of your smart devices and connect them with your back-end applications.

The Windows IoT Core Project Templates for Visual Studio are your first resource for building Windows IoT Core projects. You'll also want to take a look at the Connected Service for Azure IoT Hub extension, which enables you to connect to and interact with Azure IoT services directly from Visual Studio.

IoT Hub Explorer is a Node-based, command-line toolset for testing and managing Azure IoT Hub services. You can configure IoT device identities, send and receive messages and files, and generally keep track of your Azure IoT Hub services and communication. For learning, prototyping and testing, you can use IoT Hub Explorer to simulate a device connected to your Azure IoT Hub environment.

Azure IoT Protocol Gateway gives you a framework for custom protocol translation between your IoT devices and the Azure IoT Hub services. The framework uses the MQTT machine-to-machine publish/subscribe messaging transport designed specifically for lightweight IoT device communication for protocol adaptation. It enables custom authentication, message transformations, compression/decompression and encryption/decryption of message traffic between your devices and Azure IoT Hub.

Azure IoT Edge provides SDKs and service binding modules that help you build application gateways for your IoT devices using Azure IoT Hub. Libraries and modules are provided for the .NET Framework, .NET Core, C, Java and Node.js. The code repositories have great sample projects, including creating simulated devices or support for real devices using the TI SensorTag. You'll also find an extensive collection of pre-built modules, community developed modules, and built-in support for module installation via Maven, npm, and NuGet.

Once your Azure IoT Hub and application gateways are set up, use the Azure IoT Remote Monitoring preconfigured solution to set up management and reporting for data ingest, device identity, solution management and more.

If you want to roll your own solution, download the entire repository of Azure IoT SDKs from GitHub, or individual SDKs for Arduino, C, , Node.js, Python and more, available from the Microsoft Azure code repositories on GitHub.

AllJoyn is an open source, common protocol intended to simplify IoT device discovery and communication. Ongoing AllJoyn protocol development is overseen by the AllSeen Alliance, of which Microsoft is a member, and which has folded in the work of the former Open Connectivity Foundation's' IoTivity protocol work. Windows 10 includes native AllJoyn protocol support built in.

To simplify IoT development using the AllJoyn protocol, Microsoft has shipped the AllJoyn Device System Bridge Template for Visual Studio 2017 and Visual Studio 2015. These templates simplify the task of creating virtual proxies between the existing device interfaces of non-AllJoyn devices and the AllJoyn bus.

AllJoyn Studio adds AllJoyn project templates and code generation to Visual Studio for general AllJoyn IoT development.

Lego MindStorms
Finally, let's not forget Lego Mindstorms. The big news recently was the new ability to Create Lego Mindstorms Robots with Swift playgrounds.

However, .NET Framework support for Mindstorms has been around for a lot longer. MonoBrick EV3 Firmware, using Mono, is a replacement Mindstorms firmware that lets you program and debug using Visual Studio and the .NET Framework. Plus, it supports almost all of the default Mindstorms capabilities.

MonoBrick Communication Library is a communication library written in C# that works with the standard firmware on both the EV3 and NXT.

You can even run ASP.NET 5 on Lego Mindstorms EV3 using ev3dev. Sure. Why not?

comments powered by Disqus
Upcoming Events

.NET Insight

Sign up for our newsletter.

I agree to this site's Privacy Policy.