Pages

Saturday, 28 September 2013

Text LCDs and the Raspberry Pi

One project I'm hoping to complete in the next day or so is an I2C-based Text LCD for use with the Raspberry Pi.

Why bother? After all, the Pi has an HDMI output, and it's easy to connect the Pi via Ethernet or wireless.

The problem is that there are situations where you really need a stand-alone display.

Stand-alone Pi Projects

If you're building a battery-powered  stand alone project you may need an output mechanism that's a bit more informative that a few flashing LEDs,  your power budget may not run to WiFi, and you may want to use what you're making in an environment where a network-based solution is not practical.

Another application: running a physical computing course

It may be hard to connect to the Pi because you don't know its IP address.

Earlier this year I helped to run a couple of workshops covering physical computing on the Pi. Practical considerations meant that we couldn't use monitors for each Pi, and we had to connect to the local network using DHCP.

It would have been really helpful if we'd had a text LCD for each Pi displaying its assigned IP address.

3 popular ways to link the Pi to a text LCD

There are plenty of articles on the web explaining how a Pi can drive a text LCD. I've listed a few at the end of this post.

They fall into three main groups.

  1. Some drive the LCD via the Pi's GPIO pins
  2. Some use I2C with a port expander like the PCF8547 or MCP23008
  3. Some commercial products use I2C with a slave micro-controller which then drives the LCD

No-one is prefect

Each approach has some disadvantages.
  1. The main problem with using the GPIO pins is that there are only eight of them (not counting the special-purpose pins which may already be in use). Driving the LCD display will use at least six of them. For many projects, that's not acceptable. It certainly wouldn't work for our courses where several of the labs involve driving things via GPIO.
  2. I've used the port expander approach in past projects. It works, but it requires a lot of traffic on the I2C bus; you need to send multiple bytes over the bus in order to display a single character. For some applications this causes an unacceptable bottleneck on the I2C bus.
  3. I like this approach, but it's not cheap. Most I2C-based LCD displays cost almost as much as a Raspberry Pi!

My preferred approach: hacking the veroduino

The approach I'm trying was suggested by my first experiment with the teensy 3.0. I'm going to build a simple veroduino (see below) which I will control over I2C. On the software side, I'm going to merge the standard Arduino I2C slave example with the LiquidCrystalFast library, adding some simple control code.

I'll publish diagrams and code when they are ready.

Web resources



One good example of a port-expander based approach is the Adafruit LCD backpack, and there's a tutorial in the Adafruit learning system.


I did a very short write-up of a good commercial micro-controller based I2C LCD product.