Build a .NET Core IoT App on Raspberry Pi

Today in this article, we will cover below aspects,

IoT devices for .NET developers!

.NET Core is an open-source, cross-platform framework that has introduced all kinds of new opportunities including potential usage of IoT for .NET developers.

I am sure you must be as excited as I am !!

In this post, we will see how to configure and build the .NET Core 2.2 app on the IoT Raspberry Pi platform.

Above are similar techniques, you could use for .NET Core 3.1 or latest .NET 6 program also

Prerequisites :

All you need is 35$ Raspberry Pi and a set of hardware before get started.

You need Raspberry Pi configured with the Raspbian Linux system hence if you need more details please visit this post on the required set of software and hardware requirements.

Getting started:

I am using the same Pi version 3B Plus ( Which my kid asked me to buy a few months before for his school project :). )

Please make sure to set up your Pi as explained in the article Raspberry Pi configured with Raspbian Linux system.

Update Linux software on your Pi

Command: sudo apt-get update

Command: sudo apt-get install libunwind8 gettex apt-transport-https

Download .NET Core Runtime 2.2.0

.NET Core runtime for Linux ARM32: https://dotnet.microsoft.com/download/thank-you/dotnet-runtime-2.2.0-linux-arm32-binaries

Download ASP.NET Core runtime 2.2.0

ASP.NET Core runtime for Linux ARM32
https://dotnet.microsoft.com/download/thank-you/dotnet-runtime-2.2.0-linux-arm32-asp.net-core-runtime-binaries

Download .NET SDK 2.2.0

.NET Core SDK for Linux ARM32: https://dotnet.microsoft.com/download/thank-you/dotnet-sdk-2.2.101-linux-arm32-binaries

Upload .NET Core Runtime and SDK to Raspberry Pi

You can use scp.exe (secure copy) command easily to copy the content to Raspberry PI. This Secure Copy utility is available in Windows 10 by default.

Dotnet runtime

Please copy .NET Core runtime using below command

scp dotnet-runtime-2.2.0-linux-arm.tar.gz pi@192.168.254.66:/home/pi/Downloads

Aspcore runtime

Please copy ASP.NET Core runtime using below command

scp aspnetcore-runtime-2.2.0-linux-arm.tar.gz pi@192.168.254.66:/home/pi/Downloads

.NET Core SDK

Please copy .NET Core SDK using below command,

scp dotnet-sdk-2.2.101-linux-arm.tar.gz pi@192.168.254.66:/home/pi/Downloads

After successful upload, you shall see the downloaded file in Raspberry Pi as below

blank

Install .NET Core

Let’s install now uploaded .NET Core packages to Pi

sudo mkdir /opt/dotnet
sudo tar -xvf ./Downloads/dotnet-runtime-2.2.0-linux-arm.tar.gz -C /opt/dotnet/

blank


sudo tar -xvf ./Downloads/aspnetcore-runtime-2.2.0-linux-arm.tar.gz -C /opt/dotnet/

blank


sudo tar -xvf ./Downloads/dotnet-sdk-2.2.101-linux-arm.tar.gz -C /opt/dotnet/


sudo ln -s /opt/dotnet/dotnet /usr/local/bin

So we are all set, so far we have .NET runtime installed. We also have SDK installed, which will help us create and build .NET Core projects right within Tiny Pi.

.NET Core version

After the successful installation of .NET Core, please check the version.

Command : dotnet –info

blank

IoT examples application

We shall be exploring more on IoT packages like GPIO packages (General Purpose Input/Output) Install-Package System.Devices.Gpio and Device Binding Install-Package IoT.Device.Bindings in the next future articles.

Please see below examples/references to get started,

That’s all, you are set to enjoy a world of IoT.

Keep learning and Keep sharing !!

Summary

In this article, we learned how to configure .NET Core on the Raspberry Pi Linux system. .NET Core is open-source, a cross-platform framework that has enabled us to explore new possibilities including potential usage of IoT.



Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.



4 thoughts on “Build a .NET Core IoT App on Raspberry Pi

Leave a Reply

Your email address will not be published. Required fields are marked *