[Making a Raspberry Pi Tablet] Part 1. Touchscreen Setting

In this project, I’m making a Tablet PC with a Raspberry Pi with Raspbian and a LCD Touchscreen display. I bought a LCD Touchscreen from chalkboard electronics.

Before designing the tablet, I had to set up the touchscreen. The biggest problem that I had was the power output of Raspberry Pi’s USB was smaller than the power needed from the touchscreen. These are the steps that I went through.

  1. Change power source of the touchscreenAt first, I changed power source of the touchscreen, because I wanted my tablet to have one power source(battery). Therefore I have to use a battery for the Raspberry Pi, and power the touchscreen through Raspberry Pi’s USB. To change the power source, you can look up this link.
    You need to de-solder and solder to change the power source of this Touchscreen. So if you don’t have soldering tool, then I recommend you to use different product.
  2. Lower the brightness of the touchscreen
    I said, Raspberry Pi’s USB output current is <500mA.  And the Touchscreen’s default current is 1.2A. I can lower the consuming current of the touchscreen by decreasing brightness of touchscreen’s backlight. If you see their webpage, they provide method to decrease back-light brightness(link). But if you have problem with that method, there is another option. Actually, I had problem with using HIDAPI, which they recommended. So I used different method.Basically what they are doing is sending hex code to HID device. You can do same thing with Pyusb with python.
    This is simple python script that I used.

    import usb.core
    import sys
    dev = usb.core.find(idVendor=0x04d8,idProduct=0xf724)
    # was it found?
    if dev is None:
        sys.exit("Device Not Found")
        #raise ValueError('Device not found')
    # set the active configuration. With no arguments, the first
    # configuration will be the active one
    # get an endpoint instance
    cfg = dev.get_active_configuration()
    intf = cfg[(0,0)]
    out_ep = usb.util.find_descriptor(
        # match the first OUT endpoint
        custom_match = \
        lambda e: \
            usb.util.endpoint_direction(e.bEndpointAddress) == \
    in_ep = usb.util.find_descriptor(
        # match the first OUT endpoint
        custom_match = \
        lambda e: \
            usb.util.endpoint_direction(e.bEndpointAddress) == \
    assert out_ep is not None
    assert in_ep is not None
    # write the data
    data = '\x00\x20\x0A ' #Report ID(0), Command, Backlight value
    ret = in_ep.read(in_ep.wMaxPacketSize)

    This code sets the brightness of backlight to 10. More detail protocol is in the webpage.

  3. Change setting of the Raspberry PiEven though you go through previous steps, you can’t use  touchscreen. If you plug HDMI and USB cable and power the Raspberry Pi, nothing shows up in the display. Still, you can see the backlight is on. When you power the touchscreen at the booting time, it works fine.

    I spent a lot of time to solve this issue. I couldn’t find out exact reason for this issue. But I guess Raspberry Pi’s USB turns on little late, so touchscreen can’t be turned on the booting time. As a result, Raspberry Pi can’t recognize the touchscreen.So  I change HDIM configuration. You can change HDMI settings in ‘/boot/config.txt’. I added below options in the file.

    hdmi_force_hotplug=1 #Use HDMI mode even if no HDMI monitor is detected
    hdmi_group=1 #Depends on the display's resolution
    hdmi_mode=39 #Depends on the display's resolution

    This options forces the Raspberry Pi to use HDMI with specific resolution. If you don’t set the resolution(hdmi_group, hdmi_mode), then the display output breaks. More detail explanation of config.txt is in this link.


So finally I powered the touchscreen with the Raspberry Pi.

In the video, you can see that the screen is unstable. I think that is due to unstable USB power during booting.


7 thoughts on “[Making a Raspberry Pi Tablet] Part 1. Touchscreen Setting

  1. i use touchscreen with usb power on the raspberry. I use a hub-usb 2 ports with alimentation. One port is take by the touchscreen and the second on the raspberry power. the usb management is on my usb raspberry. the hub-usb power is on my external battery 2,1A/5V 10000ma.
    it’s work perfectly.


  2. Hello, raspberry pi 3 isn’t more power. I think it was 1,2a for all usb and ethernet without usb_max_current option. I tested the screen on my pi3 and 10 minutes after power screen power off and power on and power off etc…. Since my test my screen is broken 😦 .


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s