.NET Core on Raspberry Pi

Raspberry Pi’s can run C# controlling the GPIO with the librarys below. I had a hoon at https://github.com/carlpaton/SweetPi.

Install .Net Core

I tried to use the dotnet-install scripts and even after manually adding to path it didnt work. So I did it manually:

Update the OS

1
2
sudo apt-get update
sudo apt-get upgrade

Check for dotnet and install it

1
2
dotnet --info                      ~ fails: 'dotnet1' is not recognized as an internal or external command, operable program or batch file.
echo $0 ~ expect `bash`

At the time these were latest but always check dotnet.microsoft.com/download for the latest versions.

1
2
3
4
mkdir dev
cd dev
wget https://download.visualstudio.microsoft.com/download/pr/349f13f0-400e-476c-ba10-fe284b35b932/44a5863469051c5cf103129f1423ddb8/dotnet-sdk-3.1.102-linux-arm.tar.gz
wget https://download.visualstudio.microsoft.com/download/pr/8ccacf09-e5eb-481b-a407-2398b08ac6ac/1cef921566cb9d1ca8c742c9c26a521c/aspnetcore-runtime-3.1.2-linux-arm.tar.gz

The tar command is also used to extract tar archives:

1
2
3
4
5
6
7
8
mkdir dotnet-arm32
tar zxf dotnet-sdk-3.1.102-linux-arm.tar.gz -C $HOME/dev/dotnet-arm32
tar zxf aspnetcore-runtime-3.1.2-linux-arm.tar.gz -C $HOME/dev/dotnet-arm32

export DOTNET_ROOT=$HOME/dev/dotnet-arm32
export PATH=$PATH:$HOME/dev/dotnet-arm32

dotnet --info ~ works

Adding export above only adds it for that session, you can perminantly add it as follows

1
2
3
4
5
6
7
8
9
echo $PATH                        ~ wont have `dev/dotnet`
sudo nano ~/.bashrc ~ edit PATH in [~/.bashrc] file

At the bottom of the file add the exports. Save and exit.

export DOTNET_ROOT=$HOME/dev/dotnet-arm32
export PATH=$PATH:$HOME/dev/dotnet-arm32

source ~/.bashrc ~ reload the [~/.bashrc] file

Install VS Code

I like to edit and run the code on the Pi, VS code can be used with the C# extensions.

1
2
sudo apt update 
sudo apt install code -y

Hardware ideas & Help

Its amazing the things people share online, helps noobs like me!

LED

LEDS & Resistors

Servos

Sensor

Breadboards

Netstat & UFW

You can confirm if the port is listing on your Pi with netstat -nltp, it needs to have a Local Address of :::5001 this means its listing to the outside world.

All ports on the Pi should be open but if this still doesnt work you can try Uncomplicated Firewall (UFW) which is a front-end to iptables.

1
2
3
apt-get install ufw
ufw status
ufw allow in from any to any port 5001