Click here to Skip to main content
15,113,131 members
Articles / Internet of Things
Posted 9 Nov 2014


33 bookmarked

Introduction to Netduino Plus 2 with examples

Rate me:
Please Sign up or sign in to vote.
4.98/5 (24 votes)
10 Nov 2014CPOL10 min read
This is an article in effort to share my learning about Netduino Plus 2 with the examples.


This article takes us through our first steps with Netduino Programming. The examples are simple and are for absolute beginners.

This was my first encounter with the Netduino and I am very excited about exploring more about this little wonder, especially I am excited that the programming language is C# and not Python :)

Below are the sections in the article


Article about the IoT overview linked below may serve as a good introduction to what the IoT is and its uses.

Internet of things - Overview

What is Netduino ?

If you already know about Arduino then the answer to this question is quite simple. It’s an Arduino programmable in.Net. Otherwise, Netduino is a prototyping platform based on the .Net Micro Framework. It uses a 32-bit ARM microcontroller and compatible with most of the Arduino shields.

Netduino has 5 different models namely


Netduino Plus

Netduino Plus 2

Netduino Mini

Netduino Go

Below is the side by side comparison chart for all the top 3 models.

Components and features Netduino Plus Netduino Plus 2 Netduino Go
processor and memory microcontroller STMicro STM32F2 STMicro STM32F4 STMicro STM32F4
speed 120 MHz (Cortex-M3) 168 MHz (Cortex-M4) 168 MHz (Cortex-M4)
code storage 192 KB 384 KB 384 KB
ram 60 KB 100+ KB 100+ KB
operating system .NET Micro Framework 4.2 (or 4.3) .NET Micro Framework 4.2 (or 4.3) .NET Micro Framework 4.2
input and output networking ethernet: 10 mbps ethernet: 10 mbps add-on: ethernet gobus module
arduino shield compatibility works with most arduino shields works with most arduino shields add-on: shield base gobus module
(some require .net mf drivers) (some require .net mf drivers)
digital i/o 20 gpio, 6 pwm, 2 uart, i2c, spi 22 gpio, 6 pwm, 4 uart, i2c, spi add-on: gobus i/o modules
(gpio, pwm, uart, spi, and more)
analog inputs 6 adc channels (12-bit) 6 adc channels (12-bit) add-on: analog gobus modules
storage micro sd (up to 2 gb) micro sd (up to 2 gb) add-on: sd card gobus module
gobus ports none none 8 gobus ports
environmental operating temperature 0 - 70 °C (32 - 158 °F) 0 - 70 °C (32 - 158 °F) 0 - 70 °C (32 - 158 °F)
rohs rohs compliant rohs compliant rohs compliant

Netduino Plus 2

We are going to looks at Netduino Plus 2 in depth and also use the same for our examples here today. Below is a quick diagram of the Netduino Plus 2 board with some marking about the ports and pins.

Netduino was a incremenatal version of the Netduino Plus and it has 4 times more speed than the Netduino plus, this is 168 MHz instead of 48 MHz, also more code space and RAM making it the most powerful Netuino in the lineup as of now.

The board contains several parts and below are the descriptions for some of them:


The Atmel ARM processor is the main part and it contains the RAM and code space that is used by the app. The pins are wired into the blue pin headers along the side of the board. The pins are used to connect to other components that are external and also to the shields. Below is the picture of the processor.

Analog Input:

There are 6 analog input pin headers that could be used to read any analog sensors measuring any of the below things and more

  • Humidity
  • Temperature
  • Light
  • Pressure/force
  • Motion

In addition to being analog pins these can also act as Digital I/O pins.

Below is a quick diagram pointing out the analog pins on the board.

Digital I/O :

The Digital Input Ouput pins are the pin headers which can process digital signals as Inputs or Outputs.

  • These are 14 in number
  • These can be plugged into on/off sensors like push buttons, switches, on/off sensors etc.
  • The output s like LEDs, relay and switches can also be plugged into these headers and programmed
  • The Digital Input Output headers are capable of communicating using standard protocols like I2C, SPI, UART[Serial]
  • The Digital Input Output headers are also used to send a pulse of electricity as output to change the speed of a motor, intensity of light and etc.

Below is a quick diagram pointing out the Digital I/O pins on the board.


The Netduino Plus 2 has a Ethernet jacka enabling us to connect the unit to the network which could be a local network or The internet. Connecting to Internet opens up a whole new window of features like reading data from remote servers or posting data from the connected sensors and devices to the internet. This will enable us to build the internet of things using the Netduino.


This version of the adds MicroSD slot which can be used to insert a MicroSD card. The card can persit data that can be used by the Netduino or the Netduino can also write data to the card for local storage. We can even stored compiled programs on the card which can then be executed by the Netduino.


There are two type of LED’s on the board .

The White LED lights up when the board is powered up and acts as a power indicator.

The other LED which is blue is user LED and can be controlled from the program running on the Netduino.


The Netduino requires voltage from 7.5V to 12V with the plug having a center positive pole. The power can be supplied using a AC-to-DC adapter with 5.5mm by 2.1mm outer/inner plug.

In case we use a center pole negative plug the board is protected by integrated reverse voltage protection fuse. The fuse will auto reset upon cooling.


  • This port has several functions on the board
  • The MicroUSB port connects the Netduino board to a computer using the USB to MicroUSB cable
  • This port can also supply power to the board
  • Used to deploy apps on to the netduino board and also debug them interactively
  • Many times this also can be used to connect input devices like keyboard and mouse


