loading

Introduction

Using LCD modules with your Arduino is popular, however the amount of wiring requires time and patience to wire it up correctly - and also uses a lot of digital output pins. That's why we love these serial backpack modules - they're fitted to the back of your LCD module and allows connection to your Arduino (or other development board) with only four wires - power, GND, data and clock. You can use this with LCD modules that have a HD44780-compatible interface with various screen sizes. For example a 16 x 2 module:

16 x 2 character LCD (white text blue background) with parallel interface from Tronixlabs Australia

The backpack can also be used with 20 x 4 LCDs. The key is that your LCD must have the interface pads in a single row of sixteen, so it matches the pins on the backpack - for example:

16 x 2 character LCD (white text blue background) with parallel interface from Tronixlabs Australia

Step 1: Hardware Setup

Now let's get started. First you need to solder the backpack to your LCD module. While your soldering iron is warming up, check that the backpack pins are straight and fit in the LCD module, for example:

16 x 2 character LCD (white text blue background) with parallel interface from Tronixlabs Australia

Then solder in the first pin, while keeping the backpack flush with the LCD:

16 x 2 character LCD (white text blue background) with parallel interface from Tronixlabs Australia

If it's a bit crooked, you can reheat the solder and straighten it up again. Once you're satisfied with the alignment, solder in the rest of the pins:

16 x 2 character LCD (white text blue background) with parallel interface from Tronixlabs Australia

Now to keep things neat, trim off the excess header pins:

16 x 2 character LCD (white text blue background) with parallel interface from Tronixlabs Australia

Once you've finished trimming the header pins, get four male to female jumper wires and connect the LCD module to your Arduino as shown in the following image and table. Then connect your Arduino to the computer via USB:

16 x 2 character LCD (white text blue background) with parallel interface from Tronixlabs Australia

Step 2: Software Setup and Use

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.

If you're not sure where your library folder can be found - it's usually in your sketchbook folder, whose location can usually be found in the Arduino IDE preferences menu:

Next, visit https://bitbucket.org/fmalpartida/new-liquidcrysta... and download the latest file, currently we're using v1.2.1. Expanding the downloaded .zip file will reveal a new "LiquidCrystal" folder - copy this into your Arduino libraries folder.

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 
Uses library from https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads GNU General Public License, version 3 (GPL-3.0) */
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C	lcd(0x27,2,1,0,4,5,6,7); // 0x27 is the I2C bus address for an unmodified backpack

void setup()
{
  // activate LCD module
  lcd.begin (16,2); // for 16 x 2 LCD module
  lcd.setBacklightPin(3,POSITIVE);
  lcd.setBacklight(HIGH);
}

void loop()
{
  lcd.home (); // set cursor to 0,0
  lcd.print(" tronixlabs.com"); 
  lcd.setCursor (0,1);        // go to start of 2nd line
  lcd.print(millis());
  delay(1000);
  lcd.setBacklight(LOW);      // Backlight off
  delay(250);
  lcd.setBacklight(HIGH);     // Backlight on
  delay(1000);
}

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 - for example:

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.

How to control the backpack in your sketch

As opposed to using the LCD module without the backpack, there's a few extra lines of code to include in your sketches. To review these, open the example sketch mentioned earlier.

You will need the libraries as shown in lines 3, 4 and 5 - and initialise the module as shown in line 7. Note that the default I2C bus address is 0x27 - and the first parameter in the LiquidCrystal_I2C function.

Finally the three lines used in void setup() are also required to initialise the LCD. If you're using a 20x4 LCD module, change the parameters in the lcd.begin() function.

From this point you can use all the standard LiquidCrystal functions such as lcd.setCursor() to move the cursor and lcd.write() to display text or variables as normal. The backlight can also be turned on and off with lcd.setBacklight(HIGH) or lcd.setBacklight(LOW).

You can permanently turn off the backlight by removing the physical jumper on the back of the module.

Changing the I2C bus address

If you want to use more than one module, or have another device on the I2C bus with address 0x27 then you'll need to change the address used on the module. There are eight options to choose from, and these are selected by soldering over one or more of the following spots:

There are eight possible combinations, and these are described in Table 4 of the PCF8574 data sheet which can be downloaded from the NXP website. If you're unsure about the bus address used by the module, simply connect it to your Arduino as described earlier and run the I2C scanner sketch from the Arduino playground.

We hope you enjoyed this tutorial and you can make use of it. Finally, if you enjoyed this tutorial, or want to introduce someone else to the interesting world of Arduino – check out the author's book (now in a fourth printing!) “Arduino Workshop”.

