[HowTo] LCD HD44780 Through I2C Port Extender


[Howto] LCD HD44780 Throught I2C Port Extender HD44780 LCD Display on Pi Throught I2C Port Extender PCF8574 Serialinterface module (LCM1602 IIC)
This guide firmly works.
Tested on Pi-1 rev2 and Pi-2 model B, using OMSC KODI built.

Connect to your Pi via ssh and use the following commands:

sudo apt-get update && sudo apt-get dist-upgrade

sudo apt-get install i2c-tools

sudo apt-get install python-smbus

sudo apt-get install lcdproc
(select “Yes” when asked to perform an automatic configuration upgrade)

5, Enable modules

sudo modprobe i2c-bcm2708
sudo modprobe i2c-dev

Enable i2c on the pi :

sudo nano /etc/modules

Add the following lines to the file, press ctrl + x and save it:


6, If you are running a recent Raspberry Pi (3.18 kernel or higher) you will also need to update the /boot/config.txt file.

Edit it with:
sudo nano /boot/config.txt

and add the following lines:


Then reboot your system:

sudo reboot

7, Check if the i2c device drivers are loaded at boot time.

lsmod|grep i2c

If the module is loaded properly, two devices should exist.

i2c_dev 7054 0
i2c_bcm2708 6128 0

8, Check which version and revision of the Raspberry Pi you have.

ls -l /dev/i2c*

The ouptut should be something like this:
crw-rw---- 1 root i2c 89, 1 Apr 2 23:38 /dev/i2c-1

" #/dev/i2c-0

9, Testing the I2C address

If you’ve got an original Model B Rev 1 Pi then type the following

command :
sudo i2cdetect -y 0

If you’ve got a Model A, B Rev 2 or B+ Pi2 then type the following

command :
sudo i2cdetect -y 1

0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

My i2c address is 0x38

10, Edit the LCDd configuration:

sudo nano /etc/LCDd.conf

Change the section:

DriverPath=/home/osmc/lcdproc/ # Note 
#DriverPath=/usr/lib/arm-linux-gnueabihf/lcdproc/ # Note 
#Bind=   # doesn't need for i2c module'
#Port=13666       # doesn't need for i2c module'
Hello="OSMC KODI is starting"

Device=/dev/i2c-1 # make this i2c-0 for Revision 1 Pi's'
Port=0x38         # replace to your i2c address
Backlight=no      # I didn't use Balcklight'
Size=20x4         # 16x2 or ?
# edit the pin configurations for your i2c module (Note2)

After those changes reboot the pi:

sudo reboot

11, Enable/install LCDproc via OSMC In the OSMC main menu got to:

Settings >> Add-ons >> Get add-ons >> XBMC/Kodi add-on repository >> 
Services >> XBMC LCDproc >> Install

“You don’t need to activate the Bind= and Port=13666 in XBMC
LCDproc menu for the i2c module”
(I think it’s only needed if you directly wired to the GPIOs without the i2c module)

Restart LCDd:

sudo /etc/init.d/LCDd restart


Thanks to Rhys Williams for the right hd44780.so to allow the pin configurations to be specified via LCDd.conf.

Download Rhys’s hd44780.so from’ (Otherwise you will need to build your own .so file)

NOTE: I did make new folder for the driver. That’s much easier to copy/paste files to via FTP.

Make a folder >> /home/osmc/lcdproc/ << and drop the hd44780.so file.

MOTE2: The pin configurations for My PCF8574 Serial interface module are called “LCM1602 IIC”


The result:

Side Note:Thanks to our @mcobit is a stud muffin for refined My text in perfect English :slight_smile:


LCD 20x4
Help with lcdproc after last update

Big thanks @szalay and @mcobit about this HowTo but I have question that maybe the other members interested in this topic will ask:

How to determinate our addresses?

As you mention this tutorial is based on Rhys Williams .so file which is great and also is allowing us to use 3rd party i2c shields different than the official supported by LCDproc. I’ve already try this approach and even I’ve end up contacting Rhys for more information how to get the correct addresses but his answer was no so “direct and clear”. So if you have more information about the following section and how to make it work it will be nice to add it to the tutorial. Because I think that this is most important part of it.

