Raspberry PI with HD44780 LCD and I2C Interface Board

After buying an HD44780 compatible LCD together with an I2C interface board (which has an PCF8574T soldered on it) I tried to output some text in C on it but the display just stayed black - or after changing some GPIOs, it stayed blue.

I measured every pin of the PCF8574T and got the following scheme:

PCF8574T <-> HD44780
P0        --      RS
P1        --     R/W
P2        --      EN
P4        --     DB4
P5        --     DB5
P6        --     DB6
P7        --     DB7

R/W should be mapped to GND if the HD44780 should not talk back to the CPU. The information that was missing in the Ebay page, was that P3 must be also set to high or otherwise, there will be no backlight. Another obstacle was that the potentiometer wasn’t fully opened.

So here is my working example, thanks to very good documentation in the web and some lucky guesses.

#include <wiringPi.h>
#include <pcf8574.h>
#include <lcd.h>

#define LCDOFS(x) (lcdofs + x)
const int lcdofs = 0x64;

int main(void)
{
    int fd; 
    
    pcf8574Setup(lcdofs, 0x27);
    wiringPiSetup();
    
    pinMode(LCDOFS(1), OUTPUT);
    pinMode(LCDOFS(3), OUTPUT);
    digitalWrite(LCDOFS(1), 0); 
    digitalWrite(LCDOFS(3), 1); 
    
    fd = lcdInit(4, 20, 4, LCDOFS(0), LCDOFS(2),
    LCDOFS(4), LCDOFS(5), LCDOFS(6), LCDOFS(7), 0, 0, 0, 0); 
    lcdHome(fd);
    lcdClear(fd);
    lcdPrintf(fd, "Stay Tuned!");
}

Here are some pictures of the display.

HD44780 with I2C Adapter

HD44780 with Text

Costs:

  • HD44780 Display (20x4): 6,19 Euro
  • I2C Interface Board: 1,10 Euro