Remote programming of mini PC like Raspberry Pi or Beaglebone Black

Check out the new site at https://rkblog.dev.

Programming on mini PC like Raspberry Pi, or Beaglebone Black maybe bit annoying or hard due to lack of some more complex IDEs not available on ARM platform, or just to resource heavy to such computers. Sometimes you may also lack keyboard, mouse and a display to connect to them. In such cases remote access and remote programming may be a solution. All you need is a network connection and proper applications and protocols.

In this article I'll showcase how to use SSH, SSHFS, VNC/RDP protocols/solutions for remote access and programming of any (mini) PC. I'll also show how to configure PyCharm to use external Python interpreter (like that from Raspberry Pi).

Lets start with SSH

Basic solution for remote access is SSH connection from the PC to the mini PC. Raspberry for example will auto-connect with Ethernet connection. Some others like Beaglebone Black will not so you will have to preconfigure them with the mouse/keyboard/display setup before using them remotely.

To connect to a mini PC it will have to run SSH server (openssh-server) which some of them may already have installed. When the server is installed you should be able to login to that mini PC over the network from a terminal (assuming both computers are in the same network - connected to the same router):

ssh pi@192.168.1.100

Where pi is the username (login) on that mini PC. 192.168.1.100 is the IP address of that device within the local network. Beaglebone or other PC would have different users in the system so the username will be different. The IP address must be found. You can find the IP listed in the router control application where it lists connected devices. You can also use scanning tools like nmap on Linux or more user friendly iOS/Android mobile scanning apps like Fing. If you have no tool to do that you may try to guess it. If your main PC got 192.168.1.100 IP then the next connected device should get IP ending with 101. You can use ifconfig in terminal (Linux) to see what's the IP of the PC.

When the login and IP is correct you will be asked to enter the user password. After that you will be logged in and you will be able to do whatever is doable from terminal - execute scripts, configure the system etc. You won't be able to use the graphics mode (desktop) that way.

Fing have found a Raspberry Pi connected to the network

Moving files over SFTP

If SSH server is working then you also can use SFTP to move files from and to the mini PC. SFTP is very similar to FTP. To conect to a mini PC using a file manager you may use a URL/path like this:

sftp://pi@192.168.1.100

The login and IP are the same as when doing SSH connection. Most if not all Linux file managers can accept such string/path and will connect.

Raspberry Pi accessed via SFTP

Mounting folders via SSHFS

Most IDE and code editors will expect local paths for files and applications to edit. There is a solution to remotely mount a folder from a mini PC on you main PC and edit files easily with any editor or IDE.

If you are using Linux then the solution is to use sshfs file system. Install it with sudo apt-get install sshfs on both computers and then you can mount a folder from a mini PC on the main PC with a command like this:

sshfs pi@192.168.1.100:/path/on/a/mini/pc /path/on/the/pc/ -C

Aside of IP and username we have to specify paths. The mini PC path must exist, like the folder with your code. To unmount the folder safely just execute:

fusermount -u /path/on/the/pc/

Remote desktop

Sometimes remote desktop is needed. Under Linux and within ARM mini PC reach there is VNC or RDP protocols that can be used. On mini PC you have to install VNC server:

sudo apt-get install xrdp tightvncserver

And on the main PC you will need a client. On Linux you may use vino, remmina or many other apps of that type. I used remmina in this article. Note that when installing VNC server it will ask to create VNC connection password you will need to connect via VNC.

Let us start with RDP connection. We need the IP, user login and password. If everything is installed and entered correctly you should get mini PC desktop in a window on your main PC.

RDP connection configuration in Remmina
Remote Raspberry Pi desktop on another PC

Not that such remote desktop won't have the responsiveness and capabilities of a native desktop. You may find some animations slow, and some applications UI may not render nicely. Not that there are many VNC clients and they use various settings.

In the case of a VNC connection we have to start the server via SSH:

vncserver :0 -geometry 1920x1080 -depth 24

you can set lower resolution if needed or limited by the mini PC. Connection configuration would look like so:

VNC connection configuration

Remote Python in PyCharm

Python has great development environments like PyCharm. It can't run on Raspberry Pi and similar mini PC, but can be configured to use Raspberry Python interpreter over SSH. You will get support for it unique libraries (like for the GPIO) as well as you will be able to execute the code from the IDE on your PC if configured.

First we can start with adding mini PC Python interpreter via SSH:

Adding remote Python interpreter

Adding remote Python interpreter

Raspberry Pi Python interpreter

In case of Raspberry Pi indexing all of it interpreter libraries took a while. PyCharm also wanted to install setuptools and pip. After that you can use this interpreter when writing code. It will recognize RPi specific libraries, will give code completion tips as well as you will be able to jump to the imported module.

You may write code on the main PC and deploy it on the mini PC - either via SFTP or with more advanced solution like fabric deploy scripts. In case of PyCharm we can also play with SSHFS mounted folder - but it may be annoying if the connection breaks and the folder unmouns.

PyCharm and SSHFS

For an example I've mounted /home/pi from Raspberry Pi on my main PC. Then I used the mount point as project folder in PyCharm. I used the remote Raspberry Pi interpreter. Now to execute the code from PyCharm we have to tell it where it actually is for the remote interpreter. Go to Run → Edit configuration in PyCharm. We have to set the paths that are correct for Raspberry Pi and not for the main PC - so /home/pi:

Path configuration for remote script execution
Script executed from PyCharm that is on Raspberry Pi
Jump-to imported module
RkBlog

Check out the new site at https://rkblog.dev.
Comment article
Comment article RkBlog main page Search RSS Contact