nanoFramework.M5Core2 1.1.32 The ID prefix of this package has been reserved for one of the owners of this package by Prefix Reserved

.NET Framework
Install-Package nanoFramework.M5Core2 -Version 1.1.32
dotnet add package nanoFramework.M5Core2 --version 1.1.32
<PackageReference Include="nanoFramework.M5Core2" Version="1.1.32" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add nanoFramework.M5Core2 --version 1.1.32
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: nanoFramework.M5Core2, 1.1.32"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install nanoFramework.M5Core2 as a Cake Addin
#addin nuget:?package=nanoFramework.M5Core2&version=1.1.32

// Install nanoFramework.M5Core2 as a Cake Tool
#tool nuget:?package=nanoFramework.M5Core2&version=1.1.32
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Reliability Rating License #yourfirstpr Discord

nanoFramework logo

Welcome to the .NET nanoFramework M5Stack Libraries repository

Build status

Component Build Status NuGet Package
nanoFramework.M5Core Build Status NuGet
nanoFramework.M5Stick Build Status NuGet
nanoFramework.M5StickCPlus Build Status NuGet
nanoFramework.M5Core2 Build Status NuGet
nanoFramework.Fire Build Status NuGet
nanoFramework.AtomLite Build Status NuGet
nanoFramework.AtomMatrix Build Status NuGet


These NuGet packages provide a support for M5Stack products:

Note 1: Before trying to add NuGet packages to your projects and/or before flashing the devices (see next section) using MS Visual Studio (VS), open VS > Tools > Options > NuGet Package Manager > Package Sources and make sure that it contains an entry pointing to, otherwise add it. Note 2: When invoking VS > Project > Manage NuGet Packages make sure that in the Package source drop-down menu (right upper corner) "" is selected.

The NuGets bring support for the screens as well and require to be flashed with the proper image (using nanoff dotnet CLI). On the examples below replace COM3 with the appropriate number of the COM port to which your device is connected. (on Windows you can check this in the Device Manager).

For the M5Core:

nanoff --target M5Core --update --serialport COM3

For the M5StickC:

nanoff --target M5StickC --update --serialport COM3 --baud 115200

For the M5StickCPlus:

nanoff --target M5StickCPlus --update --serialport COM3

For the M5Core2 and Fire:

nanoff --target M5Core2 --update --serialport COM3

For the Atom Lite and Matrix:

nanoff --target ESP32_PICO --update --serialport COM3

Note 3: If the nanoff commands fails, make sure you have followed instruction from Note 1 above.

Once you have the NuGets, you can then enjoy accessing the screen, the accelerometer, get a Grove I2C connecter, add events on the buttons. And you don't even need to think about anything, all is done for you in the most transparent way!

Note 4: All the classes that you'll have access are all using the Lazy pattern to be instantiated including the screen. This have the advantage to use as little memory and setup time as possible.

In the samples below, we'll use either M5Core or M5Stick as examples, they are all working in a very similar way.


Make sure you add the proper namespaces reference to your C# program header e.g. using nanoFramework;


