Connecting the Raspberry Pi to an old (or not so) VGA monitor.

I have an old 15 inch VGA monitor optimized for a 1024x768 resolution which I have not used for a while. I thought it would be great to use it with my Raspi because it is quite small size, old and it creates that "retro" atmosphere that I love. But the thing  is not as easy as it may seem. In this post I will explain how I achieved this.

The first thing you need is an adapter to transform from HDMI signal (Raspi output) to VGA signal (Monitor input). The signal must suffer a transformation because HDMI is a digital signal while VGA is an analog one. Be careful with those cheap wires that have just a VGA port in one end and an HDMI port in the other one. They are useless for our purpose. The adapter you need may look like this (please excuse the cat...):

vga_adapter

You can find one of this in many sites, Amazon or eBay for example. I  bought this one for around 12 €. This model is great because it has also a jack port to get the sound that may come from the HDMI signal. So this is my Raspi connected to the old monitor using the adapter I got:

Raspi using HDMI to VGA adapter

Now when you turn on your Raspi three different things could happen:

1) You see everything perfectly in your VGA monitor. You are a very lucky person and you are probably wondering why I am writing this post.

2) You see a resolution that is not good for your monitor or that you do not want and you cannot change it.

3) You do not see anything in your monitor.

If your case is not the first one there is work to do yet. By the way, in my case it was the second one using Raspbian and the third one using Berryboot. I will be using the Raspbian example. When I turned on my Raspi I got a message from my monitor saying that it had to use a 1280x720 "failsafe mode" resolution which did not look very good:

1280x720, not proper resolution

I lost like a third of the screen using this resolution and the image and text quality was very poor. There was no way to change this resolution dynamically.

So now is the time to introduce the Raspberry's config.txt file. This file performs a basic configuration  when you turn on your Raspi and change its parameters would be like tuning the BIOS in a normal PC. So this file is the key to get our monitor working properly.

The config file is located at /boot/config.txt but if your case is the third one, and you cannot see anything on the screen, you can read the SD card in other PC and you will find the file at /.

You can find all the details, parameters and configurations for this file at:

http://elinux.org/RPiconfig

The problem is that setting the right parameter values depends on your hardware; your monitor, your hdmi-vga adapter and even your wire! You can spend much time tuning this file but here is the trick that worked for me:

There is one parameter called hdmi_safe that when enabled (hdmi_safe=1), it sets the proper parameters to maximize compatibility for HDMI. Reading from the RPIconfig site above:

hdmi_safe Use "safe mode" settings to try to boot with maximum hdmi compatibility. This is the same as the combination of: hdmi_force_hotplug=1, hdmi_ignore_edid=0xa5000080, config_hdmi_boost=4, hdmi_group=2, hdmi_mode=4, disable_overscan=0, overscan_left=24, overscan_right=24, overscan_top=24, overscan_bottom=24

If you type (or uncomment in some config.txt files) hdmi_safe=1, save and reboot you should boot using a 640x480 resolution:

640x480 proper but too low

Ok. That is a low resolution but it looks much better. So this "hdmi_safe" parameter did a good job. Now, to be sure of which parameters have been set, let's use a couple of commands again from the RPiconfig site:

vcgencmd get_config int - lists all the integer config options that are set (non-zero)
vcgencmd get_config str - lists all the string config options that are set (non-null)

In my case "vcgencmd get_config int" returned the following:

hdmi_safe=1
hdmi_mode=4
hdmi_group=2
hdmi_force_hotplug=1
disable_overscan=1
overscan_left=24
overscan_right=24
overscan_top=16
overscan_bottom=16
program_serial_random=1
config_hdmi_boost=4
hdmi_ignore_edid=0xa5000080
temp_limit=85
force_pwm_open=1

And "vcgencmd get_config str" did not return anything.

Therefore the group of parameters enabled do not match the ones RPiconfig indicates when hdmi_safe is activated. That's why I recommend to use vcegencmd command, to be sure of which parameters are really set. Now the only thing left to do is to change the 640x480 resolution to 1024x768 and remove the "padding" you can see in the image above.

The resolution has to be with the "hdmi_mode" parameter, and you can see its possible values in the RPiConfig site. I will show some of them:

