DIY PiKVM using Raspberry Pi Zero 2 W with OLED screen

Windix Feng
3 min readSep 23, 2023

--

Updated 08/07/2024: changed some of the commands to the latest

Just a quick note on DIY PiKVM with Raspberry Pi Zero 2 W.

The benefits of using Pi Zero 2 W: except small size and (relatively) cheap price, it only needs a single USB cable (connect to OTG port) for both power and USB controls (keyboard + mouse + OS image). Pi Zero 2 W is also powerful enough to deliver H.264 30 frames 1080p stream (Pi Zero W cannot support it).

When switching from Pi Zero W to Pi Zero 2 W, please use corresponding version of images. they are not interchangable for the HDMI-CSI module.

Hardware (total ~AUD $100):

  • Raspberry Pi Zero 2 W (ordered from Core Electronics for AUD $29.50)
  • HDMI Adapter Board HDMI to CSI-2 TC35874XBG (ordered from eBay for AUD $63.99, comes with cable)
  • 0.96" i2c OLED screen 128x64 (~AUD $8)
  • 3D printed case, model from https://www.thingiverse.com/thing:4915627
    (I open an ugly hole to install OLED screen 😆 Should change the model file to do it nicer)
The 3D case design is so nice that there is no need for any screws. Between the two boards there is a spacer.

Tips for installing CSI cable (aka Pi camera cable): the metal pins should always be faced down.

OLED connection pinout:

Pi              OLED
[1] 3.3V <--> VCC [2]
[3] SDA <--> SDA [4]
[5] SCL <--> SCL [3]
[6] Ground <--> GND [1]

Software:

The latest version of DIY — Raspberry Pi Zero 2 W, V2 platform: For HDMI-CSI bridge (details in Flashing the OS image)

The actual version of KVMD at the time of writing is 3.229

Setup:

1. Flash the SD card

2. Update with Wifi info to /boot/pikvm.txt :

FIRSTBOOT=1
WIFI_ESSID='mynet'
WIFI_PASSWD='p@s$$w0rd'

3. After first boot, login to SSH via root / root

From now on, need to enable readwrite mode by running rw first before any commands below. Can exit back to readonly mode with ro.

4. Enable i2c for OLED (source):

  • Add dtparam=i2c_arm=on to /boot/config.txt
  • Add i2c-dev to /etc/modules-load.d/kvmd.conf

5. Enable OLED systemd script (source):

systemctl enable --now kvmd-oled kvmd-oled-reboot kvmd-oled-shutdown

After running above if you see below errors, you can ignore them. It is because of i2c will only be enabled after reboot.

Job for kvmd-oled-reboot.service failed because a fatal signal was delivered to the control process.
See "systemctl status kvmd-oled-reboot.service" and "journalctl -xeu kvmd-oled-reboot.service" for details.
Job for kvmd-oled-shutdown.service failed because a fatal signal was delivered to the control process.
See "systemctl status kvmd-oled-shutdown.service" and "journalctl -xeu kvmd-oled-shutdown.service" for details.

6. Change the initial passwords.

Change console password for root (default is root):

passwd

Change web access password for admin (default is admin):

kvmd-htpasswd set admin

6. Setup timezone:

timedatectl set-timezone Australia/Melbourne

7. From time to time, to update system:

pikvm-update
reboot

If pikvm-update comes back with command not found error, just reimage with the latest image, or run the following to install pikvm-update first:

pacman -Syy
pacman -S pikvm-os-updater
pikvm-update

References:

kvmd-oled script: https://github.com/pikvm/packages/blob/master/packages/kvmd-oled/kvmd-oled.py

--

--