Loading... Please wait...

Tutorial - Serial I2C backpack for HD44780-compatible LCD modules with Arduino

Posted by

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 have our serial backpack module - it's 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 our 16 x 2 module:

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:

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:

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

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:

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

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:

Software Setup

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 sketch which can be found on our github. However you need to check one parameter - the I2C bus address for the control IC. 

We may send you one of two versions of this device - the difference is the controller IC. If you have the PCF8574T. the default I2C bus address is 0x27. If you have the PCF8574AT the default I2C bus address is 0x3F. If you have the 'AT controller, search the sketch for 0x27 and change it to 0x3F. Then save and upload the sketch as normal.

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.

We may send you one of two versions of this device - the difference is the controller IC. If you have the PCF8574T. the default I2C bus address is 0x27. If you have the PCF8574AT the default I2C bus address is 0x3F.

You will need the libraries as shown in lines 3, 4 and 5 - and initialise the module as shown in line 7. You may need to change the bus address on this line which is 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. 

Finally if you have any questions or suggestions about this or anything else, please let us know in the Tronixlabs forum