This is the small golden dot at the end of digital I/O pin headers. This is used to erase the Netduino completely and to start over from scratch. This was made in order make this board Hacker friendly so the Netduino can be repurposed as an ARM microcontroller development board. The erase function is activated by connecting a wire between the 3.3v pin and the erase pad for a few seconds.

Once the erase is complete we can even install new operating systems on the Netduino or write C++ code on to the board or flash from scratch again.


  • The pushbutton on the board acts the restart button for the Netduino by default.
  • Usually used to restart the actions of the deployed app.
  • The push button can also be accessed as an input from the program and take actions when pressed.
  • The push button helps in entering the board into the programming mode for firmware updates during the boot by holding it down through the boot.

Visual studio IDE for Netduino

As we already know Netduino apps are written using C# language and many of us are already familiar with the famouse Visual studio IDE for development from Microsoft. The same Visual studio IDE can be used to create, run and debug the Netduino apps .

Assuming we already have a installed visual studio lets look at other components that needs to be installed in order to start programming Netduino apps.

  • .Net microframework SDK

    • This framework enables us to write managed C# applications for the resource constrained embedded systems like Netduino using the Visual Studio. This framework is also a open source by Microsoft open technologies
    • Below is an excerpt from the Microsoft site explaining about what this framework is about.

“What is .NET Micro Framework used for?

.NET Micro Framework can be used to build embedded devices on resourced constrained devices running on a microcontroller with just a few hundred kilobytes of RAM and storage. Developers can use Visual Studio, C# and .NET knowledge to quickly write embedded applications without having to worry about the intricacies of each microcontroller. A developer can purchase a .NET Micro Framework compatible board, connect the board to their development computer running Visual Studio and start writing applications for physical devices. No extensive knowledge of hardware design is needed to get started writing code for physical devices.”

  • Installing .NetMF

    • Step1: Download the latest version .NetMF from
    • Step2: Extract the file from the zip into a local folder
    • Step3: Execute the msi file in the extracted folder to start installation
    • Step4:Read through the terms and conditions
    • Step5:Select the typical installation type
    • Step6: Installation completed and you can click the finish button.
    • Below is a gif of the above steps.
  • Netduino Software development Kit

    • Download the Netduino Software development kit(SDK) from
    • Choose 64 bit or 32 bit depending on your configuration
    • Run the downloaded exe
    • Complete the installation with the type as “typical”
    • Below is the Gif image for the process

Example 1: Write a helloworld program to blink the LED on the Netduino board.

  • Create a new project by selecting .Net MIcroframework as the project type.Net MIcroframework as the project type.
  • Once you have created the project you should see program.cs which contains the main method.
  • Type the below code to declare the output port. Since the output port for would be the LED on board we shall write the code as.
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
  • Now that we have the output port declared lets write to that port. The LED state takes a Boolean value, when set to true the LED is turned on and when set to false it is turned off. We shall put the code to toggle the state every 200 ms inside a infinite while loop.
while (true)




  • Now let’s connect the Netduino to the power source and also connect the micro USB to out laptop so that we can deploy the code we wrote. Below is how it look

  • Now select your project properties -> .Net Micro Framework tab -> set the transport to USB . This will deploy the code into the connected Netduino and also run it on the board.​​
  • Now we are all set to deploy and run the code. Click the run button on the IDE and below is what you would see on the board.

Congratulations!! You have successfully executed your Hello World program on the Netduino.

Example 2: Disco LED’s

Let us try building some LED’s which will light up in a particular sequence defined in our program. Let’s take 8 LED’s.

  1. Create a Project in the Visual studio.
  2. Declare a global variable array of Output ports to hold our 8 LEDs
static OutputPort[] leds = new OutputPort[8];  
  1. Now assign the pins to each Output port in the array
leds[0] = new OutputPort(Pins.GPIO_PIN_D2, false);

leds[1] = new OutputPort(Pins.GPIO_PIN_D3, false);

leds[2] = new OutputPort(Pins.GPIO_PIN_D4, false);

leds[3] = new OutputPort(Pins.GPIO_PIN_D5, false);

leds[4] = new OutputPort(Pins.GPIO_PIN_D6, false);

leds[5] = new OutputPort(Pins.GPIO_PIN_D7, false);

leds[6] = new OutputPort(Pins.GPIO_PIN_D8, false);

leds[7] = new OutputPort(Pins.GPIO_PIN_D9, false);
  1. Write a method to turn one LED at a time in sequence.
static void oneOnAtATime()


            int delayTime = 100;                        

for (int i = 0; i <= 7; i++)


                int offLED = i - 1;        

                if (i == 0)                

                offLED = 7;            






  1. Call the method inside the main with an infinite loop
while (true)



  1. Now let us prepare the circuit.
    1. We need the below things to set this up.

Resistors – 8 (300 to 500 ohms)

LED – 8



  1. Connect the positive pin of the breadboard to the 5V pin of Netduino
  2. Connect the negative pin of the breadboard to the GND pin of Netduino
  3. Now connect 8 resistors from the negative pin to the horizontal rows of the bread board
  4. Now connect 8 LED cathodes [Short leg] to the same row where resistor ends and the long leg to the next row.
  5. Connect 8 wires from same rows as the long legs of LED’s to pins 2 to 9.
  6. The circuit should look like below.

  1. Now lets run the code , below is what you should expect.

I really wanted to write more complex examples and explain them but its already late Sunday evening. But I will leave you all to do you experiments with the Netduino and promise to add more examples soon.

Take care and have a nice ride with the Netduino. :)


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
United States United States
No Biography provided

Comments and Discussions

-- There are no messages in this forum --