1

Main Question: Can my raspberry pi (powered on it's own) determine if power is being supplied to the monitor (powered by a wall plug)?

I'm trying to determine the power state of the display that is connected to my Raspberry Pi 4.

The following was tried with force_hdmi_hotplug=1 inside /boot/config.txt

By default, I've had this option on inside /boot/config.txt because a while ago I was testing this and without force_hdmi_hotplug=1, reconnecting the hdmi cable would not actually turn on the display (the raspberry pi would stay in VGA mode or something).

I have tried using tvservice, but it has not led to any good results. Using tvservice -M (monitor), I found the following results:

  • Disconnecting the display via the HDMI cable from the raspberry pi will yield no events being detected
  • Reconnecting the display via the HDMI cable from the raspberry pi will yield no events being detected

Using tvservice -s (status), I found the following results:

  • state 0xa [HDMI] when connected
  • state 0xa [HDMI] when disconnected

The following was tried with force_hdmi_hotplug=1 NOT INSIDE (disabled) /boot/config.txt

tvservice -M

  • Disconnected the display via the HDMI cable from the raspberry pi will yeild HDMI cable is unplugged.
  • Reconnecting the display via the HDMI cable from the raspberry pi will yield HDMI is attached

tvservice -s

  • Disconnected the display via the HDMI cable from the raspberry pi will yeild state 0x9
  • Disconnected the display via the HDMI cable from the raspberry pi will yeild state 0xa

However, disconnecting the monitor power cable with the HDMI still plugged in will yield the following two events simultaneously:

  • HDMI is unplugged
  • HDMI is attached

tvservice -s will still yield state 0xa and even using xrandr will say that a display is connected. xrandr -display :0 --listmonitors will still list a monitor.

Is what I'm looking for even possible?

14
  • (1) I don't understand your question. Do you want to know if the monitor power (eg 200VAC) is switched on? (2) Rpi has it own little 5V power for the HDMI logic circuit. (3) Even HMDI monitor power is NOT switched on, Rpi will still give 5V power to the HDMI logic cct to determine its configuration. In other words, Rpi will check out the mon config even mon has no AC200V power!
    – tlfong01
    Sep 25, 2019 at 12:27
  • @tlfong01I just read about the 5V power being sent from the RPi! I guess I'm wondering if, from the monitor config, if power is being supplied from a wall. I would like to know if someone has unplugged the power source to the monitor (which is different from the Pi)
    – Devin
    Sep 25, 2019 at 12:30
  • I see what you want, I need to check out the HDMI connector to see if you can do that without messing with any hardware.
    – tlfong01
    Sep 25, 2019 at 12:43
  • @tlfong01 Thank you! I've been reading for a while that the 5V supplied by the Pi to the monitor can return statistics (like what you said), but I can't find out what kind of statistics are returned other than resolutions/fps/etc. I'm looking for power status along with that info
    – Devin
    Sep 25, 2019 at 12:45
  • this is the first discussion I joined in: raspberrypi.stackexchange.com/questions/99963/…. The TI app notes I commented might be useful. PS the TI link seems broken. Here is a new one: ti.com/lit/an/snva412b/snva412b.pdf.
    – tlfong01
    Sep 25, 2019 at 12:47

2 Answers 2

1

I was struggling with this also. You can toggle power to the hdmi display by using

vcgencmd display_power 1  # on
vcgencmd display_power 0  # off

and you can query the power status by just using

vcgencmd display_power   # will return 1 or 0

Cheers

0

I was also trying to solve the issue, but none of the mentioned method worked for me, but found a solution. Despite my TV doesn't support HDMI CEC interface, running the command 'cec-client -r' printed different results on 'power status' event when the TV was OFF (printed: standby) or ON (printed: some invalid response error).

A python library 'python-cec' is also available, where the device.is_on() function results False when the TV is OFF, and raises an Error when it's ON.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.