Netduino Emulator
Ok lets get this over… I love this little device!!!
Now lets get down to what this post is really about. First head on over to the Netduino website and read about the capabilities of the device and how you program it. If you are a .Net programmer you are in for a treat! But wait you don’t have a Netduino and you are itching to get started, should you pay for overnight shipping and get it the next day! I am happy to say no you don’t have to fork out the extra bucks and wait for the device to hit your doorstep before you can get started. Emulation is a key component of the .Net Micro Framework and this post is going to show you how you get started without having the hardware.
Pre-requisites
Head on over to the Netduino Downloads page for the links to everything you will need to get set up. If you already have Visual Studio 2010 you can skip the step for installing Visual Studio 2010 Express.
Why use Emulation?
The Netduino is very easy to deploy to and debug your code physically on the device so why would you even want to use an emulator instead of the actual device? Well there are a few reasons:
- You don't have a Netduino
- Repeatedly deploying to the Netduino can be time consuming
- Repeatedly deploying to the Netduino can potentially reduce the life of the device
- Perhaps you can use Emulation to perform automated unit testing in a build environment?
What is the Emulator going to do?
We are going to start simple for this post to keep it short. The target Netduino application is simply going to cycle through 14 Digital Outputs and toggle them on for 1 second then off. Also the on board push button switch will toggle the onboard LED on and off. The Emulator UI will have a rectangle for every digital output and it will change color based on if the output is high or low. The emulator UI will also have a button that acts as the on board pushbutton.

How are we going to create this Emulator?
I have included everything that is needed in the attached zip file so that it is easy to get this simple emulator up and running. Here are the simple steps that we will do to create the emulator:
- Register my emulator shell so that it becomes available as a Device in a Netduino Project
- Compile the C# Library that contains a WPF View and a View Model that provides the emulation logic
- Copy the C# DLL to a folder that the shell looks at and loads at runtime
- Run an existing Netduino project that toggles the output bits and monitors the on board switch and turns on the on board LED.
Detailed steps
- Unzip the file that is attached to this blog post into a directory of your choice.
- Open the solution (NetduinoEmulator.sln) and compile it
- Create a folder called Extensions in the Application\Shell folder
- Copy the Application\SimpleEmulator\NetduinoEmulator.dll to the Application\ShellExtensions folder
- Run the Netduino.Shell project and press Ok on the message box that pops up.
- Give the emulator a name and press the Register button. This will write a registry entry that is used by any Netduino .Net Micro Framework project. You only have to register the emulator once for a given directory.

- Reload the solution so that the new registry entry will be read.
- Right click on the Netduino.Sample1 project and select properties.
- Select the .Net Micro Framework tab.
- Make sure the Transport is set to Emulator.
- Make sure the Device is set to the Emulator you just registered in step 6 above.

- Run the Netduino.Sample1 project.
- Observe that the Netduino Emulator will open up showing the status of the digital outputs as well as the on board LED. The Sample1.Program will cycle through all the outputs which will turn the rectangles on the emulator green one at a time.

What if I wanted to make my own emulator?
I am not going to go into detail on how to do that in this post as it would make it a little long. But basically you can create a new C# Class Library project and use the Netduino.SimpleEmulator as a model for your new emulator. In a future post I will be showing how to do this step by step. I am also planning on a future +1 post that will show how to build a thermostat emulator.
Conclusion
Using an emulator can be very helpful when trying to build out a Netduino project. The emulator library that I have created is currently very limited and will only support digital input and outputs. I have plans on expanding the emulator as I use it for some of my projects so keep an eye on the source. Also keep in mind you don’t have to use my library at all and there are several resources out there that show how to build emulators for the .Net Micro Framework.
Resources
- Netduino Emulator.zip – Zip file that contains the entire solution for this post
- Caliburn Micro – The framework used to build the emulator UI
- Netduino Emulator Source – The git repository that contains the source to my emulator
- Codeplex Netduino Emulator – Another emulator project on codeplex that looks promising
1 Comment
Music Jobs said
While going through this post I felt that you have done a lot of research on the topic, I appreciate your efforts and glad that I found your blog. Keep posting such informative content.