HDMI CEC 到 USB HID 键盘适配器
A Raspberry Pi Pico based project to bridge HDMI CEC (Consumer Electronics Control) and USB HID keyboard control (especially for use with Kodi).
The reference hardware for pico-cec has been upgraded from RP2040 to RP2350. Support for RP2040 builds will continue where possible.
Micro/mini desktops are plentiful as second hand, budget friendly media players, especially when installed with Kodi (eg. LibreELEC). However, many of these devices do not support HDMI-CEC and require the user to use additional peripherals (eg. wireless keyboard, game controller).
In this project we use a Pico to both:
[!CAUTION] The build quality of the HDMI breakout boards is highly variable, thus pass through of 4K video may not function in all circumstances.
To avoid cloning unneeded code, clone like this:
git -c submodule.active="lib/tinyusb" -c submodule.active=":(exclude,glob){lib,hw}/*" clone --recurse-submodulesAlternatively, clone everything in pico-sdk and tinyUSB:
git clone --recurse-submodulesThis project uses the 'normal' CMake based build.
The build depends on cmake (obviously), gcc-arm-none-eabi, and libnewlib-dev.
Two boards are supported, and the RP2040 and RP2350 produce incompatible
.uf2 images, so build for the board you actually have:
$ git clone
$ cd pico-cecFor the Seeed XIAO RP2350 (current reference hardware):
$ cmake -S . -B build -DPICO_BOARD=seeed_xiao_rp2350 && cmake --build buildFor the Seeed XIAO RP2040 (legacy):
$ cmake -S . -B build -DPICO_BOARD=seeed_xiao_rp2040 && cmake --build buildSwitching boards requires a clean build directory (rm -rf build).
The CMake project supports three options:
$ cmake -DPICO_BOARD=pico -DCEC_PIN=11 -DCEC_OSD_NAME="Bazzite" ..
$ makeAssuming a successful build, the build directory will contain pico-cec.uf2,
this can be written to the Pico as per normal:
pico-cec.uf2 to the PicoA command line interface over serial port is available, the guide can be found here: Command Line Interface Guide
The RGB LED provides basic functional diagnosis:
If there are no lights, something is very wrong. If this occurs, please consider raising an issue.
This is currently working with:
The hardware connections are extremely simple. Both HDMI CEC and the Pico are 3.3V obviating the need for level shifters. The DDC bus (for EDID) is I2C and 5V, however, the Pico appears to be 5V tolerant.
Additionally, we rely on the GPIO input/output impedance states to read or drive the CEC bus. DDC is I2C requiring data and clock lines. Thus, we need to directly connect four wires:
For the Seeed Studio XIAO RP2350:
After this we:
Pico-CEC to the HDMI output of the PCPico-CECPico-CEC to the PCThe enclosure is a reasonably simple three piece sandwich 3d print modelled with OpenSCAD. It is designed to be printed as three separate pieces which are bolted together with M3 nuts and bolts. An exploded preview of the result can be found in this STL.
The software is extremely simple and built on FreeRTOS tasks:
The CEC task comprises three major components:
cec_frame_recvcec_frame_sendAll the HDMI frame handling was rewritten to be hardware/timer interrupt driven to meet real-time constraints. Attempts to increase the FreeRTOS tick timer along with busy wait loops were simply unable to consistently meet the CEC timing windows.
These are simple FreeRTOS tasks effectively taken straight from the TinyUSB examples.
This project uses:
| Component | Quantity | Price (January 2026) (AUD) |
|---|---|---|
| Seeed Studio XIAO RP2350 | 1 | 10.60 |
| HDMI male/female adapter | 1 | 4.30 |
| M3x10mm bolt & nut | 2 | 0.16 |
| M3x20mm bolt & nut | 2 | 0.17 |
| Random short wires | 4 | basically free |
| Scunge 3D print from friend | 1 | mostly free |
| Umpteen hours of engineering | 1 | priceless |
| Total | 15.23 |
As of v0.2.2, pico-cec now passes the cec-compliance test suite found in the
Linux v4l-utils package.
More details can be found in the wiki entry:
https://github.com/gkoh/pico-cec/wiki/CEC-Compliance-Testing
Furthermore, pico-cec has been able to survive one hour of cec-compliance fuzz
testing.
A command line terminal over serial port is supported. Details can be found in the wiki entry: https://github.com/gkoh/pico-cec/wiki/Command-Line-Interface-Guide
In particular, debug on will log all CEC traffic to the terminal.
Inspiration and/or ground work was obtained from the following:
暂无开放 Issues,或尚未同步最近议题。