Home > Blog

Using Serdisplib Library to Drive Mobile Phone LCD

17 Aug. 2007

This article was published in the “Do-It-Yourself” section of May 2008 issue of Electronics For You (EFY) magazine. This was the first time when I was paid for writing an article. I have been reading the EFY magazine since I was 12 and therefore I was delighted to see my name in one of the articles of this magazine. Furthermore, I contributed code to serdisplib project to add support for Nokia 6100 LCD. The following downloads are available for this article:


The availability of high resolution LCD as a spare part of mobile phone has opened a new world of colored display for electronics and computer interfacing hobbyists. You will be surprised to know that 16x2 characters LCD is not available in the place I live whereas high resolution LCD of mobile phones can be found easily at very low prices.

Understanding the protocol for communicating with such LCD and writing programs to drive them can prove to be a very time consuming and frustrating job. Fortunately an open source project, serdisplib[1], exists that does this job for us.

Serdisplib[1] is a project maintained by Wolfgang Astleitner and hosted at sourceforge.net. Started in July 2003 with support for only one LCD, this project has grown to add support for 25+ different LCD. It supports several mobile phone LCD, USB based LCD and OLED displays.

In this article, we will focus on setting up Nokia 6100 (S1D15G10 controller - green connector) LCD to work with serdisplib. Then with some python scripting and 'multidisplay' (a tool shipped with serdisplib package), we will use our setup to create an application that will show alert message in the LCD screen when a new email arrives into a specified Gmail mailbox.

The discussion in this article only applies to Nokia 6100 LCD (S1D15G10 controller - with green connector). However, with some minor changes other LCDs can easily be used for the interfacing purpose using the techniques discussed below. Support for Nokia 6100 LCD was added in serdisplib-1.97.6 release[2].

Generating the voltages required by LCD

The LCD requires two voltages 7 V and 3.3 V (as given in LCD datasheet). We can use LM317 voltage regulator IC to generate these voltages. The circuit for generating desired voltage using LM317 is given in Fig. 1

Fig. 1: Circuit connection for LM317 to generate desired voltages
To obtain Vout = 6.8 V
R1 = 330 Ohm, R2 = 1.5 Kohm, Vin = 9V or 12 V
To obtain Vout = 2.8 V
R1 = 330 Ohm, R2 = 470 Ohm, Vin = 5V

Some notes:

Preparing the LCD for connection to Parallel Port

The pin separation of LCD connector (X302 10 pin male connector) is very small making it impossible to solder wires directly to the pins. Hence, we can use the corresponding female connector (easily found in mobile repair shops) to connect wires from parallel port to the LCD. This male connector can be soldered to a PCB having tracks to match the pin separation (this is quite difficult to find. I used a 32pin uSOP IC tracks, see Fig. 2, to solder this connector). The pin numbers (printed on the green PCB of LCD connector) can be seen in Fig 2.

Fig. 2: LCD connector
Fig. 3: LCD connected to X302 10 pin female connector mounted on PCB

Connecting LCD to the Parallel Port

Connect the wires from LCD to parallel port as shown in Fig. 5. The power supply circuit created in previous section should be used to supply required voltages to LCD [ Vlcd (Pin 5) = 2.8V, Vled+ (Pin 1) = 6.8V ]. You can test your LCD backlight by switching ON the power supply for 6.8V. Check the connections if the LCD backlight does not glow. Make sure that the ground of Parallel port is connected to the LCD ground and the power supply ground (ie: all of them have a common ground).

Fig. 4: Pin Diagram for LCD connector
Fig. 5: Circuit for connecting LCD to parallel port


Display some test patterns

Download the package serdisplib-1.97.6 (Note that earlier versions of serdisplib do not support Nokia 6100 LCD) from http://serdisplib.sourceforge.net and extract the package. Build the package using:

[root@tlm mydir]# tar –zxvf serdisplib-1.97.6.tar.gz
[root@tlm mydir]# cd serdisplib-1.97.6
[root@tlm serdisplib-1.97.6]# ./configure
[root@tlm serdisplib-1.97.6]# make
[root@tlm serdisplib-1.97.6]# make install

Now you are ready to test your LCD. We will use the testserdisp tool provided by this library to test our LCD.

[root@tlm serdisplib-1.97.6]# cd src
[root@tlm src]# ./testserdisp -n N6100
enter 'help' to get help

At this point you should see something like Fig. 6 in your LCD screen. If you see the welcome screen (with the LCD pixel size ie: 130x130 as shown in Fig. 6), then you have successfully setup your LCD. You can test other patterns issuing “p 0....9” (pattern command) in the command prompt displayed by testserdisp. If you don't see any output in your LCD, you can follow the Debugging steps discussed in the next section.

Fig. 6: start of 'testserdisp'
Fig. 7: pattern 2
Fig. 8: pattern 0


I had spent 3 weeks debugging my circuit (and the serdisplib code which did not support Nokia 6100 LCD at that time) and at last I found that I had connected the LCD just the other way. Yes, this is possible with the connector that these LCD have. Fortunately, this did not damage my LCD.

You can follow some of these debugging tips to find out the problem in your circuit.

  1. Make sure that the pins of LCD connector are identified correctly. If you connect it the other way, Pin1 will get connected to the line for Pin 6 and Pin 10 will get connected to the line for Pin 4. The pin numbering given in the Fig. 4 is for Nokia 6100 LCD with green connector. Other connectors can have different pin assignments. The LCD pins can be verified from the Nokia 6100 page[2] at serdisplib project website.
  2. Attach two LED to the SDATA line (Pin 8) and SCLK line (Pin 7). Make sure that these LEDs blink (very fast) when you invoke the command ./testserdisp -n N6100 in your computer. If these do not blink at all, check the connection of wires to your parallel port. Check that these lines are connected to correct pins of parallel port [ie: SDATA -> D0 (Pin 2 of Parallel Port), SCLK -> D1 (Pin 3 of Parallel Port), and so on. ]. Verify your connection with the circuit shown in Fig 5.
  3. Using a Voltmeter, check that you are applying correct voltages to the Vlcd pin (2.8V to 3.3V) and Vled(+) pin (6.5V to 7V). Vlcd pin voltage should never exceed 3.3V limit as it can cause permanent damage to the LCD.
  4. Make sure that the ground of Parallel port is connected to the LCD ground and the power supply ground (ie: all of them have a common ground).
  5. Verify the connection between parallel port connector and the LCD pins using a continuity tester (switch off your circuit and disconnect the parallel port connection).

Assuming that you have successfully setup the LCD and 'testserdisp' is working, we are ready to do something useful with this setup.

GmailToLCD application

With some python scripting and 'multidisplay' (shipped with serdisplib package), we will use our setup to create an application that will show alert message in the LCD screen when a new email arrives in any specified Gmail mailbox. See Fig. 9 to have a glimpse of the final application.

You will have to enable “POP Download” feature for your GMAIL inbox (disabled by default). Login into your GMAIL and go to 'Settings' -> 'Forwarding and POP' and then select the radio button for “Enable POP only for mail that arrives from now on” option. Save you mailbox settings. Now you can access new emails arriving into you mailbox using GmailToLCD application.

Notification in LCD when new email arrives

Now, let us discuss about the block diagram of this application shown in Fig. 10.

Fig. 10: Block diagram of GmailToLCD application

The python script 'gmailtolcd.py’ (see code listing) queries the Gmail POP server to check if any new email has arrived in the mailbox. When new mail(s) arrive, it uses the template image to create a new image (gmailbox.png) which contains the information about new email(s). The message details (From and Subject) are displayed only for the most recently arrived email. 'multidisplay' tool is then used to display the image (gmailbox.png) on the LCD screen.

multidisplay is a tool shipped with serdisplib-1.97.6 package ( in serdisplib-1.97.6/tools/ directory ). It is used to display images and text using serdisplib. You must install libgd[3] >= 2 ( GD is an open source code library for the dynamic creation of images by programmers. GD creates PNG, JPEG and GIF images, among other formats.) before compiling serdisplib. Multidisplay tool (and hence gmailtolcd.py script) will NOT work if serdisplib is compiled without installing libgd. To verify that, serdisplib is compiled with libgd support, check that configure script during the installation of serdisplib produces the result as shown below:

[root@tlm serdisplib-1.97.6]# ./configure
checking build system type... i686-pc-linux-gnu
supported features
* libgd >= 2 support ... yes

gmailtolcd.py - the script that is at the core of this application

The working of gmailtolcd.py script can be illustrated by the flowchart given in Fig. 11.

Fig. 11: Flowchart that illustrates the working of gmailtolcd.py script

Gmail POP server considers the emails in “Send Mail” folder (ie: the email messages you send from gmail) as new message. Hence, the script filters out all the new messages whose email address in “From: “ field matches the email address of the mailbox being checked. This is done to show only the new mail messages arriving in the mailbox. Without this filtering action, the emails in “Send Mail” folder of Gmail is also retrieved as new email message.

Limitations of gmailtolcd.py script:

  1. The script is not able to refresh the LCD screen when the user has checked (viewed) the new email from the web interface of Gmail. It keeps on showing the new message alert on LCD screen until another new message arrives. When new emails are retrieved from the Gmail POP server, they are marked as read by the server (but appears as NEW email in the gmail web interface). I did not find any technique to inform the script when the user reads new messages from the web interface.
  2. There should be some mechanism to turn off the power of LCD backlight when no new messages are present in the mailbox. The LCD backlight should blink, in order to attract the attention of user, when new email arrives in the mailbox. This can be done by using one additional pin of parallel port to switch the supply of LCD backlight using a BC547 transistor.
  3. Error checking has not been included in the script to keep the code simple.

Installation of GmailToLCD

  1. Install libgd[3] >= 2 library (skip this step if you already have this library. This library comes bundled with Fedora Core 7). Download tar.gz archive of libgd (version greater than 2.0). Extract the archive.
    [root@tlm mydir]# tar -zxvf gd-2.0.35.tar.gz
    [root@tlm mydir]# cd gd-2.0.35
    [root@tlm gd-2.0.35]# ./configure && make && make install
  2. Skip this step if you have already installed serdisplib[1] in previous section. Install serdisplib[1](version greater or equal to 1.97.6) library from the project's download site. Extract the archive.
    [root@tlm mydir]# tar -zxvf serdisplib-1.97.6.tar.gz
    [root@tlm mydir]# cd serdisplib-1.97.6
    [root@tlm serdisplib-1.97.6]# ./configure && make && make install
    Ensure that ./configure script produces the following output libgd >= 2 support ... yes
  3. opy the GmailToLCD archives (gmailtolcd-v1.tar.gz or gmailtolcd-v1.zip), to "serdisplib-1.97.6/tools/multidisplay" directory. Extract the contents of this archive there using ‘tar’ or ‘unzip’ tool.
    [root@tlm mydir]# cp gmailtolcd-v1.tar.gz serdisplib-1.97.6/tools/
    [root@tlm mydir]# cd serdisplib-1.97.6/tools/
    [root@tlm tools]# tar -zxvf gmailtolcd-v1.tar.gz
  4. Switch on the power supply to LCD.
  5. Verify that you have python >= 2.4.0 installed in your system. Execute the python script 'gmailtolcd.py'
    [root@tlm tools]# python
    Python 2.4.3 (#1, Oct 1 2006, 18:00:19)
    [GCC 4.1.1 20060928 (Red Hat 4.1.1-28)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> {{ Press Ctrl + D to exit }}
    [root@tlm tools]# python gmailtolcd.py adutta.np@gmail.com YOUR_GMAIL_PASSWORD
    Fig. 12: LCD screen when gmailtolcd.py script is executed

You should see a welcome screen as shown in Fig. 12. The LCD screen will be updated automatically when a new email arrives in your Gmail mailbox (see limitations of gmailtolcd.py in previous section). Press Ctrl + C key to terminate the gmailtolcd.py script.

Installation Notes:

The gmailtolcd application was successfully tested in PCQLinux 2006 (Desktop Installation) and Fedora Core 7.

GmailToLCD in Action (Photos)

Here are some photographs that capture GmailToLCD application in action. It also includes some miscellaneous photographs taken during testing of multidisplay tool and my electronics workbench setup used to test GmailToLCD application.

gmailtolcd.py code listing

See gmailtolcd.py.




[1] serdisplib project page
[2] serdisplib page for “s1d15g10 series” lcd
[3] libgd project page
[4] Google Permissions
[5] GPL Liberation Fonts