Playing with Mountaineer Ethernet Mainboard

Posted by Marco Minerva

In these days I’m making some tests with Ethernet Mainboard, a Gadgeteer compatibile mainboard that is produced by the Mountaineer Group.

Mountaineer Ethernet Mainboard

Mountaineer Ethernet Mainboard

Here it is the main characteristics of the mainboard, as described at

  • “Red mainboard” powered via USB
  • 168 MHz STM32F407 microcontroller with 192 KB RAM and 1 MB on-chip Flash
  • 8 MB external Flash, for data logging etc.
  • User-programmable RGB LED and button
  • 8 Gadgeteer sockets plus USB and Ethernet connectors

It is the first Gadgeteer compatible mainboard to include a built-in Ethernet. There is another version of it, called USB Mainboard, with 9 sockets, but it doesn’t have the Ethernet port. The support site contains a Getting Started guide that explains what is needed to write Gadgeteer application for this board. In particular, the following components must be installed in order:

Moreover, the USB drivers must be installed, so that your PC can recognize the board and allows you to deploy and debug applications. Note that there is an update to .NET Micro Framework 4.2 QFE2, but no support for the Gadgeteer libraries just yet.

In this first post about Mountaineer Ethernet Mainboard, I’ll show a simple example of a Web Service that allows to remotely control the on-board LED. In particular, we will define methods to turn the LED on, off or to make it blink.

So, let’s start creating a new Gadgeteer application, using the.NETMF 4.2 template. We can see that the mainboard is automatically added to the Designer. Then, insert an EthernetForMountaineerEth module from the Toolbox. As the board already includes an Ethernet port, there is no need of connecting it. Adding this built-in module on the Designer simply tells Visual Studio that the mainboard must be initialized to support it.

The resulting device schema is shown in the following screenshot.

The Mountaineer Ethernet Mainboard in the Visual Studio Designer

The Mountaineer Ethernet Mainboard in the Visual Studio Designer

Now we can open the Program.cs file and write the code to configure the system.

private GT.Timer tmrBlink;
private bool isLedOn;

// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
    ethernetForMountaineerEth.NetworkUp +=
               new GTM.Module.NetworkModule.NetworkEventHandler(ethernetForMountaineerEth_NetworkUp);
    ethernetForMountaineerEth.UseStaticIP("", "", "");

    tmrBlink = new GT.Timer(500);
    tmrBlink.Tick += new GT.Timer.TickEventHandler(tmrBlink_Tick);

    // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
    Debug.Print("Program Started");

We define a Timer object that will be used to control the flashing of the LED and a variable that tells if the LED is currently on or off. In the ProgramStarted method, we register on the NetworkUp event, that is raised when the connection is available. Then, we call the UseStaticIP method, in which we specify the IP address to be assigned to the device, the subnet mask and the gateway address. After that, we instantiate the Timer object, using a 500 ms interval, and we define an handler for its Tick event.

In the NetworkUp event, we create a Web event and start the Gadgeteer local server:

void ethernetForMountaineerEth_NetworkUp(GTM.Module.NetworkModule sender,
    GTM.Module.NetworkModule.NetworkState state)
    var ledEvent = WebServer.SetupWebEvent("led");
    ledEvent.WebEventReceived +=
        new WebEvent.ReceivedWebEventHandler(ledEvent_WebEventReceived);
    WebServer.StartLocalServer(ethernetForMountaineerEth.NetworkSettings.IPAddress, 80);

In this way,  the device is able to handle requests on the led path. We want it to receive the following ones:

So, in the WebEventReceived event, we check what specific command has been invoked, reading the Query string value:

void ledEvent_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
    string mode = responder.GetParameterValueFromURL("mode").ToLower();
    if (mode == "on")
        isLedOn = true;
    else if (mode == "blink")
        isLedOn = false;


We use the responder.GetParameterValueFromURL to read the value of mode parameter in Query string:

  • if it is on or off, we stop the timer used to make the LED blink and set the variable isLedOn accordingly;
  • if it is blink, we simply start the timer.

After this check, we call the Mainboard.SetDebugLED method, that allows to control the status of on-board LED, passing the isLedOn variable to it. Finally, we send a response to notify the client that the request has been completed.

Every time the timer elaspses, we invert the current LED status; in this way, we make it blink:

void tmrBlink_Tick(GT.Timer timer)
    isLedOn = !isLedOn;

Note that this example is very similar to the ones that have been previously shown on this blog. It is possible because the Mountaineer Ethernet Mainboard is fully Gadgeteer compatible, so the programming model is the same, as well as the Core Gadgeteer libraries. This allows us to share our knowledge, no matter what mainboard we use. But this means also that we can connect to the Ethernet Mainboard any Gadgeteer module that is supported by its sockets, even if it hasn’t been explicitly realized for it.

The following video shows our application running:

The Gadgeteer application is available for download.


, , ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: