News Nokia LCD Display

Live RSS news feeds displayed on a text LCD. Larger Image

This Internet of Things example uses mbed's networking features to display live RSS news feeds on the LCD. It is based on earlier networking examples from the cookbook that read a web page and the Nokia-LCD library to display characters on a text LCD. CNN Technology news is used for the live RSS feed.

CNN Newsroom in Atlanta


The same hardware and wiring setup is used as the Internet Nokia LCD Clock, Weather Nokia LCD Display and Geolocation Nokia LCD Display.

Ethernet Magjack Connector

MbedSparkfun Ethernet Breakout

Note: Different magjack connectors can use different pin outs even though they look the same. These pins are for connectors from Sparkfun in 2011. If you are having trouble with your initial network setup, try this example code first. Once it works, it will confirm correct wiring on the connector (at least on the input side). Magjack Pinouts are posted for other common connectors. More connections to the unused pins including one to 3.3V and a capacitor should be added for long cables, but this setup works well with short cables. If you still get the net error message, make sure that DHCP service is enabled for your mbed. On some networks, you need to add the module's MAC address to enable the DHCP server to give it an IP address. It times out with an error, if no IP address is returned in about fifteen seconds. If the news does not display on the LCD after seeing "net OK", you may have DNS problems or a very slow network.

Sparkfun Nokia LCD Breakout

Mbed pinsSparkfun Nokia LCD pins
p5 (mosi)DIO
p7 (sclk)SCK
Vout (3.3V)3.3V
Vout (3.3V)Vbat

Note: There are two versions of the Sparkfun Nokia LCD breakout board. This code runs on the older version seen below. Look for the blue inductor near the center and note the arrangement of the two small pushbuttons.

Older Sparkfun Nokia LCD Breakout board.

The newer version (Feb 2012) shown below needs a different version of the NokiaLCD driver code available at I will update the code example and post both versions once I have a new one to try out on it.

New Sparkfun Nokia LCD Breakout board.

Example Code


#include "mbed.h"
#include "EthernetNetIf.h"
#include "HTTPClient.h"
#include "NokiaLCD.h"
NokiaLCD lcd(p5, p7, p8, p9, NokiaLCD::LCD6610); // mosi, sclk, cs, rst, type
//CNN Tech News RSS Feed - get web page with XML
// displays titles on LCD  from XML "<title>....title text...</title>"
EthernetNetIf eth;
HTTPClient http;
HTTPResult result;
bool completed = false;
void request_callback(HTTPResult r) {
    result = r;
    completed = true;

int main() {
    char *tstartXML = "<title>"; //RSS XML start title
    char *tendXML ="</title>"; //RSS XML end title
    char *tsptr;
    char *teptr;
    int i=0,j=0;
    // the eth and HTTP code has be taken directly from the HTTPStream documentation page
    // see
    lcd.printf("net setup");
    EthernetErr ethErr = eth.setup();
    if (ethErr) {
        lcd.printf("net error");
        return -1;
    lcd.printf("net ok");
    HTTPStream stream;
    char BigBuf[2048 + 1] = {0};
    stream.readNext((byte*)BigBuf, 2048); //Point to buffer for the first read
    //CNN Tech News RSS Feed - get web page with XML
    HTTPResult r = http.get("HTTP://", &stream, request_callback);
    while (!completed) {
        Net::poll(); // Polls the Networking stack
        if (stream.readable()) { // check for end of file
            BigBuf[stream.readLen()] = 0; // Transform this buffer in a zero-terminated char* string
            tsptr = BigBuf;
            // displays titles on LCD  from XML "<title>....title text...</title>"
            do {
                tsptr = strstr(tsptr,tstartXML); // find <title> in string - NULL if not
                teptr = strstr(tsptr,tendXML); // find <\title> in string - NULL if not
                if (tsptr!=NULL) tsptr = tsptr + strlen(tstartXML);// move to char after "<title>"
                if ((tsptr!=NULL)&&(teptr!=NULL)) {
                    // loop to display lines on LCD
                    for (j=0; (j)<(strlen(tsptr)-strlen(teptr)); j=j+16) {
                        //                      lcd.cls(); // clear screen before writing a new line
                        // loop to output a line on the LCD
                        for (i=0; ((i<16)&&(tsptr[i+j] != '<')); i++) {
                    lcd.cls(); //clear LCD between news items
            } while (tsptr!=NULL); // No more "<title>"s in BigBuf to display
            stream.readNext((byte*)BigBuf, 2048); //Buffer has been read, now we can put more data in it
    if (result == HTTP_OK) {
        lcd.printf(" Read complete");
    } else {
        lcd.printf(" Error %d\", result");
        return -1;

Import programNews_Nokia_LCD_display

Live RSS News feed is displayed on a Nokia LCD. See

A small portion of the RSS news feed web page containing XML is seen below. The data displayed on the LCD is the title. The format is "<title>....title text.....</title>". The code uses ad hoc parsing with strstr (i.e., this searches a large string for a substring) to find the "<title>' and "</title>" strings in the read buffer. The data on the web page is too large in many cases to read all of it into a memory buffer given mbeds RAM size, so it is split into several smaller buffers for each read and processed as the data streams in.


<pubDate>Fri, 20 Apr 2012 15:49:58 EDT</pubDate>
<title>Debate reopens on violent video games</title>
<guid isPermaLink="false"></guid>
<description>Norway's alleged mass killer testified on Thursday that he played video games as a way to train for a shooting spree that killed 77 people last summer. In particular, Anders Behring Breivik said at his trial that he played "Call of Duty: Modern Warfare 2" as a means of shooting practice, according to CNN's report.&lt;div class="feedflare"&gt;
&lt;a href=""&gt;&lt;img src="" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href=""&gt;&lt;img src="" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href=""&gt;&lt;img src="" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href=""&gt;&lt;img src="" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href=""&gt;&lt;img src="" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="" height="1" width="1"/&gt;</description>

Video Demo

In the video above, mbed is powered up and obtains an IP address from the DHCP server. Net OK appears on the LCD. It then opens and reads a portion of the web page, searches for news items displaying them as they are found on the LCD and reads through the rest of the web page. When it reaches the end of the web page, "Read Complete" is displayed.

Ideas for further enhancements

1. Add a loop to keep reading and displaying the RSS feed.
2. Add other RSS news feed to cycle through.
3. Add code to display the description text after each title.
4. Add pushbuttons to select different RSS feeds or stop the display and show the description.
5. Instead of pushbuttons, use touch switch input or an IR remote.
6. Experiment with different scrolling ideas.
7. Use a Google RSS news feed. Google also has several RSS news feeds and news can be searched to generate a new RSS feed. Here is an example
8. Items that span across a read buffer boundary will not be displayed. Modify the code to add this feature and reduce the buffer size to 512B.
9. Use Power over Ethernet (PoE) to power the device and avoid the extra wires for power. Sparkfun has one PoE option.
10. Upgrade to a larger LCD display or VGA.
11. Instead of ad hoc parsing code, use an XML parser like SPXML to read the RSS news items. Some RSS feeds have web pages that are too large to save in memory and streaming of data through the parser will be required. It could also be written to a file for demos in a prototype, but small flash devices can wear out with constant use, so such an approach would not work out well long term for a product.

2 comments on News Nokia LCD Display:

07 Jun 2012

Hi Jim, Is the code for the Video Demo above somewhere? I saw XM's version a week ago and used it, but made changes for the Phillips controller. Earlier, I used a 16 x 2 LCD. I like your idea of getting more stories. Right now, just see 3 "Top Stories", like I got with "Tech News".

13 Jun 2012

You should be able to just click the "Import this Program" link (in the box after the source code). It will setup a new project with all of the source code files.

Please log in to post comments.