My last attempt was to follow all traces on my i2c board and make a map of them with the hope that this will help me a little bit in combination of the chip (PCF8574P)… but it wasn’t… So thanks again and I will try to make it based on your tutorial and as I already mention it - more detailed information about this part of the tutorial will be very appreciated.



I think the address is being decided by the jumpers a0 a1 and A2 on the I2c port expander. On the photo above there are no pins attached on those solder joints but basically it depends on how you will bridge them.

Make a search on I2c port expander address for let’s say arduino and I think you will find the answer.

Most of those expanders come with all this joints non bridged and you have to tweak them only if you are using more than one to avoid conflicts.

If I am wrong please ignore me and accept my apology.



Hi @GnF - these 3 jumpers are relared to the I2C address of the board. For example at the picture they are all bridged and this leads to have 0x30 as I2C address. At my board the are not bridged and the address is 0x27. My question is regarding the addresses that you must define at your config file.



In LCDd.conf



OK let me be more precise:

As I already say these 3 couples of jumpers are available for I2C address configuration. Based on the way how you bridge them you can change the I2C address of your port expander. Just imagine that you have 2 or more displays connected to the same I2C bus - you need to make them with unique addresses. This can be done with these 3 jumpers and base on the way/variations how you bridge them you can get address into the range from 0x20 to 0x38. And I’m NOT asking about them.

This is OK but later on you must define your RS, RW, EN, BL, D4, D5, D6, D7 lines. This is the minimal configuration needed to drive your LCD. If there was no port expander usage you need to wire all these pins of the LCD to GPIO pins of your RPi, but the port expander is doing this for you. At the configuration you must define their values as 0x** hexadecimal addresses.

I’m asking for these values, how you can find them based on the port expander that you have because these addresses are representing the HW address of each leg of your chip. Please note there are a lot versions of these small extenders, you can get board with the same chip (PCF8574AT) but totally different wiring because these chips are with 16 legs and you have 10 legs (if I remember it correctly) free for usage. Or you can get board with totally different IC chip and wiring implementation. So there are a lot of possible configurations.

So my question is - Do you know how to determinate the values for RS, RW, EN, BL, D4, D5, D6, D7 lines of the config file if the values that you already provided are not working for you - like they are not working for me because my boards are with different version of the PCF8574 IC and the wiring between the IC legs and LCD pins is also different.



The datasheet of the expander ic would be my first stop.
Then the documentation of the driver.



@ WizziLalev Yes you’re right.

We have no clue yet “How to determine The addresses” except Williams, but He’s not respond.
(i thought get response from Williams then I’ll write the example)

I’m lucky to got same I2C Port Extender what match his configurations.

I need another versions of LCM1602 module and figure out for alternative configurations.

about i2c address,

I connected A0,A1,A2 to ground to get 0x38 address but it doesn’t matter because we can check with command, and replace it.

“chips are with 16 legs and you have 10 legs”

what do you mean ?
all LCM1602 module soldered with 16 legs i never see with 10 legs
if i good understand what you written above.

sry my bad English



@szalay, sorry maybe I didn’t write it correctly, yes all chips are with 16 legs, but few of them are for Vcc, ground, reset and two are used for the I2C communication. So from 16 pins you have only 10 that can be used as “output” pins.



What exact chip do you have?
As said, you will normally find all the needed documentation in the datasheet of your chip or breakout board.



Here it’s part number:



And here is a datasheet with the pinout.
Should be easy to read what pin is what if you only have the chip without the breakoutboard.


A0-2 are the address pins, P0-7 are the io-pins, vdd = positive, vss = negative, SDA/SCL = I²C interface.

Edit2: Here you can find a picture of the connection of this interface with an lcd:

From there you should be able to figure out what pin is what.



The major thing, how connected I2C-Port Expander and HD44780 between.

I did simplified depict circuit from my PCF8574AT I2C-Port Expander

Simplified circuit (different pin configuration) from lcdproc.sourceforge.net

My logical theory:

@WizziLalev can you photo from your I2C-Port Expander botton and top side, and send it me PM ?



how did you connect the LCD?
did you use a logic level converter ?




how to overcome the issue:

self.bus = SMBus(self._port) IOError: [Errno 13] Permission denied

permission problem