C# on Raspberry Pi

*** Draft ***

Getting Ready

Programs and procedures on this web site, have been tested on Raspberry Pi 3 B. I will test the programs on Raspberry Pi 3 B+, when I have the chance to get one.

For Linux distribution, I am using Raspbian version March 2018. You may choose to use Ubuntu Mate. The look and feel between Raspbian and Ubuntu Mate are somewhat different. The programs, however, should work on both of them.

Please follow Raspberry Pi Software Guide on Raspberry Pi official web site to install Raspbian or Ubuntu Mate on your Raspberry Pi.

Update OS

After booting up your Raspberry Pi, the first thing to do is to update the software packages.

For those who are new to Raspbian, the Terminal is where you enter Linux commands. You can launch Terminal by clicking on the icon on the task bar on top of the screen:

And, here is the Terminal where you can enter commands:

Now, launch Terminal and run the following commands to update software packages to the latest version:

sudo apt update
sudo apt dist-upgrade

The second command may take a while to finish, sometimes more than 30 minutes. It depends on how many packages need to be updated.

Update raspi-config

Since we are at updating software, might as well update the rasp-config. At Terminal, enter command sudo raspi-config.

With the keyboard, move cursor to highlight Update. Then hit Enter key to update.

Later, raspi-config will be used to configure software and hardware components.

VNC

Now is a good time to enable VNC, if you need it. VNC allows you to control your Raspberry Pi from a remote client in full screen mode, e.g. Windows. It is possible to connect to more than one Raspberry Pi at the same time. Source codes and objects can be copy-paste between client (Windows) and server (Raspberry Pi).

Raspbian has included VNC in the installation. To use it, all you have to do is to enable it. From desktop menu, launch Raspberry Pi Configuration:


On Raspberry Pi Configuration screen, click Interfaces tab. Then, enable VNC:

And, that’s it. You are ready to control your Raspberry Pi remotely. When you attempt to connect, you will need user name/password, which by default is pi/raspberry. You will also need the IP Address of the Raspberry Pi. You can obtain the information by simply hovering your mouse over the up-down arraw icon on the task bar:

Here you can see the IP Address is “192.168.0.39”.

The alternative is to click on the VNC icon which will show you more details on the VNC connection:

BTW, the VNC icon is visible after VNC has been enabled.

Ubuntu Mate Only

For Ubuntu Mate, you need to install one of the VNC server packages. I will show you the steps to install and activate vino. (There are talks on the internet, saying that vino is installed with Unbuntu Mate. Somehow, I couldn’t find it.)

Open up Terminal and enter command sudo apt install vino to install vino. Then, enter command vino-preferences to configure. On the screen:

  • Enable Allow other users to view your desktop.
  • Enable Allow other users to control your desktop.
  • Under Security, uncheck everything.

Next, return to the desktop. Open the menu item Applications | System Tools | dconf Editor. On the left side of the screen, expand the options org | gnome | desktop | remote-access. You won’t see remote-access until one of the VNC packages is installed.

At this point, you should see VNC options on the right side of the screen. Depending on the VNC software you choose, the options will be different. For vino, you may ignore most of them. The ones that need your attention are:

  • leave blank in network-interface.
  • uncheck require encryption. (You can leave this checked, if you are sure the client software accepts the encryption.)
  • put blank in vnc-password.

That’s all about installation and configuration.

Now you can start VNC by entering command /usr/lib/vino/vino-server --sm-client-disable. Usually, you would want to run this command at system startup. To do so, open the menu item System | Control Center. Then click Startup Applications in Personal group. Enter /usr/lib/vino/vino-server in the Command field. Enter your choice of words in Name and Comment fields. Restart the system, you should see the VNC icon on top of the desktop.

Security

If security is a concern, you will need to tighten the security by changing the configuration options.

VNC Client

On the client side, I use VNC Viewer which can be found at realvnc.com.

Where Are We?

Now we have a Raspberry Pi with either Raspbian or Ubuntu Mate installed. The system is up-to-date, and ready to install mono and other software. Right, we have not even started on mono yet. But, if you are at his point, it’s a good start.

Continue reading, mono will be coming next.

Leave a Reply