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.

Comments

  1. Zach says:

    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.

  2. jc says:

    Still too wussy to do any kernel work?

  3. threeck says:

    My raspi wont arrive till the end of august. Cant wait to try stuff on it.

  4. dreamer says:

    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.

  5. problemchild68 says:

    I think the use of an I2C i/O expander is quite sensible since he would need to use a level shifter anyway. I belive that Microchip have some functionally similar chips for $0.80 or there abouts.

    Either way he’s protected his RPi which is nearly an endagered species at the moment

  6. B34RDY says:

    Is that conductive foam his Pi is sitting on? I’m not sure that’s a good idea.

    • problemchild68 says:

      That “Conductive” foam still has a resistance plenty high enough for the RPi to be ok.

      The foam should really be called “not as insulating as the insulating stuff” foam
      Still not the best idea if you were making sensitive measurements though ;)

  7. Stepan says:

    Here is my C++ HD44780 library for RaspberryPi. Easy to use.

    or

    https://gitorious.org/rpi-gpio

    https://gitorious.org/rpi-hd44780

  8. 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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 96,459 other followers