Getting Started with Netduino. Learn IoT using .NET C#

What is Netduino?

Netduino is an open source hardware platform that runs applications built with the .NET MicroFramework. Applications can be built on Windows (with Visual Studio), or on Mac OS (with Xamarin Studio). Netduino can be used to build nearly any Connected Thing you can dream up.
It’s similar in concept to the Arduino platform, but is generally more powerful and instead of writing applications in C/C++ or Wiring (essentially, C++ without header files), applications are written in C#, which brings powerful, high-level language constructs to the toolbox such as threading, event handling, automatic garbage collection, and more.

Features of Netduino…

  • Netduino is based on the Cortex-M Micro Processor running on .NET Micro Framework v4.3.
  • For development, Windows user will use Visual Studio and Mac user will use Xamarin Studio.
  • Netduino board is packed with IO; including 22 General Purpose Input/output (GPIO) ports, 6 of which support hardware Pulse Width Modulation (PWM) generation, 4 UARTs (serial communication), I2C, and SPI (Serial Peripheral Interface Bus).
  • Netduino allowing programmers to work in C# using Microsoft Visual Studio.
  • Step-by-step debugging can be very useful to trace errors.
  • It’s fully interrupt based and has multi-threading.
  • Using the .Net framework it is quick to write a test program to just try stuff out before writing the proper code.
  • There‘re a very friendly community with a lot of people willing to help out.
  • Do not forget that the NetMF framework is from Microsoft, which is awesomeness. Everyone loves Microsoft!

Software Installation Guideline

First, configure your development environment by installing the necessary software.

Installation for Windows OS

Installation for Mac OS

  • Download and install the latest Visual Studio for Mac or Xamarin Studio
  • Launch Xamarin Studio and install the NETMF plug-in
  • Open the Visual Studio menu and select Extensions. Note, for Xamarin Studio users, the menu item is called Add-ins
  • Select the Gallery Tab
  • In the search box, type MicroFramework

  • Click install and follow the directions
  • Restart Visual Studio/Xamarin Studio.

Lets Build First Application

Visual Studio

  • Open Visual Studio and go to menu File – New – Project.
  • According to your convenience choose Visual C# or Visual Basic and select Micro Framework from Template section and then select Console Application.
  • In Name section, write program name like “LED_Blink_App” or other.
  • Select preferred save location by using Browse Button.

  • Right-click on the References folder in the Solution Explorer and add:(Follow video to know how to add references).
  • Microsoft.Spot.Hardware
  • SecretLabs.NETMF.Hardware
  • SecretLabs.NETMF.Harware.Netduino

Xamarin Studio

  • Launch Xamarin Studio and create a new solution of type C# > MicroFramework > MicroFramework Console Application and name it whatever you want:

  • Double-click on the References folder in the Solution Pad and add :
  • Microsoft.Spot.Hardware
  • SecretLabs.NETMF.Hardware
  • SecretLabs.NETMF.Harware.Netduino

Code Segment

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace LED_Blink
{
    public class Program
    {
        public static void Main()
        {
            OutputPort onboardLED = new OutputPort(Pins.ONBOARD_LED, true);

            while (true)
            {
                onboardLED.Write(false);
                Thread.Sleep(500);
                onboardLED.Write(true);
                Thread.Sleep(500);
            }
        }
    }
}

Deployment

Visual Studio

  • Make sure your Netduino is plugged in.
  • Right-click on the Project Properties item in the Solution Explorer, select .NET Micro Framework on the left, and the under Deployment choose USB and in the Device drop down, choose your Netduino device:

  • Click the Start button in the toolbar to deploy to your device.

The app should deploy and after a moment, the LED should start blinking on the Netduino:

 

Second Article :- Control LED in C# .NET using Netduino

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *