Archive for July, 2012

Connecting a Color lcd (MI0283QT-2) to the raspberry pi.

I started to look at the SPI interface of the raspberry pi for only one purpose, to be able to to use it as a control panel for some hacking project.
I had a LCD Screen laying around that I bought at watterrott so I decided to connect it to my raspberry pi.


The MI0283QT-2 module is a nice 2.8” Color LCD with a resolution of 320×240 controlled by a hx8347 controller and a touchscreen based on the ADS7846 controller.
Since the spi interface is 3.3 – 5 V tolerant, it is directly compatible with the raspberry pi, cool.

Connection to the raspberry-pi

C++ Library

The guy from watteroot is providing an ardurino library for controlling the LCD. I decided to start from it to quicly have some working code.
In fact, it was not so easy to implemented since I have barly no experience in C/C++ and the spidev was a huge mystery at that time.
Hopefully, I managed to make it working, and here is the result of my work. The code is available from github.
At this time only the LCD library is implemented, I will work on the touch screen library as soon as this come as a priority to me
As usual feel free to check the code, and use as you wish. You will quickly see it is really a quick port.

Tips :

  • You need a kernel with a SPI library. I only tested on Chris boot kernel
  • For performance reason, some functions are sending quite big SPI command. Make sure to load the spidev with a buffer big enough.
    modprobe spidev bufsiz=256000

Finding that I need that parameter was not easy, the only symptom was that all screen was not clearing. After couple of hours I noticed that only function which was sending less that 4096 bytes were working.

The library does not directly support to set the led light level. However if you connect the led pin to the GPIO18 you can control it using the WiringPI gpio tools.

gpio -g mode 18 pwm
gpio -g pwm 18 100
gpio -g pwm 18 300
gpio -g pwm 18 500
gpio -g pwm 18 1000

Building instructions

git clone
cd MI0283QT2-pi/demo
gcc -lstdc++ -iquote ../MI0283QT2 BMPDemo.cpp ../MI0283QT2/MI0283QT2.cpp ../MI0283QT2/font*.c -o BMPDemo
gcc -lstdc++ -iquote ../MI0283QT2 demo1.cpp  ../MI0283QT2/MI0283QT2.cpp ../MI0283QT2/font*.c -o demo1
gcc -lstdc++ -iquote ../MI0283QT2 gameoflife.cpp  ../MI0283QT2/MI0283QT2.cpp ../MI0283QT2/font*.c -o gameoflife

In actions


Demo of the lib functionalities

Game of life

What next

For the moment I am trying to implements a framebufffer driver for this device. This will allows any king of gui application to work on this lcd, including the console at the boot time.
The current status is that I am able to clear the sceen. I have to admit that it is not easy task, mainly because I am lacking of C experiences, linux kernel development experiences and I do not know the kernel SPI interfaces at well. But that really challanging job.

Edit 15 March 2013
The information in this blog entry is rather oudated.
Here some informations about using a framebuffer based on my code, with support for the touch screen. MI0283QT2-pi Github project of Dronus
The model of LCD sold by Watteroot changed, and it is not compatible anymore with this code.
On the lallafa blog, you can find the appropirate frame buffer for this new LCD Watterott MI0283QT-9A Display for the Rasbperry Pi.
You can also find a true framebuffer for the old version of LCD on the same blog Watterott Display on Raspberry Pi