Skip to main content
Version: Torizon OS 6.x.y

How to Use UART with Torizon Visual Studio Code Extension (.NET Core)


In this article, we will show how you can use the UART interface, also known as serial, with .NET Core and the Visual Studio Code Extension for Torizon.

The goal is to create a simple application using .NET Core Console template showing the data returned from a serial UART GPS.



Define the UART Device​

In Linux systems, including Torizon OS, UART devices can be accessed through /dev/tty*. Toradex adds a layer of abstraction with symlinks, so the UART names are standardized for a given SoM family. Take a look at UART (Linux) article to understand the different /dev/tty* names across the Toradex's Module families.

Once you identify the exact name of your UART device, you can add it to your application.

Connect to a Serial GPS​

For this example the Ublox Neo 6M, GY-NEO-6MV2, GPS module was used:

Ublox Neo 6M

Connect the UART of the GPS Module to an available UART on your board.

Board            GPS
VCC <--------> VCC
RX <--------> TX
TX <--------> RX
GND <--------> GND

For the purposes of example in this article, the Apalis iMX6Q and Ixora carrier board will be used. For connect GPS module we will use UART4 signals from Ixora header X27:

GPS Module connected to Ixora UART4

Create a New Project​

On VS Code, create a new Torizon .NET Application. See the .NET Core Development and Debugging on Torizon Using Visual Studio Code article for detailed instructions.

.NET Core Project

Add UART Device to the Project​

To add UART to your .NET Core Torizon project, first, open the Torizon Configuration View. To do that, press F1 in Visual Studio Code command bar and then type "Torizon: Focus on Configurations View"

Show the Configurations View

On the device item, press the '+' button on the right.

Add New Device to The Project

Type the selected tty device. As an example, we will add /dev/apalis-uart4.


/dev/apalis-uart4 is UART4 in the case of the Apalis family. Find your UART name on the previous section Define the UART Device.

Adding tty device

Check if the device was added to your project.

Project's Devices

Add Serial Access Permission​

To have access to the serial devices we need to add the default torizon user to dialout group. Go to the Torizon Visual Studio Code Extension Configurations and add the buildcommands:

RUN usermod -a -G dialout torizon 

Add torizon user to dialout group

Add Nuget Packages​

To easily parse NMEA data from GPS module, we use the SharpGIS.NmeaParser. To add it to the project open a new terminal using the Visual Studio Code and enter the following command:

dotnet add package SharpGIS.NmeaParser

Dotnet add Nuget package

Source Code​

The example code used in this documentation comes from the sample

Set the Serial Port​

In the Torizon properties, edit the env property with the desired UART.

ENV GPS_SERIAL_PORT="/dev/apalis-uart4"

With the correct device set, you can now run and debug the application. See the .NET Core Development and Debugging on Torizon Using Visual Studio Code article for detailed instructions about debugging tools.

Send Feedback!