Raspberry Pi Based Ethernet to HDMI Adapter for Linux Laptops and Desktops

by pierre-couy in Circuits > Raspberry Pi

2112 Views, 15 Favorites, 0 Comments

Raspberry Pi Based Ethernet to HDMI Adapter for Linux Laptops and Desktops

banner-rpi-eth-monitor.jpg

Have you just bought a laptop, assuming you would be able to plug an USB-C dock into it to add an HDMI port ? Were you disappointed to find out that your new computer did not support DisplayPort over USB-C ? Well, I did, and the downgrade from 3 to 2 screens was not an option.

This project describes how I overcame this limitation. By following this Instructable, you will be able to turn a Raspberry Pi into an Ethernet to HDMI adapter for your Linux computer. With the main goal of providing an experience that is as close to using a regular display as possible, I tried hard to make a solution that matches the requirements below :

  • The latency should not be noticeable when scrolling or moving the mouse
  • The picture quality should be high enough to read small text
  • If the receiving end of the stream ever gets behind, it should catch-up to live as quick as possible
  • The monitor that is attached to the Pi should automatically go into sleep mode when the host computer stops streaming
  • Use Direct Rendering Manager to display the stream on the Pi instead of depending on a X server.
  • This will not stream inputs from the Pi to the host computer : this is not a remote gaming solution

In this tutorial, I will guide you through the fastest past to a working setup by using the configuration files and install scripts from the GitHub repo. If you are interested in more technical details, you can read the write-up of the process I went through while making this project.

Supplies

  • A Raspberry Pi. I used a Raspberry Pi 3, and some of the instructions below may depend on the model you are using. With that in mind, the main part of the project should work fine with more recent models. You may even have success with earlier models. You'll need the following parts, often found in Raspberry Pi starter kits :
  • A micro SD card (4GB minimum)
  • A power supply
  • (Recommended) A case
  • (Recommended for models that do not have onboard WiFi) A WiFi dongle
  • There are a few requirements for the host computer you intend to run this with :
  • Running Linux : you will need to install some dependencies and tweak some configurations on the host computer. I'm not knowledgeable enough with Windows or MacOS to provide instructions for these OSes.
  • Running an X server : this does not support Wayland (you may be able to adapt the relevant parts if you're familiar with Wayland)
  • Using an Intel integrated GPU : this does not work with Nvidia or AMD GPUs
  • An Ethernet port, or an USB dock that adds one
  • An Ethernet cable to connect the host computer to the Raspberry Pi
  • An HDMI cable to connect the Raspberry Pi to the monitor

As of writing this guide, Raspberry Pi are pretty expensive due to the global chip shortage. This makes the commercial alternatives a lot cheaper than buying all the supplies specifically for this project. However, all commercial alternatives require you to install proprietary drivers on the host computer. Moreover, they seem to often lack first-class support for Linux. You should only try to follow this guide if one of the following applies to you :

  • You already have most of the supplies laying around unused
  • Proprietary drivers are a big "no" for you
  • You are mostly interested by the DIY aspect of the project

If you are feeling like overcoming one of the limitations of this project (mainly regarding the host computer requirements), I strongly recommend you read the write-up instead, and get in touch with me on GitHub if you need help.

Software dependencies


On the Raspberry Pi side, we will be using the following software :

  • ffplay (from ffmpeg) to display the stream
  • tcpdump to count the packets from the host computer (for power management)
  • udhcpd to manage the LAN between the host computer and the Pi
  • supervisord to manage the ffplay and tcpdump processes

On the host computer :

  • ffmpeg to grab the virtual screen, encode it and stream it to the Pi
  • xrandr : After following these instructions, running xrandr on your computer should call a wrapper that will automatically start the ffmpeg stream when using the VIRTUAL1 display. This also works when using a GUI for xrandr, such as arandr

Prepare the SD Card

Flash an SD card with a Raspberry Pi OS image. You can download the latest versions from the official website (I recommend using the "Lite" image as we won't need a graphical environment).

Then, run the commands below (you will need to change the second one to match the image file you downloaded and the SD card block device) to flash the image to the SD card :

pierre@laptop:~ $ lsblk -f # Identify SD card block device
pierre@laptop:~ $ sudo dd if=[date-of-image]-raspios-[version]-arm64-lite.img of=/dev/sd[SD card letter]

After doing this, put the SD card in the Raspberry Pi and boot it with a screen and keyboard attached (no mouse required). This will automatically resize the partition to use the full space of the SD card. After the Pi has finished booting, run `sudo raspi-config` on the Pi to enable WiFi and SSH (you can read the documentation from the official Raspberry Pi website on how to do this). After this, you will no longer need a keyboard attached to the Pi as you'll be able to SSH into it.

Install on the Raspberry Pi

This step should be really straightforward as the installation script takes care of everything and no manual intervention is required.

Using either a keyboard or SSH, install git using :

sudo apt-get install git 

and clone the repository : 

git clone https://github.com/pcouy/rpi-eth-display.git

You can now run the install script as root using :

sudo rpi-eth-display/rpi/scripts/install.sh

This script takes care of installing all dependencies on the Pi. This step will make the Raspberry Pi be ready to display a stream from its Ethernet port to its HDMI monitor after every boot.

On the Host Computer (part 1 : Install)

Similarly, clone the repository on the computer you want to stream from, then run the install script (but this time as your regular user) : 

git clone https://github.com/pcouy/rpi-eth-display.git
rpi-eth-display/laptop/scripts/install.sh

You will need to reboot your computer for the VIRUTAL1 screen to show-up.

On the Host Computer (Part 2 : Using It)

Plug the Ethernet cable into the host computer and the Raspberry Pi, and then re-run the install script :

rpi-eth-display/laptop/scripts/install.sh 

It will detect that the VIRTUAL1 screen already exists, and prompt you for its size in pixels. You will need to re-do this once after every reboot.

If everything was setup correctly, you should be able to start a stream simply by enabling the VIRTUAL1 display in xrandr or any of its GUI, such as arandr. The wrapper will auto-start ffmpeg using the right options.

If you disabled WiFi on the Pi, you should still be able to SSH into it using the eth link. The Pi's IP address on this interface is 10.0.0.1.