Switch On/Off the HDMI port in Raspberry Pi 3

Sometime we need to switch Off or On the HDMI port on our Raspberry Pi 3.

Check the status of the HDMI port

To check the status of the HDMI port we can use the tvservice with parameter -s. Type:

sudo /opt/vc/bin/tvservice -s

If the HDMI port is OFF the output will be:

state 0x120002 [TV is off]

If the HDMI port is ON the output will be something similar to:

state 0x12000a [HDMI CEA (16) RGB lim 16:9], 1920x1080 @ 60.00Hz, progressive

Switch On or Off the HDMI port

To switch On the HDMI port we will invoke the tvservice with parameter -p:

sudo /opt/vc/bin/tvservice -p

The output will be:

Powering on HDMI with preferred settings

To switch Off the HDMI port we will invoke the tvservice with parameter -o:

sudo /opt/vc/bin/tvservice -o

The output will be:

Powering off HDMI

Switch Off HDMI on boot

To switch Off the HDMI port on every boot, you have to edit your /etc/rc.local. I will use nano to edit the file:

sudo nano /etc/rc.local

Now, add the following line above the exit 0.

# Disable HDMI
/opt/vc/bin/tvservice -o

Switching Off HDMI on boot can save about 30mA of current.

 

Leave a Reply