Tuesday, March 8, 2011

How to Erase & Reset the Netduino Plus

This post is a step by step guide to resetting your Netduino plus in case it becomes unresponsive. Is your Netduino plus not responding? Can't deploy a project to the Netduino plus? Can't Debug your project on the Netduino plus? Tonight I tried to run someone's sample project and it caused mine to hang. The White LED and the Blue LED stayed lit and it became completely unresponsive.  Rebooting it did not help, nor could I deploy another project to it to try and fix it. This is how to reset the Netduino plus.
  1. Unplug the Netduino plus from the computer (and an external power supply).
  2. Start MFDeploy.exe Start > Programs > .Net Micro Framework 4.1 > Tools
  3. Change "Device" to "USB". The actual device (pull down will be blank)
  4. Hold down the pushbutton on theNetduino plus (don't let go)
  5. Without letting go of the push button, plug the Netduino plus into the computer
  6. Within 5 seconds... press "Ping" and you should see "Pinging.... TinyBooter". If it says TinyCLR you did not complete everything quick enough so you need to start over.
  7. Quickly press "Erase". Press "OK" to continue. This will erase the Netduino application ONLY. The Netduino plus firmware will not be affected by this procedure.
  8. You should see a dialog box (picture above) "Erasing Deployment Status"
  9. When the dialog box disappears and it has completed the erasing procedure, you can disconnect and reconnect the Netduino plus
  10. You should now be able to deploy another application to the Netduino plus.
If this procedure fails to recover your Netduino plus, you may have to take the drastic measure of erasing and reflashing the firmware.

Saturday, March 5, 2011

Netduino Plus Web Server Hello World

This tutorial will show you how to create a simple Netduino plus web server. The Netduino plus will respond with "Hello World" when we make a HTTP request over it's Ethernet port. This is a step by step how to with all of the code for the project available for download at the end of this post.
  • Let's start by creating a new project. Name it "WebserverHelloWorld"
  • Right click on project name and choose to "Add" > "Add new item"
  • Add new "Class" and name is "WebServer.cs"
  • Here is a very simple version of a web server. It will listen for requests and respond with "Hello World". It will also blink the on-board LED when a web request comes into the Netduino plus.
public class WebServer : IDisposable
        private Socket socket = null;   
        //open connection to onbaord led so we can blink it with every request
        private OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
        public WebServer()
            //Initialize Socket class
            socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            //Request and bind to an IP from DHCP server
            socket.Bind(new IPEndPoint(IPAddress.Any, 80));
            //Debug print our IP address
            //Start listen for web requests

        public void ListenForRequest()
            while (true)
                using (Socket clientSocket = socket.Accept())
                    //Get clients IP
                    IPEndPoint clientIP = clientSocket.RemoteEndPoint as IPEndPoint;
                    EndPoint clientEndPoint = clientSocket.RemoteEndPoint;
                    //int byteCount = cSocket.Available;
                    int bytesReceived = clientSocket.Available;
                    if (bytesReceived > 0)
                        //Get request
                        byte[] buffer = new byte[bytesReceived];
                        int byteCount = clientSocket.Receive(buffer, bytesReceived, SocketFlags.None);
                        string request = new string(Encoding.UTF8.GetChars(buffer));
                        //Compose a response
                        string response = "Hello World";
                        string header = "HTTP/1.0 200 OK\r\nContent-Type: text; charset=utf-8\r\nContent-Length: " + response.Length.ToString() + "\r\nConnection: close\r\n\r\n";
                        clientSocket.Send(Encoding.UTF8.GetBytes(header), header.Length, SocketFlags.None);
                        clientSocket.Send(Encoding.UTF8.GetBytes(response), response.Length, SocketFlags.None);
                        //Blink the onboard LED
        #region IDisposable Members
        public void Dispose()
            if (socket != null)
  • Now add the following code to Program.cs.
public static void Main()
            WebServer webServer = new WebServer();

  • Make your program run on the Netduino and not the emulator by right clicking on your project > "Properties"
  • Select the ".Net Micro Framework" tab and change the following settings.
    • Transport: USB
    • Device: NetduinoPlus_NetduinoPlus
  • Now run the program by pressing F5 or "Debug" > "Start Debugging".
  • In the "Output" the program will write the Netduino plus IP address. If you don't have the "Output" window open, select "View" > "Output" to open it.
  • Now open a web browser and type the Netduino plus IP in the address bar.
  • You should receive back "Hello World" from the Netduino plus.
Here is a video demo of the web server running on the Netduino plus.
Here is the complete source code.

Thursday, March 3, 2011

Simple Netduino plus example

Time for your first Netduino plus project. Let's build a very basic example to make sure everything is working correctly. If you have not installed all the software yet, see my previous blog post on how to setup your development environment.
  • Launch Visual Studio
  • Choose to create a new project
    • Select "Netduino Plus Application" and name the project "NetduinoPlusSimpleExample".
    • Enter the following code in the Main method
      • On line #3 we declare the on-board LED as an output port. The second parameter we set the default value to "false" (low or off).
      • Then we create an infinite loop.
      • Inside the loop on line #6 we write to the on-board LED true (high or on).
      • Line #7 we pause the application for one second
      • Then we turn off the LED for one second.
      • This loop will continue until you reset the Netduino plus or upload another program.
    public static void Main()
                OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
                while (true)

    • Now that we have the program written we are going to upload it to the Netduino. Attach a mini-USB cable to the Netduino plus and plug into a USB port. If you receive a driver error you must confirm or re-install the Netduino drivers.
    • Now we need to tell Visual Studio to run the program on the Netduino plus board and not the emulator. I have not found the emulator to be very useful as it does not display any outputs.
    • Right click on your project "NetduinoPlusSimpleExample" > "Properties"
    • Select the ".Net Micro Framework" tab and change the following settings.
      • Transport: USB
      • Device: NetduinoPlus_NetduinoPlus
    • Save your changes
    • Let's run the program. Select "Debug" > "Run" or F5
    • Here is a video of the program running on my Netduino plus

    • Download the complete project