Windows Remote Arduino, Yun WiFi and NetworkSerial

Windows Remote Arduino, Yun WiFi and NetworkSerial © GPL3+

Create Windows Universal Apps to control your Arduino Yun over WiFi with Windows Remote Arduino

  • 10 respects

Components and supplies

Apps and online services

About this project


Few days back, the Windows IOT challenge dropped in my twitter feed. While the challenge was very interesting, after poking around the web, I quickly realized that there is no Windows IoT Core for Arduino. Hopefully, sometime soon, Microsoft and Arduino will give us one. 

Until then we will have to make do with Windows Remote Arduino which is essentially a Firmata client library wrapped in a Windows Runtime Component. I had both an Arduino Uno and an Arduino Yun and i wanted to check out the Windows Remote Arduino interfacing.

So when I started looking around i noticed that while there are lot of articles on using the Arduino Uno and Bluetooth there is not much starter material on using the Arduino Yun over the Wifi. And since i didn't want to buy a Bluetooth or Ethernet shields, i set out out to make it work using Arduino Yun WiFi.

Arduino Yun Serial Port Primer

I am assuming you are familiar with your Arduino Yun. If not, please refer to this

Basically its comprised of two sections: The ATMega32u4 Arduino environment and the Linino AR9331 Linux (OpenWrt) environment that interfaces the WiFi.

These two are connected through hardware serial. Accessed through Serial1 when writing Arduino Sketch for Yun and available on the Linux environment as "/dev/ttyATH0"

There is also the USB programming chip that we normally use to connect the Arduino to the PC. Accessed through "Serial" when writing Arduino code and available on the Windows as COM port.

To enable Windows Remote Arduino to control the Yun over WiFi, we need to do the following.

1. Expose the Yun Serial Port (/dev/ttyATH0) over TCP

2. Load modified StandardFirmata.ino to Yun that uses Serial1.

3. Connect to Yun using NetworkSerial class in WRA library

Expose the Yun Serial Port over TCP

If you were familiar with connecting to Yun over Putty go to step 4.

1. Install WinSCP and Putty. Both are available here. You will need this to access the Linux terminal on Yun from your Windows 10

2. Optional: Expand the disc space on Yun if you have not already done so. (I would recommend expanding)

3. Run Putty and connect to the Yun using the IP address of the Yun using SSH. (You can see the IP Address on "Tools> Ports" in the Arduino IDE under Network ports)

4. Update OPKG package manager and install "ser2net". Make sure update happens first as this will allow the package manager to load the list of available packages in to Yun's memory. Ser2net is a Serial Port to TCP port proxy.

~# opkg update
~# opkg install ser2net

5. Configure Ser2net by editing the config file at : /etc/ser2net.conf

You can comment out everything in the ser2net.conf file and add this line in the end:
5055 is the TCP port. You can change it to whatever un-allocated port number you fancy.
raw -- represents that it should be raw data
0 -- timeout disabled
/dev/ttyATH0 -- The tty serial port on the Linux side that we are proxying over TCP
115200 -- The baud rate. 115200 is the highest baud rate that Yun could reliably work on.
You can edit it either by using vi editor if you are familiar with Linux or by using WinSCP to retrieve the file to windows and edit/save from there. Following screenshots are for editing the file on windows using Winscp.

6. You can always run "ser2net" from the console to make it use the config file and proxy the serial port. If you need the Ser2net is always started when the Yun is powered on, then "ser2net" should be added to /etc/rc.local file.. 

Open the file and add "ser2net" line before the exit 0 line.

7. By Default Arduino Yun attaches a serial console to this port. We need to disable this serial console so that it doesn't interfere whenever Windows Remote Arduino network serial connection is made. Note that this will disable Yun Bridge Library. Who cares? We have WRA now. Any way you can bring it back whenever you want.

For disabling serial console, edit the this file: /etc/inittab and comment out the following line by adding "#" in front.
ttyATH0::askfirst:/bin/ash --login

With all this done, reboot the Arduino Yun. To verify if everything is good, you can enable telnet client on the Windows 10 and connect to the ip address of Yun and the port that was configured. Example :

telnet 5055

If the connection is successfully made, then the yun is now ready for next step. Close telnet.

Load modified StandardFirmata.ino to Yun

We need to make 2 modifications to ensure that the Yun can communicate over WiFi.

1. The standardfirmata.ino on Yun uses "Serial" by default. We need to change it to use the "Serial1" stream.
2. Since the Yun is comprised of two distinct sections, when the Yun is started, the sketch on the Arduino part will start and run even before linux side is fully booted. During the linux boot processes if it receives any unexpected signals over the Serial1, the linux boot process will be interrupted. (tell tale sign of this issue: no arduino yun ip address showing up on the ports list in Arduino IDE.) To avoid this, we need to ensure that our sketch waits until the process is complete and the Serial1 becomes available without any issue. You can read all about this in this thread.