hdmi_mode=1 640x350 85Hz
hdmi_mode=2 640x400 85Hz
hdmi_mode=3 720x400 85Hz
hdmi_mode=4 640x480 60Hz
hdmi_mode=5 640x480 72Hz
hdmi_mode=6 640x480 75Hz
hdmi_mode=7 640x480 85Hz
hdmi_mode=8 800x600 56Hz
hdmi_mode=9 800x600 60Hz
hdmi_mode=10 800x600 72Hz
hdmi_mode=11 800x600 75Hz
hdmi_mode=12 800x600 85Hz
hdmi_mode=13 800x600 120Hz
hdmi_mode=14 848x480 60Hz
hdmi_mode=15 1024x768 43Hz DO NOT USE
hdmi_mode=16 1024x768 60Hz
hdmi_mode=17 1024x768 70Hz
hdmi_mode=18 1024x768 75Hz
hdmi_mode=19 1024x768 85Hz
hdmi_mode=20 1024x768 120Hz
hdmi_mode=21 1152x864 75Hz
hdmi_mode=22 1280x768 reduced blanking

...(truncated)

As you can see the hdmi_safe configuration used hdmi_mode=4 which corresponds to a 640x480 60Hz resolution. I will change this value to 16 that corresponds to 1024x768 60Hz which is perfect for my monitor. As you can imagine, the "padding" thing has to be with the "overscan_left", "overscan_right", "overscan_top" and "overscan_bottom" parameters. If you see my config, it is curious that  the "disable_overscan" is set and the overscan is working. I will set the four parameters I mentioned to 0 because I do not need any padding. My final configuration will be the following (remember that now we have to disable the hdmi_safe parameter):

hdmi_safe=0
hdmi_mode=16
hdmi_group=2
hdmi_force_hotplug=1
disable_overscan=1
overscan_left=0
overscan_right=0
overscan_top=0
overscan_bottom=0
program_serial_random=1
config_hdmi_boost=4
hdmi_ignore_edid=0xa5000080
temp_limit=85
force_pwm_open=1

Now I am ready to set or copy this parameters to the config.txt file and reboot. Everything looks great and now my monitor starts a new life working with my Raspi.

1024x768 perfect

1024x768 desktop

I hope this post can help you out.

Enjoy.

Posted on November 17, 2013 at 21:21 by Samuel · Permalink
In: Raspberry Pi, Raspbian · Tagged with: , , ,

14 Responses

Subscribe to comments via RSS

  1. Written by Ikem
    on July 2, 2016 at 01:27
    Reply · Permalink

    I'm curious, what adapter did you bought exactly?

  2. Written by Gioun Desk
    on May 28, 2016 at 06:40
    Reply · Permalink

    Hi samuel, even if i change the hdmi_mode i'm getting the same resolution (640x350, like this http://www.mendrugox.net/wp-content/uploads/2013/11/vga_640_480.jpg) over and over, i can't figure out what's the problem <.< can you help me?

    The monitor it's a 17" 1280x1024 75hz

    • Written by Mathew
      on July 2, 2016 at 02:29
      Reply · Permalink

      Did you set hdmi_safe=1?

      If you did it manually sets that resolution No matter what.

      Try force_hdmi=1

  3. Written by Mathew
    on April 29, 2016 at 09:10
    Reply · Permalink

    How to do using berryboot

  4. Written by Aerrios
    on April 3, 2015 at 23:30
    Reply · Permalink

    Thanks a lot! It works ;)

  5. Written by Yan
    on December 8, 2014 at 02:30
    Reply · Permalink

    Hi, thanks for the amazing tutorial !
    I was playing around, testing different display settings in the configure.txt file from the raspi gui.
    I set my "hdmi_mode = 6"
    After rebooting I saw the "press shift to boot into safe mode" screen and then my monitor just went black and I couldn't get nothing to appear on the screen.

    I tried to put the sd card in my laptop(Microsoft os) but I can't find the config.txt file. Any suggestions ?

  6. Written by Danny Virasawmi
    on September 30, 2014 at 05:47
    Reply · Permalink

    Worked perfectly for me! Thank you!

  7. Written by Marco
    on May 4, 2014 at 21:29
    Reply · Permalink

    I have bought the same HDMI/VGA converter. Thanks a lot for this guide, I had own this problem :)

    • Written by Samuel
      on May 5, 2014 at 11:09
      Reply · Permalink

      You're welcome. Thank you for your comment.

  8. Written by Praveen
    on April 14, 2014 at 23:40
    Reply · Permalink

    what to do when using kali linux ??....this thing works in others OS but there is no config.txt in kali linux....i put a config.txt file with all the configuration required but it didn't work. It stops at the very first screen...gives 1 green flash...

    PLEASE HELP...

  9. Written by carlos
    on February 25, 2014 at 18:53
    Reply · Permalink

    brilliant thanks

    • Written by Samuel
      on February 26, 2014 at 15:08
      Reply · Permalink

      You are very welcome Carlos :)

Subscribe to comments via RSS

Please leave a reply :)

Time limit is exhausted. Please reload CAPTCHA.