27

We have a Pi3 connected to a TV on a remote worksite.

Sometimes, the remote site has a power outage, and when power is restored, the TV and Pi get power at the same time.

The problem is that the TV takes a while to power up, so when the Pi starts up, as far as it can tell, there's nothing plugged into its HDMI port.

Unfortunately, using the 2018-11-13-raspbian-stretch-full.img raspbian image (with the GUI), unless the TV is already powered up and plugged into the Pi when the Pi is starting up, the Pi will output nothing to the TV.

There's an option in /boot/config.txt called hdmi_force_hotplug=1 which is commented out by default. Uncommenting it causes the HDMI to be hot-pluggable.

The problem now is that if you plug a TV or monitor in after the Pi starts up, the resolution is horrible. It is way, way below the regular 1920x1080 that it normally runs at.

Our Pi automatically opens up a browser on boot to a particular page, and is totally unattended - there's no one to notice, or fix the resolution on site. We need it to be able to automatically fix itself if the TV is not detected on boot.

Does anyone know any way to fix this?

Edit: While there are a few answers below that are helpful, none really make the HDMI hot-pluggable. When a Desktop OS like Ubuntu/Fedora/Windows has a new monitor plugged into it, it detects it immediately, and adjusts the resolution on it immediately. It doesn't require a reboot, or a hard-coded resolution. The ideal solution would do something similar.

I would think that one way to do it would be to have a service constantly query the HDMI device for an EDID, and cache it. If the EDID changes, the device must have changed, and if the new device has a different preferred resolution, it should change the active resolution to match that.

I have no problems writing a service that can query the EDID, cache it, and see if a resolution change needs to be made. I'm just not sure how to use the terminal to change the Desktop's active resolution without a reboot. I'm not sure if I should be looking for a way to change the framebuffer resolution, or X Server's resolution, or the Desktop Environment's resolution, or all of the above.

John
  • 467
  • 1
  • 5
  • 10

4 Answers4

28

In /boot/config.txt:

hdmi_force_hotplug=1
hdmi_group=1
hdmi_mode=16

Those are explained here: https://www.raspberrypi.org/documentation/configuration/config-txt/video.md

There is also this: https://www.raspberrypi.org/documentation/configuration/hdmi-config.md -- But if the group 1, mode 16 as above works, you don't have to worry about all that.

goldilocks
  • 60,325
  • 17
  • 117
  • 234
7

In 'Raspberry Pi Configuration', select 'Set Resolution'

enter image description here

Choose resolution, then reboot.

enter image description here

CoderMike
  • 7,102
  • 1
  • 11
  • 16
1

I'm just not sure how to use the terminal to change the Desktop's active resolution without a reboot. I'm not sure if I should be looking for a way to change the framebuffer resolution, or X Server's resolution, or the Desktop Environment's resolution, or all of the above.

From my understanding, the Raspberry Pi GPU resolution is completely unrelated to the framebuffer resolution after boot. tvservice lets you change the GPU resolution, and tvservice -p will use the native resolution of whatever TV/monitor is plugged in. The framebuffer/X server (AFAIK the DE just uses the X server's resolution) is a trickier problem.

You'll need to use fbset to reload the framebuffer resolution. However, fbset will only actually reload the settings if you make changes. You could create a modified version without this limitation, or just do fbset -depth 32; fbset -depth 16 to set the depth to 32 and back to the default of 16 (if you're using a 32-bit framebuffer, switch the order).

Refreshing xorg is much simpler. While I believe changing the framebuffer resolution will set the xorg resolution automatically, windows will need to repaint. xrefresh (part of x11-xserver-utils) will do this for you.

leo60228
  • 121
  • 2
1

There actually exists an easy solution provided that the same (kind of) monitor is connected. The procedure is as follows:

  1. Boot the rpi with the monitor connected via hdmi. It should now work as usual.
  2. As the settings are now correct we can save them by the command sudo /opt/vc/bin/tvservice -d /boot/edid.dat.
  3. Next we modify config.txt by uncommenting hdmi_force_hotplug=1 and adding hdmi_edid_file=1.
  4. When one reboots without the monitor connected the rpi will still set the characteristics for the monitor according to the stored information in edid.dat.
  5. When plugged into the hdmi port, the monitor will come into action in a second or so.

For the RPi4 the procedure is slightly more complicated as there are two hdmi ports, but the idea is the same.

Good luck!

gkoper
  • 11
  • 1