Mac Format

Remote control

Use virtual network computing to access different devices

-

I’m going to use a remote desktop server to connect to the Pi over Wi-Fi and log in to it from my Mac mini

The Raspberry Pi Zero uses a miniHDMI port as its video output. This is already a minor aggravatio­n, because you need an adaptor cable to convert to ordinary HDMI. The necessary adaptor costs more than a basic Pi Zero, but at least it’s a thing that exists and can be bought.

A more serious roadblock is that my 27-inch Thunderbol­t Display, which I wanted to give new purpose with this project, doesn’t have an HDMI port, and all the money in the world won’t buy me a cable to convert from HDMI to Thunderbol­t. Although Thunderbol­t ports are physically the same shape as Mini DisplayPor­t, the technologi­es are quite different and not backward compatible. You can connect a Thunderbol­t Mac to an HDMI monitor, but not the other way around. If you have a Thunderbol­t monitor, it will only accept input from a Thunderbol­t source.

A different connection

Obviously, I could just use a cheap HDMI monitor as a dedicated screen for the Pi. But it should be equally obvious, from the way I began this paragraph with ‘obviously’, that I’m not going to do that.

There is a 3D printer taking up the space on my desk where a second monitor would go, and I already have a beautiful Thunderbol­t Display in exactly the correct position for perfect ergonomic comfort. So instead, I’m going to use a remote desktop server to connect to the Pi over Wi-Fi and log in to it from my Mac mini, which is connected to the Thunderbol­t Display.

Virtual Network Computing (VNC) is a protocol to send

keystrokes, mouse input and screen updates over a network connection. There is a basic VNC client already built in to macOS. If you press ç+K in Finder to bring up the ‘Connect to Server’ dialog, you can enter the network address for a remote desktop server, such as vnc://pi.local:5901. The port number at the end depends on the server, but 5901 is a common default. This is great when it works, but that dialog is pretty forbidding and if port 5901 doesn’t work, it doesn’t give you any clues for what to do next. VNC Viewer (realvnc.com) on the other hand, only requires that I know the IP address of the server, which I can easily find by looking up the list of connected devices on my router. It has really solid support for all the desktop and mobile platforms I use and, like macOS’s built-in VNC client, it’s entirely free.

Inevitably, connecting through VNC results in some display lag. It’s much slower to send screen updates over Wi-Fi than an HDMI cable. But how serious is it? The VNC app’s window is rendered by the Mac on which it’s running, so I can drag or resize this portal to the Pi’s desktop instantane­ously. But as soon as you try moving windows that are running on the Pi, you’ll see the lag. Running the Pi at a screen resolution of 1920x1080 pixels, I get just one or two frames per second. If that sounds absolutely unplayable, that’s because it is. Remote Desktop is not a viable way to play games. But then the Pi Zero is hardly a games console to begin with. There is a version of Minecraft included with the default install, but it runs pretty slowly even on a directly connected monitor.

Over VNC, I get one frame every three seconds. Writing code – my intention here – is a much more reasonable propositio­n. The cursor still lags a few characters behind your key presses when you are typing, but it’s manageable. Coding is a lot more about staring at the screen than actually typing, anyway. When I know I have a large chunk of text to bash out at once, I have even experiment­ed with using a text editor natively on the Mac, and then cutting and pasting this into the VNC window to send it to the Raspberry Pi. VNC has an option for cut and paste between

There’s some display lag; it’s slower to send screen updates over Wi-Fi than HDMI cable

virtual machines in its preference­s. This option is quicker, but it doesn’t feel natural and interrupts my concentrat­ion switching between macOS and the Raspbian OS.

A smaller screen

Now that the basic concept has been proved though, another idea occurs to me. Why not connect to the Pi from my iPad? VNC Viewer is available for iOS too, and it has very smart options for translatin­g touch gestures into mouse actions for resizing and scrolling. It also sensibly keeps the on-screen pointer offset from your finger, so you can see it. It’s still harder to point accurately with your finger than a mouse though, and my iPad mini’s screen resolution is much lower than the desktop Mac, so I have to drop the Pi to iPad’s native screen resolution of 1024x768 pixels to make it workable. This cuts down on the screen real estate, and I don’t really want to lose any more to the on-screen keyboard. So I prefer to use an external keyboard.

Now, I could plug a USB keyboard directly into the Pi, but the Pi uses micro-USB, so I’d need an adaptor cable. And besides, I like the freedom of leaving the Pi up on the bookshelf, plugged into the wall and connecting to it remotely. A Bluetooth keyboard works much better and the KKMoon keyboard (£12, kkmoon.com) is just the right size for my iPad mini, and includes a trackpad as well.

I have 3D-printed some clips to connect the iPad to the keyboard and now I can use my iPad like a tiny laptop. What I really like about this concept is that all the components are totally modular and cable-free. The iPad, keyboard and Pi can all run off their own batteries, and all are connected wirelessly. Depending on what I want to do, I can choose from iOS, macOS or Raspbian; a Thunderbol­t monitor or an iPad touchscree­n; a full-size keyboard or a tiny portable one. The only real drawback is that I have to constantly remind myself whether I should be pressing ç+C, swiping the trackpad and checking the frame rates in Minecraft, or pressing ≈+C, touching the screen and getting on with some real work.

 ??  ?? Some simple 3D-printed clips turn an iPad mini and a Bluetooth keyboard into an impromptu laptop.
Some simple 3D-printed clips turn an iPad mini and a Bluetooth keyboard into an impromptu laptop.
 ??  ?? If you enable direct capture mode, you can view apps that write directly to video memory, over a remote connection.
If you enable direct capture mode, you can view apps that write directly to video memory, over a remote connection.
 ??  ?? The tiny Raspberry Pi Zero, to the left of the keyboard, connects to the mighty Thunderbol­t Display through the magic of Virtual Network Computing.
The tiny Raspberry Pi Zero, to the left of the keyboard, connects to the mighty Thunderbol­t Display through the magic of Virtual Network Computing.
 ??  ?? Be prepared for some lag; it’s best to be pretty Zen-like about this ‘fix’.
Be prepared for some lag; it’s best to be pretty Zen-like about this ‘fix’.
 ??  ??
 ??  ?? You may not want to pen a novel with this kind of setup, but the Raspberry Pi adds a lot of flexibilit­y for coding.
You may not want to pen a novel with this kind of setup, but the Raspberry Pi adds a lot of flexibilit­y for coding.

Newspapers in English

Newspapers from Australia