Using An HD44780 Character LCD With The Raspberry Pi

[Tech2077] is one of the lucky ones who already got his hands on a Raspberry Pi. He’s been looking into different interface options with the GPIO header and just posted a guide to using an HD44780 character display with the RPi. We like this approach because instead of doing some hard-core LCD work he’s using prototyping equipment you probably already have on hand.

Getting a character LCD running should be really simple. The gotcha is the logic level gap between the devices. If you’ve been working with Arduino, your add-ons are probably meant for a 5V power rail  and logic levels. The RPi outputs 3.3V logic. You could use a level converter (you’d need at least 7 pins to be converted in this case) or you can be a bit more clever. [Tech2077] grabbed an I2C port expander that uses just 2 of the RPi lines to address even lines of the display (four data bits plus three control bits). This is a bit of a hack, as the 3.3V logic is 0.2V below the recommended minimum for a digital 1 on the port expander. But it seems to work just fine! If it didn’t, a couple of NPN transistors would do the trick as well.

Addressing the new peripheral is just a matter of loading the i2c module and writing some Python.

15 thoughts on “Using An HD44780 Character LCD With The Raspberry Pi

  1. When I was working on some code for the STM32F4 to use a hd44780, I found that the unit only requires .7v for a logic level high when vcc is 5v. Datasheet confirms this. Could have used 7 pins at normal voltages. But this method is an interesting way to *add more pins, to low pin devices.

    1. Just because the logic levels are a little below the high transistion value that doesn’t mean it wont work. The dead zone is merely an unqualified “transition” area where you may or may not get what you want. Of course the pull ups if he’s using them will tend to bias it towards the logic 1 anyway !

  2. Hmm, I was thinking of talking to an MSP430 and have that do the lcd-stuff (have a couple hd44780s lying around). That we you also have a bunch more io-pins to play around with.

    However the two libraries I use on msp430 are not yet compatible to one another. One is specifically for hd44780 displays (someone ported from arduino), and another with some utilities like i2c and timer functions ( https://github.com/esmil/msp3n1s/ ). It’s the timer functions that are incompatible it seems, and I haven’t gotten esmil motivated to integrate it yet ;)

    This seems like a pretty good solution as well though.

    1. Good morning,

      I am participating in a project where we need a library to use a LCD 16×2
      via I²C bus (PCF8574) in Raspberry PI.
      I found many references from you.
      I wonder if you know or developed some template library in C / C ++ that
      makes communication with the PCF8574 LCD.
      For I saw their libraries to the PCF8574 and the LCD separately, but I can
      not use them together.

      Thank you,
      Tamires

  3. PILib is a C++ library that implements an interface for HD44780 based LCD displays for the Raspberry PI. It can be downloaded at PILib . It is pretty easy to use. Source code and complete documentation are included. A “Hello World” is as easy as:

    #include "HD44780.h"
    
    int main() {
    
        CTTPI::HD44780 module(1, 16);
                       // EN  RS RW  D4  D5  D6  D7
        module.initialize(17, 18, 0, 21, 23, 24, 25);
        module.writeString("Hello world!");
        return 0;
    }
    

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.