September 7, 2016 2:00 pm

Introducing Arduino Wiring on Windows 10 IoT Core

By / senior software engineer in Windows

Developers targeting Windows 10 IoT Core can use a programming language of their choice. Today, this includes C#, C++, Visual Basic, JavaScript, Python and Node.js, but we’re not stopping there. Arduino Wiring is the latest addition to IoT Core.

Arduino is one of the most popular platforms among makers. Its community has produced a large number of libraries to interface with peripherals such as LED displays, sensors, RFID readers and breakout boards. One of the main drivers for Arduino’s adoption is its simplicity. With Windows 10 IoT Core, you can now create or port Arduino Wiring sketches that will run on supported IoT Core devices, including Raspberry Pi 2, 3 and Minnowboard Max.

Creating your first Arduino Wiring sketch for IoT Core

You can find the detailed steps for creating Arduino wiring sketches in the Arduino Wiring Project Guide. In addition, here is a quick summary:

IMAGE1

  • Upon project creation, a sketch file with the same name and the extension ‘.ino’ will be created and opened by default. The sketch includes a template for Arduino Wiring using a classic hello world LED blinking code. More details about the Arduino Wiring template and required device setup can be found at the Hello Blinky (Wiring) page.

IMAGE2

  • Before deploying, make sure to change the driver on the target device to DMAP. For more details, follow the instructions in the Lightning Setup Guide.
  • Finally, select your remote machine and press F5 to build and deploy your app to your device. Go back to the Arduino Wiring Project Guide for additional guidance.

How does an Arduino Wiring sketch run on an IoT Core device

On an IoT Core device, an Arduino Wiring sketch runs as a background application (headless); i.e. there is no UI visible on an attached monitor. This is similar to running a sketch on an Arduino device such as the Arduino Uno for example. However, you can still debug the sketch as you would any other app under Visual Studio by inserting breakpoints and/or stepping through the code. Additionally, to enable verbose output logging, Serial.print() and Serial.println() have been updated to send their output to Visual Studio’s debug pane when the sketch is running under the debugger (the output will also be sent to the serial pins). The Log() function can be used to output to debug as well. Check the Arduino Wiring Porting guide for more details on using Serial.print*() on IoT Core devices.

Porting an Arduino wiring sketch or library to Windows 10 IoT Core

For many Arduino Wiring sketches, simply copying the source code from the existing one to a new Arduino Wiring project in Visual Studio editor and replacing the pin numbers with the ones on your device would suffice.

However, while we have tried to make our implementation as close as possible to other Arduino-based devices, in some cases, a few modifications need to be made to your sketch to make it compatible with the Windows IoT Core OS, the C++ compiler or the board the sketch is running on. The Arduino Wiring Porting Guide covers many of those modifications needed and solutions to problems you may face while porting your sketch.

To use an existing Arduino library, you simply need to copy and add the header (.h) and source file (.cpp) for the library to your project, then reference the header file. Again, most libraries should work with no or very few modifications. However, if you face any issues, please check the Arduino Wiring Porting Guide.

Writing Windows 10 IoT Core specific code

For your scenario, you may want to write code parts that target Windows 10 IoT Core only, but at the same time maintain compatibility with other devices. For that, you can use the _WIN_IOT macro; e.g.:


#ifdef _WIN_IOT
// Windows IoT code only
#else
// Other platforms code
#endif

Arduino Wiring and the Universal Windows Platform (UWP)

Arduino sketches runtime behavior on IoT Core devices is similar to other Arduino devices, with every function implemented to work the same way when interacting with the various controllers. However, Arduino Wiring sketches are also Windows UWP apps and thus can be extended to call any UWP APIs such as networking, storage, Bluetooth, media, security and others; for example, you can communicate with Bluetooth devices, connect to Wi-Fi network or even create a OneNote app using Arduino Wiring.

Additionally, you can wrap your sketch inside a WinRT library and use it in any UWP app, including UI apps. Building Arduino Wiring Libraries guide details the steps needed to create Arduino Wiring based libraries.

