Is anyone can assist me how to set up 3.5 inch Waveshare touch screen display works in Android Things on Raspberry Pi 3?

Usually, I only run script from LCD Show for 3.5 inch that available in Waveshare site. But android doesn't support sudo which used in that script.

I'll use it to develop mobile device app system. So it will need display that come handy for mobile use. Any other display with hdmi connection works perfect as it is easy to setup. But it will need more power source. While portable battery that come with 2 power output only provide a single port with 2.1 Ampere. The other one only provide 1 Ampere. And I have no luck looking for portable battery that comes with 2 port with 2 Ampere output.

Does anyone have successfully setting up 3.5 inch display to Raspberry Pi 3 with Android Things? Or how do I setting the SPI pin to succesfully connect to 3.5 inch Waveshare display?

  • i would like to know if you have your setup working already? Let me know if you do, otherwise I would like to collaborate.. I am dealing with the same kind of problem :)
    – thanten
    Commented Aug 29, 2017 at 5:39
  • @thanten I ended up buying another display. Waveshare 5 inch LCD (B) Rev 2.1. It is working fine, even without including ads7846 parameter in config.txt. It uses usb interface as touch + power.
    – adadion
    Commented Aug 29, 2017 at 10:02

2 Answers 2


I got touch input working for my Waveshare touch input display running on Android Things.

There is a demonstration on Youtube. I also go it working on a KeDei 3.5" touch input display. They both use the XPT2046 touch controller although the KeDei details are a little bit different.

I based my work on this driver for sending touch events to the Android OS and on BitBank's C code for SPI reading.

The driver is available as an Android Things Library project here: https://github.com/dirkvranckaert/touchinputdisplaydriver

All the details for using the driver are in the readme of the project. Your display is waveshare 3.5" so your resolution will be different. So to initialize the library you will need something like this: WaveshareProfile.getInstance(new ScreenDimension(800, 480, ScreenDimension.Ratio.R_4_3)); and then replace your dimensions and ratio. Please let me know if you have verified this to be working or not. If it works I'll add your dimension settings, if not I would be glad to work with you to get the library compatible for you as well!

The full detail on how I have implemented this library is available in a medium article: https://medium.com/@dirkvranckaert/android-things-and-touch-display-compatibility-b013a77a8bb8

  • Nice! I will be waiting and test it myself. Cheers.
    – adadion
    Commented Oct 14, 2017 at 8:47
  • @adadion I've updated the answer with library and the details you will need to get your display working. Let know if I can help you out! Commented Oct 15, 2017 at 12:36
  • Does this work with Lineage OS 14.1 for Raspberry too? I'm having problem getting the XPT2046 touch controller to work on Raspberry Pi 3 B. Commented Sep 1, 2018 at 12:58

If you can access GPIO pins and SPI from your Android program you can use code I've written (in C) to talk directly to that display:


Select the HX8357 display type; it's the LCD controller used in that display. I provide simple functions for reading the touchscreen position, drawing pixels, rectangles, tiles and text. If that's enough for your project, it's pretty easy to use my functions.

  • sorry for late follow up, it uses XPT2046 touch controller
    – adadion
    Commented Aug 2, 2017 at 7:03
  • If you look in the code for my project Iisted above, I added code to read the X/Y value from an XPT2046 touch controller too.
    – BitBank
    Commented Aug 2, 2017 at 13:12

Your Answer

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

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