The only thing you need to do to access the screen is to initialize it (please note that InitializeScreen() it's target specific) e.g.:

For Core:


For StickCPlus:


Once you've initialized it, you can access both a Screen static class and a Console static class.

THe Screen one brings primitives to write directly on the screen points or scare of colours as well as writing a text.

For example, you can write a blue square of 10x10 at the position 0, 0 like this:

ushort[] toSend = new ushort[100];
ushort blue = ColorUtility.To16Bpp(Color.Blue);

for (int i = 0; i < toSend.Length; i++)
    toSend[i] = blue;

Screen.Write(0, 0, 10, 10, toSend);

The Console class works in a similar way as the classic System.Console. In order to use it you have to reference it using the fully qualified name of the methods, like this:


// Test the console display
nanoFramework.Console.Write("This is a short text. ");
nanoFramework.Console.ForegroundColor = nanoFramework.Presentation.Media.Color.Red;
nanoFramework.Console.WriteLine("This one displays in red after the previous one and is already at the next line.");
nanoFramework.Console.BackgroundColor = nanoFramework.Presentation.Media.Color.Yellow;
nanoFramework.Console.ForegroundColor = nanoFramework.Presentation.Media.Color.RoyalBlue;
nanoFramework.Console.WriteLine("And this is blue on yellow background");
nanoFramework.Console.CursorLeft = 0;
nanoFramework.Console.CursorTop = 8;
nanoFramework.Console.Write("This is white on black again and on 9th line");

Note: You can change the default font as well, you need to provide it as a property. The Cursor positions are calculated with the largest possible character.

M5Core2 and Fire have PSRAM, so you can get a full screen buffer as well. Refer to the Graphics samples to understand all you can do with it.

If you have intensive graphic need with any of the M5Stack, you can adjust the memory requested. While both M5Core2 and Fire have PSRAM and can accommodate very large amount like 2 Mb or more, the ones without cannot go more than few Kb or tens of Kb.

// This will allocate 2 Mb of memory for the graphics
M5Core2.InitializeScreen(2 * 1024 * 1024);


The main buttons except the power buttons are exposed.

On the M5Stack and Fire they are called ButtonLeft, ButtonCenter and ButtonRight. You can get access to the events as well. For example:

M5Stack.ButtonLeft.Press += (sender, e) =>
    Console.ForegroundColor = Color.Yellow;
    Console.CursorLeft = 0;
    Console.CursorTop = 0;
    Console.Write($"Left Pressed  ");

On the M5StickC/CPlus they are called ButtonM5 and ButtonRight. You can get access to the status of the button, the events and everything you need. For example:

while (!M5StickC.ButtonRight.IsPressed)

M5StickC.M5Button.IsHoldingEnabled = true;
M5StickC.M5Button.Holding += (sender, e) =>
    Console.Write("M5 button hold long.");

On the Atom Lite/Matrix it's called Button. You can get access to the status of the button, the events and everything you need. For example:

AtomLite.Button.Press +=> (sender, e)
    var color = AtomLite.NeoPixel.GetColor();
    if(color.R > 0)
        AtomLite.NeoPixel.SetColor(Color.FromArgb(255, 0, 255, 0));
    else if (color.G > 0)
        AtomLite.NeoPixel.SetColor(Color.FromArgb(255, 0, 0, 255));
        AtomLite.NeoPixel.SetColor(Color.FromArgb(255, 255, 0, 0));

Note: The M5Core2 has touch screen and the buttons are "virtual"". See next section to see how to use them.

M5Core2 touch panel and buttons

The touch panel comes with the screen. Both are initialized and activated at the same time. To get the touch events, you'll have to register to the TouchEvent event:

M5Core2.TouchEvent += TouchEventCallback;

Here is an example on how to check if you are on a button or not and get the various elements:

void TouchEventCallback(object sender, TouchEventArgs e)
    const string StrLB = "LEFT BUTTON PRESSED  ";
    const string StrMB = "MIDDLE BUTTON PRESSED  ";
    const string StrRB = "RIGHT BUTTON PRESSED  ";
    const string StrXY1 = "TOUCHED at X= ";
    const string StrXY2 = ",Y= ";
    const string StrID = ",Id= ";
    const string StrDoubleTouch = "Double touch. ";
    const string StrMove = "Moving... ";
    const string StrLiftUp = "Lift up. ";

    Debug.WriteLine($"Touch Panel Event Received Category= {e.EventCategory} Subcategory= {e.TouchEventCategory}");
    Console.CursorLeft = 0;
    Console.CursorTop = 0;

    Debug.WriteLine(StrXY1 + e.X + StrXY2 + e.Y + StrID + e.Id);
    Console.WriteLine(StrXY1 + e.X + StrXY2 + e.Y + StrID + e.Id + "  ");

    if ((e.TouchEventCategory & TouchEventCategory.LeftButton) == TouchEventCategory.LeftButton)
    else if ((e.TouchEventCategory & TouchEventCategory.MiddleButton) == TouchEventCategory.MiddleButton)
    else if ((e.TouchEventCategory & TouchEventCategory.RightButton) == TouchEventCategory.RightButton)

    if ((e.TouchEventCategory & TouchEventCategory.Moving) == TouchEventCategory.Moving)

    if ((e.TouchEventCategory & TouchEventCategory.LiftUp) == TouchEventCategory.LiftUp)

    if ((e.TouchEventCategory & TouchEventCategory.DoubleTouch) == TouchEventCategory.DoubleTouch)

    Console.WriteLine("                                    ");
    Console.WriteLine("                                    ");
    Console.WriteLine("                                    ");

The TouchEventCategory enum is a flag and can combine buttons and states. The buttons are mutually exclusive, so you can only have the Left, Middle or Right button, the states are Moving and LiftUp. Moving is happening when a contact has already been made and the touch point is moving. LiftUp will appear when the contact is released.

DoubleTouch is a specific that let you know there is another contact point happening. Each contact point will receive this flag. The event will be raised 2 times, one for each point. In a double touch context, you may not get the second point LiftUp event but you'll get the change with the disappearance of the DoubleTouch flag and the final LiftUp on the first point.

Power management

The M5Core and M5StickC/CPlus are exposing their power management elements. It is not recommended to change any default value except if you know what you are doing.

Please refer to the detailed examples for the AXP192 used in the M5StickC/CPlus; M5Core2 and IP5306 for the M5Core and Fire.

Accelerometer and Gyroscope

You can get access to the Accelerometer and Gyroscope like this:

var ag = M5Core.AccelerometerGyroscope;
// Do not move the M5Core/M5Stick during the calibration
var acc = ag.GetAccelerometer();
var gyr = ag.GetGyroscope();
Debug.WriteLine($"Accelerometer data x:{acc.X} y:{acc.Y} z:{acc.Z}");
Debug.WriteLine($"Gyroscope data x:{gyr.X} y:{gyr.Y} z:{gyr.Z}\n");

Refer to the MPU6886 documentation for more detailed usage on this sensor.


The M5Core has a magnetometer, you can access it as well:

var mag = M5Core.Magnetometer;
// It is more than strongly recommended to calibrate the magnetometer.
// Move the M5Core in all directions to have a proper calibration.
var magVal = mag.ReadMagnetometer();
Console.WriteLine($"x={magVal.X:N2}   ");
Console.WriteLine($"y={magVal.Y:N2}   ");
Console.WriteLine($"Z={magVal.Z:N2}   ");
var headDir = Math.Atan2(magVal.X, magVal.Y) * 180.0 / Math.PI;
Console.WriteLine($"h={headDir:N2}  ");


The M5Core and M5Core2 can provide a Serial Port, just get it like this:

// You can access any of the Serial Port feature
// Do anything else you need

Refer to the SerialPort documentation for more information.

ADC Channels

ADC Channels are pre setup on the M5Core, M5Core2, Fire and Atom Lite/Matrix, access them like this:

// This will give you the ADC1 channel 7 which is on pin 35 of M5Core
AdcChannel myChannel = M5Core.GetAdcGpio(35);

Refer to the M5Stack documentation to have the mapping of the ADC channels and the pins.

I2C Device/Grove

You can get an I2cDevice/Grove like this:

// In this example, the I2C address of the device is 0x42:
I2cDevice myDevice = M5Core.GetGrove(0x42);
// replacing GetGrove by GetI2cDevice will have the same impact

SPI Device

The M5Core, M5Core2, Fire and Atom Lite/Matrix provides as well an SpiDevice:

// In this case GPIO5 will be used as chip select:
SpiDevice mySpi = M5Core.GetSpiDevice(5);

GPIO Controller

Similar as previously, you can get the GpioController on any of the M5Core, M5Core2, Fire and M5StickC/CPlus:

// This will open the GPIO 36 as output
var pin5 = M5StickC.GpioController.OpenPin(36, PinMode.Output);


The M5Core, M5Core2, Fire and Atom Lite/Matrix exposes 2 DAC and you can access them thru the Dac1 and Dac2 properties. Refer to the DAC documentation for more information.


The M5StickC/CPlus exposes a led. You can access it thru the Led property:

// This will toggle the led:

Infrared Led

The M5StickC/CPlus and Atom Lite/Matrix exposes an infrared led. You can access it thru the InfraredLed property. This will give you a TransmitterChannel. Check out the sample pack to understand how to use it.

NeoPixel on AtomLite

The Atom Lite exposes a rgb led. You can access it thru the NeoPixel property:

// This will set NeoPixel to green:
AtomLite.NeoPixel.Image.SetPixel(0, 0, Color.Green);

RGB LED matrix on AtomMatrix and Led bar on Fire

The Atom Matrix has a matrix of 25 RGB LEDs. The position of the LEDs in the array follows their placement in the matrix, being 0 the one at the top left corner, growing left to right, top to bottom.

You can access it thru the LedMatrix property on the AtomMatrix, like this:

// This will set the RGB LED at position 2, 2 to green
AtomMatrix.LedMatrix.Image.SetPixel(2, 2, Color.Green);

Similarly, you have access to the LedBar property on the Fire:

// This will set the second RGB LED to green
Fire.LedBar.Image.SetPixel(2, 0, Color.Green);

After you're done with updating all the LEDs that you want to change, flush the updated to the LEDs, like this:

// This will update all RGB LED 

And on the Fire:

// This will update all RGB LED 

Feedback and documentation

For documentation, providing feedback, issues and finding out how to contribute please refer to the Home repo.

Join our Discord community here.


The list of contributors to this project can be found at CONTRIBUTORS.


The nanoFramework Class Libraries are licensed under the MIT license.

Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community. For more information see the .NET Foundation Code of Conduct.

.NET Foundation

This project is supported by the .NET Foundation.

Product Versions
.NET Framework net
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.32 47 8/6/2022
1.1.30 45 8/5/2022
1.1.28 33 8/4/2022
1.1.26 38 8/3/2022
1.1.24 31 8/3/2022
1.1.22 44 8/2/2022
1.1.20 53 7/30/2022
1.1.18 66 7/26/2022
1.1.16 46 7/24/2022
1.1.14 49 7/23/2022
1.1.12 79 7/13/2022
1.1.7 151 7/7/2022
1.1.5 61 7/7/2022
1.1.3 63 7/6/2022
1.1.1 67 7/5/2022 72 7/1/2022 68 6/30/2022 59 6/28/2022 49 6/28/2022 58 6/28/2022 69 6/26/2022 64 6/24/2022 92 6/16/2022 56 6/15/2022 62 6/14/2022 80 6/13/2022 88 6/8/2022 87 6/3/2022 62 6/3/2022 71 6/1/2022 74 5/31/2022 67 5/31/2022 70 5/31/2022 73 5/27/2022 66 5/26/2022 76 5/26/2022 81 5/25/2022 75 5/24/2022 80 5/23/2022 98 5/20/2022 107 5/12/2022 165 5/6/2022
1.0.46 89 5/5/2022
1.0.42 110 4/26/2022
1.0.40 89 4/25/2022
1.0.38 95 4/24/2022
1.0.36 88 4/23/2022
1.0.34 93 4/22/2022
1.0.32 88 4/22/2022
1.0.30 87 4/21/2022
1.0.26 85 4/21/2022
1.0.24 91 4/20/2022
1.0.22 92 4/19/2022
1.0.20 83 4/18/2022
1.0.18 123 4/17/2022
1.0.16 78 4/16/2022
1.0.14 84 4/15/2022
1.0.12 102 4/13/2022
1.0.10 109 4/6/2022
1.0.8 100 4/4/2022
1.0.6 92 4/3/2022
1.0.4 112 3/31/2022
1.0.2 61 3/31/2022
1.0.1-preview.68 47 3/30/2022
1.0.1-preview.67 56 3/25/2022
1.0.1-preview.66 50 3/25/2022
1.0.1-preview.65 45 3/25/2022
1.0.1-preview.64 49 3/23/2022
1.0.1-preview.63 36 3/22/2022
1.0.1-preview.62 40 3/21/2022
1.0.1-preview.61 49 3/20/2022
1.0.1-preview.60 47 3/19/2022
1.0.1-preview.58 50 3/16/2022
1.0.1-preview.57 51 3/16/2022
1.0.1-preview.56 51 3/14/2022
1.0.1-preview.55 50 3/14/2022
1.0.1-preview.54 47 3/11/2022
1.0.1-preview.53 44 3/9/2022
1.0.1-preview.52 52 3/8/2022
1.0.1-preview.51 49 3/7/2022
1.0.1-preview.50 49 3/4/2022
1.0.1-preview.49 53 3/3/2022
1.0.1-preview.48 50 2/27/2022
1.0.1-preview.47 46 2/26/2022
1.0.1-preview.46 45 2/25/2022
1.0.1-preview.45 56 2/18/2022
1.0.1-preview.43 52 2/16/2022
1.0.1-preview.42 56 2/12/2022
1.0.1-preview.41 50 2/10/2022
1.0.1-preview.40 56 2/9/2022
1.0.1-preview.39 57 2/8/2022
1.0.1-preview.38 64 2/6/2022
1.0.1-preview.37 63 2/5/2022
1.0.1-preview.36 67 2/4/2022
1.0.1-preview.35 66 2/3/2022
1.0.1-preview.34 65 1/31/2022
1.0.1-preview.32 66 1/31/2022
1.0.1-preview.31 121 1/29/2022
1.0.1-preview.30 81 1/28/2022
1.0.1-preview.28 73 1/28/2022
1.0.1-preview.26 76 1/27/2022
1.0.1-preview.25 84 1/27/2022
1.0.1-preview.24 81 1/26/2022
1.0.1-preview.23 78 1/24/2022
1.0.1-preview.22 81 1/21/2022
1.0.1-preview.21 75 1/21/2022
1.0.1-preview.20 69 1/21/2022
1.0.1-preview.19 67 1/21/2022
1.0.1-preview.18 76 1/20/2022
1.0.1-preview.17 69 1/20/2022
1.0.1-preview.16 77 1/16/2022
1.0.1-preview.15 83 1/14/2022
1.0.1-preview.14 71 1/14/2022
1.0.1-preview.13 73 1/12/2022
1.0.1-preview.12 88 1/11/2022
1.0.1-preview.9 93 1/5/2022
1.0.1-preview.8 76 12/31/2021
1.0.1-preview.7 71 12/31/2021
1.0.1-preview.6 87 12/29/2021
1.0.1-preview.5 72 12/28/2021
1.0.1-preview.3 75 12/27/2021
1.0.0 209 12/23/2021
1.0.0-preview.99 81 12/23/2021
1.0.0-preview.98 79 12/23/2021
1.0.0-preview.94 123 11/12/2021
1.0.0-preview.91 107 11/9/2021
1.0.0-preview.88 111 11/9/2021