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?

Devin
  • 11
  • 1
  • 3
  • (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 '19 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 '19 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 '19 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 '19 at 12:45
  • this is the first discussion I joined in: https://raspberrypi.stackexchange.com/questions/99963/hdmi-power-circuit-on-the-raspberry-pi-4. The TI app notes I commented might be useful. PS the TI link seems broken. Here is a new one: http://www.ti.com/lit/an/snva412b/snva412b.pdf. – tlfong01 Sep 25 '19 at 12:47
  • @tlfong01 Do you happen to have the PDF handy? The link you provided in that comment does not exist anymore! – Devin Sep 25 '19 at 12:50
  • Yes, it is my mistake. The link is in my updated comment above. – tlfong01 Sep 25 '19 at 12:54
  • And you might like to read my comments on another HDMI question. https://raspberrypi.stackexchange.com/questions/101074/raspberry-pi-4b-no-video – tlfong01 Sep 25 '19 at 12:58
  • And in case you have not read it, this is the schematic showing the Rpi4B HDMI connector: https://www.raspberrypi.org/documentation/hardware/raspberrypi/schematics/rpi_SCH_4b_4p0_reduced.pdf – tlfong01 Sep 25 '19 at 13:02
  • I see that the Rpi uses I2C to talk to the HDMI. So if Rpi shouts something (Don't ask me what is "something", because I don't know, just wild guessing) to HDMI and gets no reply, then someone has pulled the plug! :) – tlfong01 Sep 25 '19 at 13:08
  • @tlfong01 I guess I understand that there is a 5V power supplied to the monitor from the Pi, but after reading the links you gave me I found no information if monitor power state can be determined from the HDMI spec alone. I'm also not very well versed in electronics on this kind of level that we're getting to. EDIT: I'll take a look at the I2C information you just commented as well – Devin Sep 25 '19 at 13:12
  • (1) Yes so earlier I hinted that it is not a good idea to mess around with the HDMI connector hardware. (2) The I2C method is not easy, because you might need to look into the driver and make changes to the software, But the hardware might explode! (3) If I really need to do it, I will try something like this: open the HDMI monitor chassis, find the 5V/12V power circuit and extract two wires 12V/Ground, or 5V/Ground out to the Rpi side, convert it to 3V3, and let Rpi GPIO to read it. Again, not recommend for newbies, because the monitor also will explode~ :) – tlfong01 Sep 25 '19 at 13:22
  • @tlfong01 Yeah I think for my situation this is not possible. Thank you so much for all of the information you gave me! I read this blog post, but it seems too much work for my application. Very interesting stuff indeed, thank you. – Devin Sep 25 '19 at 13:27
  • Ah, your I2C HDMI article is good. Have not read it before. Article also warns newbies not to do it. Modifying the kernel (similar to driver) is difficult. Bad thing about driver is even it works one OS version, it might not work next version, so monitor still explodes, only later. I2C over HDMI: http://blog.koalo.de/2013/11/i2c-over-hdmi.html. Nice to solve problems with you. I usually enjoy solving problems though fail eventually (Like I often got beaten up in squash games, but I still enjoy it every time! :) Cheers. – tlfong01 Sep 25 '19 at 13:52

2 Answers2

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.