3. C#

This tutorial will take you through your first C# App.

3.1. Prerequisites

If you are new to Windows 10 development, first download Visual Studio 2017 and ensure your machine is updated to the Creator’s Update.

You should be familiar with the C# language and know how to deploy Apps before starting the Win10 C# tutorials. There is a great tutorial to get started here: https://code.visualstudio.com/docs/languages/csharp

Don’t forget to keep the C# documentation handy as it can provide additional code examples and context to help you better understand what the tutorials are saying.


3.2. Template App

For those who want to build a simple MetaWear app or are new to Android development, we have provided a template for creating MetaWear apps which we will be using in this guide.

Download the C# Tutorial and import the solution into Visual Studio.

All the code on this page can be found in the StarterApp project.

Advanced developers building more complex Apps can refer to the C# Documentation for explicit installation instructions of the MetaWear library.


3.2.1. XAML Layout

The first thing we will do is add two buttons to the DeviceSetup.xaml file that start and stop the accelerometer.

<Button x:Name="accStart" Content="Start" HorizontalAlignment="Stretch" Margin="10,10,10,0"
        VerticalAlignment="Top" Click="accStart_Click"/>
<Button x:Name="accStop" Content="Stop" HorizontalAlignment="Stretch" Margin="10,47,10,0"
        VerticalAlignment="Top" Click="accStop_Click"/>

3.2.2. Data Stream

Open the DeviceSetup.xaml.cs file and implement the button click callback functions. The accStart_Click button will subscribe to the acceleration data signal and start the accelerometer whereas the accStop_Click will stop the data stream.

private async void accStart_Click(object sender, RoutedEventArgs e) {
    var accelerometer = metawear.GetModule<IAccelerometer>();

    accelerometer.Configure(odr: 25f);
    await accelerometer.Acceleration.AddRouteAsync(source => source.Stream(data =>

private void accStop_Click(object sender, RoutedEventArgs e) {
    var accelerometer = metawear.GetModule<IAccelerometer>();


3.2.3. Test the App

Load the App onto your Windows 10 device, select your board from the devices list, and press the start button to see acceleration data being outputted to the debug console.

3.3. FreeFall App

The FreeFall Detector app showcases how to use advanced firmware features such as data processing and logging. While we currently do not have videos availble that go through the app’s construction, the Java free fall videos should sufficiently explain how to use the aforementioned features as the C# SDK heavily mirrors the Java SDK.