[SOLVED] Using I2C 16x2 LCD with Arduino

Hello,

First of all, I should mention I'm a beginner in all this, so please be gentle when criticizing.

I have one of these displays: RC1602B5-LLH-JWV RAYSTAR OPTRONICS - Display: LCD | alphanumeric; VA Negative; 16x2; 80x36x13.2mm; LED | TME - Electronic components and I'm having trouble getting it to work. It has a I2C interface, and I've been trying to use the library at https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home, but without success. I only see the first row full of white boxes, and nothing on the second row, which makes me suspect that the LCD is not initialized.

The test code I have right now is:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3C);

void setup()
{
  lcd.begin(16, 2);
  lcd.print("hello, world 0 !");
  lcd.setCursor(0, 1);
  lcd.print("hello, world 1 !");
}

void loop()
{
}

The address 0x3C was obtained using I2cScanner:

I2C Scanner
Scanning...
I2C device found at address 0x3C !
done

I've done a lot of searching and I still have no clue as to what to do next. I'm hoping there's someone here with more experience who can help me.

Am I even using the right library? If so, then what am I doing wrong?

Thanks for taking the time to read this post!

Am I even using the right library?

Yes.

If so, then what am I doing wrong?

You need to use the correct 'constructor' to match your hardware. The I2C LCD guesser program will help you with that:
I2CLCDGUESSER --> [SOLVED] MJKDZ brand I2C Controller working with 1602 LCD - Displays - Arduino Forum

Don

Thanks for the answer, Don!

Unfortunately, it's still a no go. I2CLCDGUESSER reports a MCP23008 device:

<Press or click [Send] to Continue>
Scanning i2c bus for devices..
i2c device found at address 0x3C
Device found: MCP23008
Only supports PCF8574

That said, I did a little searching and found the LCDI2C4Bit library, but it doesn't work either. Perhaps the wiring is different?

I've tried several other libraries I could find, but none of them seems to work. Right now I'm looking at this LCD and scratching my head without any clue as to what to do next. I'm starting to think about getting another LCD module, and giving up on I2C.

That link to your product shows another link to a datasheet.
It tells you quite well how to use it.
That includes connection details and how to initialize it.
I have no idea if that is the same as what other modules expect or not.
So i can't tell whether you need to find or even build yourself some specific library to this display.

Not that that is helping much. It is pretty much gobbledegook and appears to be a composite of a number of disparate devices..

I would suggest you will need to use a standard I2C library to interface with it, and write your own routines to initialise the display, perform cursor control and send data. If, that is, you can make any sense out of the insane datasheet. I have spent some time looking at it, but am little the wiser.

There is a previous discussion here on a similar device, but I cannot locate it at present.

I gather that while the I2CLCDGUESSER reports a MCP23008 device, that is simply on the basis of its misunderstood behaviour as it clearly does not use a MCP23008 but a custom IC.

Yeah, I'm starting to feel that I'll have to write my own stuff. Looking on the back of the module, there's no MCP23008 to be found. I've been looking through the datasheet, but either I'm very lacking in basic knowledge, or it's simply that hard to understand. Anyway, I'll keep trying and see what I can sort out of it. I'll look for the similar discussion you mentioned, maybe that will give me a head start.

Sorry guys,
I didn't look closely enough at first.
I just saw all the pins and assumed it was a standard hd44780 interface using a mcp2008 based backpack.
I have code that will drive this type of native i2c display that looks like it will work on this display.
I worked with another forum member to create it as I don't have one of these types
of displays.
It is a add on to fm's library.

I'm also in the process of creating a new hd44780 multi-layer library that isn't finished yet
that will include support for this type of display.

bogg.
in the mean time if you would like to try the IIClcd code I have pm me and we'll
work offline to get it up and going.

--- bill

Was waiting for you ...

The problem was solved with the help of forum user bperrybap - thanks, Bill! As he said, my LCD module does not have a port expander backpack, it has a native I2C interface. The code from Bill drives this kind of module, and my LCD now works great.

bogg:
As he said, my LCD module does not have a port expander backpack, it has a native I2C interface.

And indeed, as I pointed out. :smiley:

But as I also said, he is the expert on these displays; you really need one on hand to try out approximations to guess what that totally addled datasheet is vainly attempting to describe; I do not have the display, so we really were waiting for him to pop up with the answer.

Presumably Bill will publish the code - and perhaps even explain what the datasheet really means!

At some point I'll release a library that should make using LCDs
with i2c interfaces (PCF8574, MCP23008 and these native interfaces)
a lot easier than it is today.

As far as the datasheet for this LCD goes, focus on pages 23, 24 and 29 of the datasheet.
That is where all the 'magic' is explained.

One thing that I didn't notice earlier is that the address for this device appears to be configurable using
the SA0 and SA1 signals (lcd pins 7 and 8).
(see pages 23 and 29 of the datasheet)

The message interface is actually pretty simple since it is just a wrapper for the
raw HD44780 interface.
The i2c messages consist of a control byte followed by 1 or more data bytes.
The control byte contains 2 bits

  • Ao (which is the RS signal level in the hd44780 interface)
  • Co (continuation bit which indicates another control byte follows the data byte)

The hd44780 interface is always in 8 bit mode so all you have to do is send the
control byte appropriately before sending the hd44780 command or data bytes.

While the i2c message interface supports sending multiple data bytes after a control byte by
setting the continuation bit, it can't really be used in the Arduino environment due
to the way the Print class works.
The Print class sends 1 byte a time through the write() interface.

So to use this type of display, you essentially just send a control byte with
the continue bit clear and Ao set/clear depending on if you want to send a
hd44780 command or a data data byte,
then send your hd44780 command or data byte.

That is pretty much it.

--- bill

Having some kind of similar issue I tried to run the lcdguesser. I installed that library: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
I removed the I2C library I was using and then it compiles.
I had some issue at typing enter or clicking send. But if I type space then send it works.
So my lcd is working with the following:

i2c device found at address 0x27
Device found: PCF8574
<Press or click [Send] to start guessing>
Trying: lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE)

How should I use it now that I have all this parameters? I had figure the 0x27, but that is my first almost hello world here...
Thanks for the good work guys, because that is already a huge step for me. Now I just need to understand what lib to use or tweak.

OK easy, doing that with the same library:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>



#define BACKLIGHT_PIN     13

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

That work.

Can someone post the lib for MCP23008 ?:frowning:

Hi, can anyone help me out with running the HD44780 MCP23008? I've been fighting with it for a while now and still all I can see are those white boxes... WHITE BOXES EVERYWHERE!!

You have resurrected an old [SOLVED] thread based on a different interface board. You don't have to look very far to find a current thread based on a board that may (or may not) be similar to the one you have but does use the same chip.

If your board is different than that one then start a new thread.

Don