Arduino: LCD with I2C Expander PCF8574
If you don't want to use 7 or more pins of your Arduino for a character LCD, and I2C Expander is your first choice.
The PCF8574 8-Bit I/O Expander
This IC is probably the most used "I2C LCD adapter". The I2C address are mostly either 0x3F or 0x27 depending on the used chip. When working with I2C always check with an I2C Scanner the wiring and the correct address. After setting the address of your display, the Hello World sketch should work like expected.
The Character Set of the HD44780U A00 ROM
There are several Arduino libraries available for this chip. So why does the world need an additional library? The "Noiasca Liquid Crystal" library does a character mapping from UTF-8 to the existing characters in the Hitachi HD44780U A00 ROM. As example some special characters in the second row of the display:
(Degree, Division, middle Point, n with tilde, Pound, Yen, Tilde, Sqareroot, Proportional to, Infinity, Left Arrow, Right Arrow, Backslash)
You can read more about this character mapping in the Introduction or in the German section of this site. For the beginning you should just know that you don't need to enter the octal ROM addresses of the special characters manually and these print can be done by a simple:
The Hardware Driver for I2C Expanders
The library offers a basic class for displays connected with an I2C expander. It uses the 4bit mode only.
The necessary #include and the constructor are:
#include <NoiascaLiquidCrystal.h> #include <NoiascaHW/lcd_i2c.h> LiquidCrystal_I2C lcd(lcdAddr, cols, rows);
Remember to add a Wire.begin() to your setup() like in the examples, as this will not be done in the library. (ok, there is a little hack for some processors in the library, but don't rely on it. Do a Wire.begin in the setup before you call the LCD.begin).
Your own Character Converter
If you need a different converter for the characters you can hand over a callback function as optional last parameter.
Obviously - you also have to implement the callback function to do all the magic.
See the general example how to write your own character converter.
For my German readers: the default constructor enables the support for the small letters ä ö ü and ß. For the sharp s ß we are using the Greek beta as it is available on the LCD. The large German umlauts Ä Ö Ü will be converted to their counterpart A O U. If you want to try other variants, you can use following constructors:
LiquidCrystal_I2C lcd(lcdAddr, cols, rows); // (Ä gets A) //LiquidCrystal_I2C_Ae lcd(lcdAddr, cols, rows, convert_ae); // Ä become Ae //LiquidCrystal_I2C_small lcd(lcdAddr, cols, rows, convert_small); // Ä become ä //LiquidCrystal_I2C_special lcd(lcdAddr, cols, rows, convert_special); // Ä become Ä
If you need an easy support of the given character set of a HD44870 display, take the "Noiasca Liquid Crystal" library in consideration.