[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”
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.
I think you need to learn how to read datasheets…
Its 0.7*Vcc, when Vcc is 5v that translates to 3,5v
… a bit condescending?
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 !
Still too wussy to do any kernel work?
Oh no, you revealed my next blog update
My raspi wont arrive till the end of august. Cant wait to try stuff on it.
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.
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.
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
Is that conductive foam his Pi is sitting on? I’m not sure that’s a good idea.
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 ;)
Here is my C++ HD44780 library for RaspberryPi. Easy to use.
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:
Please be kind and respectful to help make the comments section excellent. (Comment Policy)