ASP.NET 5 on Lego Mindstorms EV3 using ev3dev

Lego Mindstorms EV3

Lego Mindstorms EV3

Lego Mindstorms EV3 Robot * image permission granted by Lego

I find Lego Mindstorms EV3 very enjoyable. There are so many great projects that it can awake kid in every geek. If you happen to be a father (or mother) you will probably agree that it is very creative and developing fun. The same goes with Raspberry Pi.

I had this idea while playing with my kids that it would be great to see my EV3 running ASP.NET 5. After all Scott Hanselman was able to run DNX on his Raspberry PI long ago. And Lego Mindstorms EV3 is also a ARM based machine.

Source code for this article along with C# library for ev3dev can be found here:

Contributions are welcome !


After few days of research David Lechner made a comment my stack overflow question, suddenly changing my way of thinking from “this is impossible” to “yeah this can be done!”. He gave me a link to this wonderful ev3-dev project of his.

The ev3dev is essentially Debian distribution. Debian Jessy currently to be precise. Compiled and packed into 200 MB zip file, released on GitHub for Raspberry Pi, Raspberry Pi 2 and Lego Mindstorms EV3. Because ev3dev runs on top of your Lego firmware it does not need usual flashing. If you are worried about braking your brick this type of installation is a perfect choice.


You will need:

  • Lego Mindstorms EV3 brick with USB cable
  • At least 4 GB Micro SD card
  • New set of AA batteries (seriously – buy fresh ones)
  • Visual Studio Community 2015 or other editor of your choice
  • putty to connect to your Linux
  • WinSCP or any other scp client
  • Few hours of free time

I found out (the hard way) that new set of batteries are essential. Installation process will take few hours so make sure that nothing is going to interrupt.

In my original setup I used 2GB SSD card and I strongly recommend you to use bigger one. Before buying new one check performance as well. Card should be as fast as possible as you can gain significant boost with mono installation, compilation and while making backups of your progress.

I assume that you are running on root account. If not you may have to add sudo command where elevated privileges are needed.

Running ASP.NET on Lego Mindstroms EV3

To run ASP.NET 5 on Lego Mindstroms EV3 few things are needed. The plan is:

  • Setup ev3dev on a brick
  • Install DNVM & DNX
  • Install Mono >= 3.10 (I used v4.0)
  • Run simple app

Sounds easy and mostly it is, except for mono installation part where I’ve spent most of my time. Setting up drivers to communicate with ev3dev, was long but it was a one time effort.

Due to the difficulties I had with using Roslyn compiler on ev3dev all code will be compiled on Windows machine. This approach has speed advantage over compilation on the brick.

Setup ev3dev

Download latest image from GitHub (be sure to get one starting with ev3-ev3dev-). Follow instructions published on ev3-dev site under Getting Started and then enable connection sharing to access web from your Lego brick. Internet connection can be established using ev3-devinstructions.

This process is quite straightforward but long to describe so I feel that it is useless to repeat it here.

Install DNVM & DNX

Original instructions can be found on this ASP.NET site. Short installation script is:

I suggest installing apt-utils with apt-get install apt-utils. This package contains tools that package manager uses when package needs to ask questions how to be configured.
If you are too hasty and installed curl you shall get debconf: delaying package configuration, since apt-utils is not installed. Do not worry though. curl nor unzip does not ask any install questions.

Despite what message says after installing dnvm you do not have to ‘source’ anything. It is already there. Just type dnvm and you will see familiar ascii art.

No CoreCLR

What’s next? You say install CoreCLR runtime? No way…

The CoreCLR does not have official builds for ARM architecture but I was informed by ASP.NET team that it can be done and there is nothing intrinsic that prevents it.

Mono installation

Mono is an open source implementation of .NET Framework that runs on Mac, Linux and Windows delivered by Xamarin. Using mono, DNX is able to run applications on full version of .NET Framework.

Here is where I spent most of my time. To avoid this:

You have to add not only Xamarin main repository but also one extra to install libgdiplus.

Compilation and deployment

As I mentioned earlier I stumbled upon a problem with compilation on the brick. For this reason and the fact that the brick has only 64MB of RAM which may be insufficient for the compiler I advise you to do the compilation on your own computer.

I’ve spent some time to develop very simple C# library that supports motors and sensors for EV3. You can find it here:

Along with the library you can find SensorDemo project. This very simple program prints state of a single connected EV3 sensor (I used color sensor).

In order to prepare the project to be executed on Lego Mindstorms, open a console windows and navigate to the demo project folder. Use dnu publish --no-source to build and package application into output folder. The --no-source is crucial to avoid code compilation.

Publish command will create following structure under project bin folder:

The packages directory contains all the files your application needs to run.

The SensorDemo.cmd and SensorDemo files are commands that run application. The first one is used under Windows, second one used on Linux and Mac.

Connect to EV3 using SCP client (eg. WinSCP) and copy entire output folder to your home directory. Using putty navigate to approot directory and grant execute rights to SensorDemo script. This can be achieved by typing chmod +x SensorDemo.

At this point you are ready to run the application and see how it works!

(just execute script by typing ./SensorDemo)

What’s next?

If you are tired with looking at sensors try another demo. ShootDemo is prepared to shoot using tail of SPIK3R.

You can participate in development of this C# library. Fork it on GitHub, prepare your changes and create a pull request. Your contribution is welcome !


After many trials and errors I was able to find the way to run DNX on Lego Mindstorms EV3. I’m excited about this project and looking forward to see if you are as well.


This article was heavily edited since it’s first release. My first attempt to setup Lego Mindstorms EV3 was a failure but since then I was able to overcome most difficulties.


  1. FYI, leJOS and MonoBrick both run off of an SD Card as well and do not require flashing the EV3.

    P.S. Why does your website use Title case for comments and email adresses?

  2. I was sure it needs flashing. Good to know I will note this in the article.

    Thanks for reporting me this email issue. I do not know why it does that. It must be theme issue as I Haven’t set anything like that.

  3. Are you insane? Using .NET anything for embedded electronics? And you’re site implied “bleeding edge”?

    That your very first paragraph has to mention all the difficulties you have is evidence you need a serious re-education! Jeez.

    1. @Rob,
      it seems that you don’t know what really geek is, do you? Is idea of using .NET for embedded electronics so difficult for you? If yes, try .NET Micro Framework, maybe it will help you to understand. Also, please do not use re-education argument for people that might be more intelligent than you.

      Idea of using Lego is great, however it’s so bad that sets of mindstorms are at its price…

Leave a Reply