pcf8574 i2c lcd module factory

A regular LCD requires a lot of wires (parallel interface) to be connected with a Microcontroller.The Serial LCD  backpack built on PCF8574 IC uses the I2C bus to convert  the parallel interface to a serial one.This needs only2 wires SDA & SCL , apart from the power connections.

The blue preset is to adjust the contrast of the LCD. The black jumper on the left is to enable the Backlight of LCD. The I2C device has a HEX address by which a microcontroller can communicate with it.This is set by the 3 bits A0,A1 ,A2 .If no jumper is present , it is HIGH &  a jumper means LOW. By default all the 3 jumpers are open . ie., A0,A1 A2 all are 1s.

The I2C bus has 2 bidirectional active wires SDA & SCL .They are joined to positive supply through a pull up resistor of 4k7.When the bus is  idle both lines are pulled high.

lcd.setBacklightPin(HIGH);  makes the P3 pin go High, which turns on the NPN transistor.This provides GND to the LED pin of LCD As the other LED pin is already connected to Vcc through the jumper , the LCD backlight glows.

pcf8574 i2c lcd module factory

16×2 LCD is an alphanumeric display that can show up to 32 characters on a single screen. You can display more characters by scrolling the texts one by one. We have already seen how to connect LCD Display directly with the Arduino using 4bit and 8bit modes in our previous tutorial. But those two modes will utilize many numbers of GPIO Pins of our Arduino and we would have to end up with less number of pins for other sensors and actuators.

To overcome this problem we use LCD I2C backpack with our LCD. This I2C Backpack uses PCF8574 Remote 8 bit I/O Expander. It translates the data received from the I2C Bus into Parallel data that is needed for the LCD Display.

Inter-integrated Circuit (in short I2C) is a two-wire short distance communication protocol. You can use multiple slave devices in the same two wires with one or more master controllers. You may wonder how does the master identifies which slave does the data to be sent. In I2C the external devices have an I2C address for different external devices like LCD Backpack, OLED Display, etc. By using the address the data is sent to the specific device connected on the same I2C Bus.

The message is broken into two frames and sent serially via the I2C Bus. The first frame contains the address, once the address matches with any device on I2C bus, that device will send an acknowledge signal to the master. After receiving the acknowledgment from the slave the data bits are sent. By this method an I2C bus works.

There are totally 16 pins in an LCD Display. You can use directly all the pins in 8-bit mode with Arduino or 12 pins using 4-bit mode. In this tutorial, we use the I2C module for LCD and multiplex it into just 4 pins. This pin details might not be useful while using I2C Method but this is the actual pin details of all the pins in LCD Display.

RS – Register select. Specify what we are sending Command or Data. Sets to 0 for Command mode like setCursor, LCD Clear, TurnOFF LCD. Set 1 for data mode like sending Data/Characters.

First, we need to find the address of our I2C LCD Backpack. For that, we will be using I2C Scanner code to display the address in the serial monitor. Upload the following code, then note down the I2C address from the serial monitor.#include

In my case, it is 0x27. Node down the address displayed for you. Mostly it will be 0x27 only. In case you have another I2C device connected on the same bus it will show that address too.

Download .zip LiquidCrystal_I2C library by Frank de Brabander from hereand Install it in IDE by navigating Sketch>Include Library>Add .zip library and choose the downloaded LiquidCrystal_I2C.zip library file.

Now the LCD I2C library is installed. We need to define and initialize the library using its associated functions. The steps is as follows. Or you can copy the code given below to print Hello World example.

Set the address that we copied from I2C Scanner code. The address I got is 0x27 so I replaced it to 0x27 in the following lineLiquidCrystal_I2C lcd(0x27, 16, 2);

In the above code, we have created an LCD object for ‘LiquidCrystal_I2C’. So you can use directly use the regular LCD functions to work with I2C like lcd.begin(), lcd.print(“”), etc.

