Arduino, Netduino Plus and XBee Radio

I just received two XBee wireless modems with an Arduino shield and an USB adapter board. I bought all these parts from I followed the instructions from the Lady Ada website to configure both modems so they can talk to each other.

Once I finished soldering the XBee shield stackable headers I tried the simple “serial echo sample” from the Sparkfun website. I modified it to turn a LED on and off depending on the data received.

void setup() {
  pinMode(13, OUTPUT);

void loop() {
  if (Serial.available()) {
    char c = (char);
    if(c == 'h')
    if(c == 'l')

I connected an XBee board to the USB adapter connected to my computer and the other on the Arduino mocro-controller powered by a 9V battery. No mater where I hided the Arduino board in my house, the communication between both XBee modems was perfect.

I then decided to give it a try using my new Netduino Plus. I replicated the exact same behavior as on the Arduino to compare both platforms. It took me less then 30 minutes to port the code to the Netduino Plus.

using System;
using System.Text;
using System.IO.Ports;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

namespace NetduinoPlusXbeeEcho
    public class Program
        private static bool pin13Value;
        private static OutputPort pin13 = new OutputPort(Pins.GPIO_PIN_D13, false);

        public static void Main()
            byte[] buffer = new byte[32];

            SerialPort port = new SerialPort("COM1", 19200);
            port.ReadTimeout = 0;

                int count = port.Read(buffer, 0, buffer.Length);
                if(count > 0)
                    char[] chars = Encoding.UTF8.GetChars(buffer);
                    if (chars[0] == 'h')
                        pin13Value = true;
                    if (chars[0] == 'l')
                        pin13Value = false;

                    port.Write(buffer, 0, count);

The code is a bit longer but it has more to do with the structure of the program than the complexity of the code. The Netduino Plus has a direct advantage over the Arduino because it can connect to the net through itsĀ EthernetĀ port.