Additional Resources:

Here are resources to assist with creating/porting Arduino Wiring apps running on Windows 10 IoT Core:

Also, check out these Arduino Wiring samples:

OneNote Cloud Services Weather Station Stepper Motor
RGB Pixel LCD Text Display DC Motors

Finally, please add your questions/comments below or send your feature requests to the Lightning repository on GitHub.

Get started with Visual Studio.

The Windows team would love to hear your feedback. Please keep the feedback coming using our Windows Developer UserVoice site. If you have a direct bug, please use the Windows Feedback tool built directly into Windows 10.

Updated September 13, 2016 1:39 pm

Join the conversation

  1. Sketch? Wiring App? Explain your jargon first, or use the context Windows Developers prefer, like software, application, schematic, or code. Are you talking about a Clang app? Because that doesn’t look like Visual C++. The way you wrote this, one assumes that Python and Arduio Wiring App are ISO/IEC languages. You seem to be ignoring the standard ARM development libraries propagated by industry leaders like Keil and IAR, but instead are chasing some arcane hobby market. Why would I use that when there are literally millions of established embedded choices used in products right now with decades of testing behind them.

    • Well, these terms are well understood by the intended audience of this post: Arduino coders. Also, there aren’t direct parallels to those concepts for Windows devs, because of how odd Arduino is.

      Maybe don’t get so peeved over things like this?

  2. The Wiring framework does not use .ino files. The Wiring framework uses .pde files which are from the default for the “Processing IDE” which Wiring is based on.

    The free Visual Micro Arduino extension for Visual Studio has used and registered .ino files into Visual Studio for 6 years so this release really conflicts for no good reason.

    The extension .ino was created more recently than the Wiring/Processing system and the letters “ino” are taken from the end of the ArduINO name.

    It seems that IoT core is trying to displace Arduino and Visual Micro from the Microsoft World.

    • Hi Tim,

      This and Visual Micro target two completely different spaces. Our work is about supporting the Arduino Wiring API on Windows 10 IoT Core and not about providing a development tool for Arduino boards. Visual Micro is a great extension for developing code for Arduino devices and we recommend it to people who are interested in using Visual Studio instead of the Arduino IDE.

      The reason that there is a clash with the .INO extension is that this is the extension used for Arduino Sketches. It is an artifact of the extension association model that you can only have one thing associated to a file extension at a time.

      So if you want to use the Arduino Wiring API on Windows 10 IoT Core then installing this will setup Visual Studio to understand Arduino Sketches that you download in the context of a Windows 10 IoT Core app.

      If you want to write code for an Arduino device then you should install Visual Micro.

      Unfortunately if you want to write for both then you’ll need to pick whichever one you spend the most time in and make that the handler for the INO extension in Tools-Options.

      Tony Goodhew,
      Program Manager, Windows IoT Core.

  3. Dear Mahmoud Saleh,

    Thank you for this post!

    I’m trying to wrap an Arduino lib to work with Raspberry Pi3 running windows core IoT, I’ve setup my device to run Windows 10 IoT Core, My PC running MS Win 10 and the VS2015 with the Windows 10 IoT Core Templates Extension; when using C# to run my app on the Pi3 it compiles and run as it should, great options are now available! however, when trying to use the sample above (or any other Arduino samples from https://github.com/mjmeans/ms-iot_samples) I get many errors from the start, for example, the most straight forward error is the:

    // Use GPIO pin 5
    const unsigned int LED_PIN = GPIO5;

    identifier “GPIO5” is undefined at ArduinoWiringApplication1.ino

    so it seems that the template doesn’t recognized some basic constants..

    One more point I must add, I’m using the VisualMicro addin who is uses the *.INO file extensions inside VS2015, is that a problem?

    One last question: is there an MS community forum where this subject is discussed and supported?

    many thanks in advance!
    Best,
    Ram