I2C LCD Display

I recently acquired, via eBay, a 40X4 HD44780 based LCD screen that has a daughter-board on the back that provides an I2C interface, labled “LCD2004“. This permits interfacing with only two wires (SDA/SCL) plus ground and 5-volts. This particular board is sold by a Chinese company,  SainSmart.com. SainSmart provides its own version of the Arduino LiquidCrystal library and some example code. Unfortunately, both the library are for the old version of the Arduino IDE and will not compile with the current Arduino 1.0 version.

LCD2004 I2C Interface

To get the I2C display to work I did some reverse engineering. The LCD2004 board utilized the PCF8574 I/O expander. This nifty little chip provides eight bits of parallel I/O addressable by a I2C bus address – 0x00 to 0x27. SainSmart tied all address leads to Vcc, so the LCD2004 board’s I2C address is permanently fixed at hex 27. This is rather limiting since no additional LCD2004s can be added to the bus. Anyway, you simply address the board and write an eight bit value which is then presented on the output pins of the PCF8574, which, in this case, are connected to the HD44780 based LCD screen.

After some reverse engineering to determine which PCF8574 pins were connected to which LCD pins, I was able to use  F Malpartida’s NewLiquidCrystal library to write a functional test program. The unit works quite nicely and my code and schematic can be obtained in my BitBucket Repository.

The SainSmart LCD2004 board is identical to one offered by YwRobot and SainSmart’s provided example code is even marked with Ywrobot. Possibly SainSmart merely markets the Ywrobot board under their name, or possibly they cloned it. Furthermore, both Ywrobot may have obtained its design from DFrobot. DFRobot may have been the original board designer given their more professional approach of decent documentation, but given China’s disregard for intellectual property rights, who knows for sure? Also, DFRobot has and active forum with timely responses by their engineers, and a wiki, which is another plus for their professionalism. DFRobot’s board and SainSmart’s significantly differ, physically, so if SainSmart copied DFRobot, it was only from their schematic and not the board design.

A more versatile I2C LCD board would be to use the design offered by F Malpartida. Her I2CLCDextraIO board allows you to define a unique address for each LCD, permitting a multi-display configuration with all controlled over one I2C bus. Her designs are freely available in her BitBucket repository if you’d like to make your own board. You can also buy her bare board or assembled unit from ElectroFUN.

Advertisements
This entry was posted in Arduino, display, Electronics, Programming and tagged , , , . Bookmark the permalink.

3 Responses to I2C LCD Display

  1. Svetlana says:

    The reverse-engineered pins also work for a YWRobot 1602 LCD which uses the same daughterboard (except labeled 1602 instead). This allowed me to use LCDBitmap with the LCD I got in my Arduino kit. Thank you!

    Like

  2. Wil G says:

    Thanks for your sketches posted on bit bucket. I was thinking that I had made a good deal on something that I couldn’t figure out how to use. I also bought some i2c adapters on Ebay and was a bit miffed when the the default was 0x27. Their answer was that the A0, A1 and A2 lines must be shorted LOW for 0x20. That worked. Is it possible that the pins on the Sainmart device simply aren’t connected? The backboard that I purchased is here http://www.ebay.com/itm/I2C-IIC-Serial-Interface-Board-Module-LCD1602-Address-Changeable-/130895393679?hash=item1e79f9338f

    Like

    • celem says:

      Re – “Is it possible that the pins on the Sainmart device simply aren’t connected?” – look back at my schematic on BitBucket and you will see that the address lines are all tied to Vcc, creating a fixed address of 0x27.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s