Introduction
This article demonstrates how to deploy a .NET core LED on and off the application on NOOBS OS using Raspberry pi. We will port a windows application to raspbian os with Visual Studio 2019.
About .Net Core
- NET Core is an open-source, general-purpose development platform maintained by Microsoft
- It's cross-platform (supporting Windows, macOS, and Linux)
- It supports the UWP and ASP.NET
- UWP - it is used to build a windows 10 and mobile application.
- ASP.NET - -It is used to build a web browser-based application.
Step 1
The first step will be to create a simple .NET Core console application for Windows. Start Visual Studio 2019 and select the console app. The project name is hellodotnetiot.
Then, you need to add the GPIO NuGet Package, so select the hellodotnetiot to right-click to more options available. Select NuGet Package and install the GPIO system configuration package.
Now, NuGet package managers are available here. Search the System.Device.Gpio then install the desired package.
Once again, check the package installation preview page.
Step 2
Next, go to the Project Name >> program.cs. Here is the code from program.cs, then replace the following code.
- using System;
- using System.Device.Gpio;
- using System.Threading;
-
- namespace hellodotnetiot
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Hello World, this is a dot net core iot app");
-
- int pin = 4;
- GpioController controller = new GpioController();
- controller.OpenPin(pin, PinMode.Output);
-
- while (true)
- {
- controller.Write(pin, PinValue.High);
- Thread.Sleep(1000);
- controller.Write(pin, PinValue.Low);
- Thread.Sleep(1000);
-
- }
-
- }
- }
- }
Next, right-click on the project name to see more options available, then click the publish button. It opens the publish window.
Two types of publications are available :
Now, select the folder because the windows based application package must convert the Linux-based application package.
While creating a folder profile you must set the deployment models and target runtime. Click the save button, and finally, publish the code
Step 3
Install the following code on the raspbian terminal.
- sud apt-get install curl libunwind8 gettext apt-transport-https
Now, Installing the WinSCP tool. This tool used to sharing publish packages from Windows to Linux and modify permission limits.
Step 4
Then, go to the given directory file and run the project. Every second the LED will on and off.
- cd /home/pi/hellodotnetiot
- ./hellodotnetion
Output
Summary
In this article, you learned how to deploy Windows applications on NOOBS os using Raspberry pi.
If you have any questions/ feedback/ issues, please write them below in the comment box.