<p>Nice tutorial. Help me alot!<br>But i wonder, can we use P10 lcd with 16x32?<br>Just like this</p><p>Thankyou</p>
<blockquote>I fixed it thanks to the IC Scanner!<br>It gave me adress 0x3F so i changed it in the code ant then it worked!<br><br>And I have to say..THANKS for a great book!!!<br>Great both in learning Arduino code AND learning about electronics.<br>Ohms law, all about how different components works...a reference book.<br>I found it on the library, after two days i bought my own copy (may 2016)<br>i just wish i could get the digital version on my ipad as well.<br></blockquote><p>Today, my first soldering experience, and the first time I have tried with LCD.<br>The same day :-)</p>
<p>Yeah man, It works out of the box... I have it now running on some cheap arduino uno clone with a 4x20 display attached to the i2c backpack... Yeah man!</p>
<p>I tried with arduino uno (clone ) and it worked without any problems, With an arduino nano i can not put it to work , should it be done differently , i mean the connections?</p>
I also like these . I've bought one but I rarely use them .<br>It's not impossible to make that black board (which they call I2c what what what) , it's only a shift register IC .
<p>No, its not 'only a shift register IC'. It uses the I2C (aka TWI) protocol. It has address jumpers, so you can connect up to 8 LCDs in parallel to the SAME 2 wires, which is not possible in a simple shift register arrangement.</p>
<p><strong>Attention to cabling... <br></strong>The given information is ONLY valid for:</p><p><strong>Uno &amp; Ethernet</strong></p><p>For other models see:</p><p><a href="https://www.arduino.cc/en/Reference/Wire" rel="nofollow">https://www.arduino.cc/en/Reference/Wire</a></p><p>P.D.:</p><p>Makes NO sense at all, not providing full and right information when typing and/or not updating these articles...</p>
<p>OK now. Got it to work. The installation of the LquidCrystal library hadn't worked the first time. I installed it through the Sketch&gt;Import Library&gt;Add Library function of 1.0.5 Arduino IDE. </p><p>Hope this helps someone in the future.</p>
<p>I tried to use the test sketch, but it failed with a message of </p><p> 'LiquidCrystal_I2C' does not name a type</p><p> I am using Arduino 1.0.5-r2 Environment on a windows 7 computer.</p><p>Thanks</p>
<p>A little probing shows the two pin header is used for the resistor. The top pin goes to pin 15 on lcd, that is, A of back light led. The bottom pin goes to Vcc.</p>
<p>do you mean to say one should hook up a resistor between the two pins rather than a jumper?</p>
Yes. For a 16x2 use a 270 ohm. For 20x4 a 25 ohm. The transistor driving the led is a s8050 npn and can handle .5 amp.I do not know why the chinese ship it with a jumper, that is, 0 ohms. Not a good idea.
<p>thanks. very useful. I have been wondering about it, whether it needed a resistor but i figured the manufacturer would have thought about that. Will add resister</p>
<p>great stuff. have been using that i2c to lcd board often as they are quite cheap. Often one can find an LCD with this little board already soldered on for little more money than an LCD without. </p><p>oddly PCF9574 I/O extension boards are more expensive than this LCD board that i presume can also be used as I/O expander</p>
<p>The problem with these units is there is no limiting resistor for the back light</p>
<p>Please I need help !!!!!!!</p><p>I need a circuit diagram(or connections) for &quot;Transfering 4 bits binary over optical patch cable using arduino board. I have the following:</p><p>optical patch cable</p><p>bread board</p><p>arduino board</p><p>Tx and RX</p><p>resistors, coneection wires</p><p>remote</p><p>LCD</p>
Smart idea! Thanks for shearig :)
<p>Nice tutorial! And your photos are really good!</p><p>I never used one of these, but i can see in your instructable that you save a lot of pins using this board, now I'm thinking in buiyng one of these, this can also help me to understand the I2C protocol.</p><p>Tahnks for sharing!</p>
<p>Thanks, glad you enjoyed it. We'll do some more in the coming weeks.</p>

About This Instructable

26,700views

47favorites

Bio: Helping you make it with Australia's best value for supported hobbyist electronics from adafruit, DFRobot, Freetronics, Seeed Studio and more!
More by tronixlabs:Tutorial - Using HC06 Bluetooth to Serial Wireless UART Adaptors with Arduino Control DC and stepper motors with L298N Dual Motor Controller Modules and Arduino Using PCF8574 backpacks with LCDs and Arduino 
Add instructable to: