The Raspberry Pi supports HDMI-CEC natively through its HDMI port. No Pulse-Eight USB-CEC adapter is needed — libcec communicates directly with the Pi's built-in CEC hardware. This means you can control your TV over HDMI, or allow your TV remote to control the Pi, without any additional hardware.
Installing libcec on Raspberry Pi
libcec is available through the standard Raspberry Pi OS package manager. Open a terminal and run:
sudo apt-get update sudo apt-get install libcec6 cec-utils
This installs both the libcec library and the cec-client command-line tool.
Testing Your CEC Connection
With your Pi connected to your TV via HDMI and the TV powered on, run:
cec-client -l
This will list detected CEC adapters. You should see the Raspberry Pi's HDMI port listed. To scan the CEC network and see all connected devices:
echo "scan" | cec-client -s -d 1
Troubleshooting: TV Cannot Detect the Pi
If your TV cannot detect the Raspberry Pi's CEC, or the Pi cannot detect the TV, the most common fix is to force the HDMI output to always be active, even if no display is detected at boot.
Add the following line to /boot/config.txt (or /boot/firmware/config.txt on newer Raspberry Pi OS versions) and reboot:
hdmi_force_hotplug=1
To edit the file:
sudo nano /boot/config.txt
Add the line at the bottom, save with Ctrl+X, then Y, then Enter, and reboot:
sudo reboot
Common Commands
Turn TV on:
echo "on 0" | cec-client -s -d 1
Turn TV off / standby:
echo "standby 0" | cec-client -s -d 1
Monitor all CEC traffic (useful for debugging):
cec-client -m
Press Ctrl+C to stop monitoring.
Using libcec with Kodi on Raspberry Pi
If you are running Kodi on your Raspberry Pi (including via LibreELEC or OSMC), CEC support is built into Kodi and uses libcec automatically. You should be able to control Kodi using your TV remote without any additional configuration.
If CEC control in Kodi is not working, check that libcec is installed and that hdmi_force_hotplug=1 is set in your config.txt as described above.
libcec documentation: github.com/Pulse-Eight/libcec
libcec FAQ: libcec.pulse-eight.com/faq
Submit a support ticket
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article