The following update is in the setup() method of the StandardFirmata.ino..

// to use a port other than Serial, such as Serial1 on an Arduino Leonardo or Mega,
// Call begin(baud) on the alternate serial port and pass it to Firmata to begin like this:
//this code is to delay the firmata begin process to avoid interference with the boot process of Yun Linux.
do {
while (Serial1.available() > 0) {;
} while (Serial1.available()>0);
// then comment out or remove lines 701 - 704 below
// while (!Serial) {
// ; // wait for serial port to connect. Only needed for ATmega32u4-based boards (Leonardo, etc).
// }
A modified StandardFirmatYun.ino is available at Github with these two changes. (This file will come in handy if you want to run nodejs scripts right on the Yun to interface with the arduino side.)
Load the sketch to Yun and we are ready to test if everything is good.

Testing with Windows Remote Arduino Experience

1. If you want to check out it truly works over WiFi, run the Arduino yun from a wall wart or battery without connecting it to the PC.

2. Get the Windows Remote Arduino Experience Universal Windows App from the App Store. Launch it and choose the Connection as "Network", Baud rate of 115200, provide ip address of the yun and the port number (5055 in this sample). Click Connect. If everything is good, you should be connected and see a list of available Digital Pins. Scroll down to Pin 13. This PIN is connected on the Yun to onboard LED. (red). Make sure its on output and toggle the value. You should see the LED toggling on the arduino. Below are the screenshots and the video.

Yun at the bottom connected to battery..Red LED reacts to changes in WRA

Code for connecting to the Yun over WiFi through Universal Windows App

With this setup in place,  when you create a Universal Windows App, you can interface it with the Yun by using the "NetworkSerial" connection.

1. Create a blank Windows Universal App project in VS 2015 ( I am assuming you have a Windows 10 with all the necessary software needed to write a Windows Universal App... Click here for more details..)
2. use Nuget package manager to add WRA to your project.

install-package 'windows-remote-arduino'

3. Ensure Internet client server capability is enabled by editing the Package.appxmanifest file.

<Capability Name="internetClientServer" />

4. In the mainpage.xaml.cs add the following code for creating a NetworkSerial Connection and interacting with the Arduino GPIO using Windows Remote Arduino library.

public MainPage()
this.InitArduino(); //Init Arduino connection
Microsoft.Maker.RemoteWiring. RemoteDevice arduino;
Microsoft.Maker.Serial. NetworkSerial netWorkSerial;
public void InitArduino()
//Establish a network serial connection. change it to the right IP address and port
netWorkSerial = new Microsoft.Maker.Serial. NetworkSerial(new Windows.Networking.HostName ("" ), 5055);
//Create Arduino Device
arduino = new Microsoft.Maker.RemoteWiring.RemoteDevice (netWorkSerial);
//Attach event handlers
netWorkSerial.ConnectionEstablished += NetWorkSerial_ConnectionEstablished;
netWorkSerial.ConnectionFailed += NetWorkSerial_ConnectionFailed;
//Begin connection
netWorkSerial.begin(115200, Microsoft.Maker.Serial.SerialConfig .SERIAL_8N1);
private void NetWorkSerial_ConnectionEstablished()
arduino.pinMode(13, Microsoft.Maker.RemoteWiring. PinMode.OUTPUT); //Set the pin to output
//turn it to High. The RED LED on Arduino Yun should light up
arduino.digitalWrite(13, Microsoft.Maker.RemoteWiring. PinState.HIGH);
private void NetWorkSerial_ConnectionFailed( string message)
System.Diagnostics. Debug.WriteLine( "Arduino Connection Failed: " + message);

5. Run and check.

Now that my Yun is ready for Windows Remote Arduino over WiFi, I will explore more on what's possible with the combination of Windows 10, Windows Remote Arduino and Yun.


Similar projects you might like

WiFiLamp with FastLED and Windows Remote Arduino

Project tutorial by Mohan Palanisamy

  • 1 comment
  • 18 respects

Windows 8.1 IoT: Windows Remote Arduino and Universal apps

Project tutorial by David Jones

  • 1 comment
  • 9 respects

Windows Remote Arduino

Project tutorial by Team Windows IoT

  • 384 respects

IoT: Windows Remote Arduino and Universal Apps

Project tutorial by David Jones

  • 45 respects

Remote Control Panel for Solar Charger/Inverter

Project showcase by Hannes

  • 20 respects
Add projectSign up / Login