To print a string we use lcd.print() function with string in its parameters. This prints ‘Factory’ string in the 1st row and ‘Forward’ in the 2nd row.

This function sets the cursor on 7th column and 2nd row. Printing the string will gets displayed from this location on LCD.lcd.setCursor(6,1); // Sets cursor column and row position

By Using lcd.blink() function we can make the cursor blinking on LCD. To turn off the blinking cursor we use lcd.noBlink() function.lcd.blink(); //Blinking cursor

Use lcd.cursor() function for printing an underscore symbol. It is also used for notifying users to enter some values.lcd.cursor(); // Prints an underscore symbol

pcf8574 i2c lcd module factory

SMALL ISSUE: I"ve used a npn transistor for backlight, the library is written for a pnp transistor. This means that the command lcd.setBaclight(LOW) turns the backlight on and lcd.setBacklight(HIGH) switchs the backlight off.

pcf8574 i2c lcd module factory

The next step is to download and install the Arduino I2C LCD library for use with the backpack. First of all, rename the "LiquidCrystal" library folder in your Arduino libraries folder. We do this just to keep it as a backup.

Now restart the Arduino IDE if it was already running - or open it now. To test the module we have a demonstration sketch prepared, simply copy and upload the following sketch:/* Demonstration sketch for PCF8574T I2C LCD Backpack

After a few moments the LCD will be initialised and start to display our URL and the value for millis, then blink the backlight off and on. If the text isn"t clear, or you just see white blocks - try adjusting the contrast using the potentiometer on the back of the module.

pcf8574 i2c lcd module factory

This LCD I2C interface adapter can be added to a 16 x 2 or 20 x 4 character LCD display with a standard parallel interface to make it I2C compatible.  It can also be repurposed for other I2C to parallel tasks.

By default, the industry standard HD44780 compatible 16 x 2 and 20 x 4 character LCD displays require 4 or 8 parallel data lines to drive them along with a couple of pins for chip select and chip enable.  This consumes a lot of pins on the MCU.  This adapter board reduces the data pin requirements to only 2 pins which can also be shared with other I2C devices.

The backlight can be controlled ON/OFF, but the intensity is not directly controllable though the I2C interface.  Some modules have a jumper on the board that supplies Vcc power to the backlight.  That jumper can be removed and a voltage applied to the header pin nearest the ‘LED’ markings on the board to provide power to the backlight separately.  Note:  Some modules do not have this header / jumper installed, instead the solder pads have a trace connecting them.  It is possible to cut the trace between the pads and add header pins if desired.

The PCF8574 is a generic I2C to 8-bit I/O device and the module can be repurposed for other uses besides driving LCD modules.  Max I2C clock frequency is 100kHz which makes it most suited to lower speed applications.

VCC =  Connect to 5V.  This can come from the MCU or be a separate power supply.  Some LCD may operate at 3.3V and this module can also operate at 3.3V

The pin-out of the header which is soldered to the LCD follows for reference, but in general you don’t need to worry about it as the I2C interface board and software library takes care of this interface unless you are adapting the module for another use.  These pins are listed starting at the I2C header end of the board.

To use the adapter with an LCD, you will need to insert the 16-pin header into the 16 solder pad holes on the back of the LCD and solder them in place on the front side.  The pins are long and can be cut off before or after soldering.

Soldering the module on is easy to do, but if you already have other pins in those holes, they will need to be removed first before this board can be added.  The picture below shows the adapter mounted to the back of an LCD2004 4 x 20 character LCD.

This is the same module used on our I2C compatible LCD displays we sell and is well supported using the LiquidCrystal_I2C.h and similar libraries.  For using the board with software, you can check out one of the LCDs below that already have this module installed.

The PCF8574 itself is a general purpose 8-bit I/O expander for the I2C bus.  The reverse engineered schematics are provided here mainly for those who may want to adapt the module to other applications.  The I2C bus on this module is limited to a 100kHz clock frequency.

pcf8574 i2c lcd module factory

This is a RoHS compliant I2C Serial LCD Daughter board that can be connected to a standard HD44780 compatible 16×2 , 20×4 or 20×2 Character Display Module that supports 4 bit mode. All Character Modules sold on our site support 4 bit mode, and nearly all commercially available 16×2 and 20×4 line character modules support it too.

There are many examples on internet for using this board with Arduino. Do a search for "Arduino LCD PCF8574". The I2C address is 0x3F by default, but this can be changed via 3 solder jumpers provided on the board. This allows up to 3 LCD displays to be controlled via a single I2C bus (giving each one it"s own address).

There are many Arduino libraries for a I2C display with the PCF8574 chip. We tested the library from Francisco Malpartida, and it works without any problems. For info see this page. We also made this library available on our site located here. To test this board with a LCD, do the following:

pcf8574 i2c lcd module factory

In this article we are going to continue learning about the I2C bus and how it can work for us. If you have not already, please read and understand thefirst I2C articlebefore continuing.

First of all, there are some limitations of I2C to take into account when designing your projects. One of these is the physical length of the SDA and SCL lines. If all your devices are on the same PCB, then there is nothing to worry about, however if your I2C bus is longer than around one metre, it is recommended that you use an I2C bus extender IC.

These ICs reduce electrical noise over the extended-length bus runs and buffer the I2C signals to reduce signal degradation and chance of errors in the data. An example of such an IC is the NXP P82B715 (data sheet).

Several applications come to mind with an extended I2C bus, for example remote temperature monitoring using the the ST Microelectronics CN75 temperature sensor from part one; or controlling several I/O ports using an I2C expander without the expense or worry of using a wireless system. Speaking of which, let’s do that now…

A very useful and inexpensive part is the PCF8574 I/O expander (data sheet.pdf). This gives us another eight outputs, in a very similar method to the 74HC595; or can be used as eight extra inputs. In fact, if you were to use more than one 74HC595 this IC might be preferable, as you can individually address each chip instead of having to readdress every IC in line as you would with shift registers. So how do we do this? First, let’s consult the pinout:

There should not be any surprises for you there. A2~A0 are used to select the last three bits of the device address, P0~P7 are the I/O pins, and INT is an interrupt output which we will not use. To address the PCF8574 we need two things, the device address, and a byte of data which represents the required output pin state. Huh? Consider:

The reason is that the PCF8574 is a current sink. This means that current runs from +5v, through into the I/O pins. For example, an LED would have the anode on the +5V, and the cathode connected to an I/O pin. Normally (for example with a 74HC595) current would run from the IC, through the resistor, LED and then to earth. That is a current source.Consider the following quick diagram:

In the example above, please note that the PCF8574N can take care of current limitation with LEDs, whereas the 74HC595 needs a current-limiting resistor to protect the LED.

Luckily this IC can handle higher volumes of current, so a resistor will not be required. It sounds a bit odd, but like anything is easy once you spend a few moments looking into it. So now let’s use three PCF8574s to control 24 LEDs. To recreate this masterpiece of blinkiness you will need:

…and the example sketch. Note that the device addresses in the sketch match the schematic above. If for some reason you are wiring your PCF8574s differently, you will need to recalculate your device addresses:

That was a good example of controlling many outputs with our humble I2C bus. You could literally control hundreds of outputs if necessary – a quite inexpensive way of doing so. Don’t forget to take into account the total current draw of any extended circuits if you are powering from your Arduino boards.

The next devices to examine on our I2C bus ride are EEPROMs – Electrically Erasable Programmable Read-Only Memory. These are memory chips that can store data without requiring power to retain memory. Why would we want to use these?

Pin 7 is “write protect” – set this low for read/write or high for read only. You could also control this in software if necessary. Once again we need to create a slave I2C device address using pins 1, 2 and 3 – these correlate to A2, A1 and A0 in the following table: