20x4 I2C Serial LCD Display Module with Arduino Create

Hi

Need a bit of help with libraries, I've got a 4 x 20 line display I got a few years back from www.hobbycomponents.co.uk and it all works really well but I've now got to make a few mods to the code which I wrote a couple of years back and neither the local IDE or the on-line editor will compile the code now.

I've played around with several libraries but can't seem to find one that works in the latest IDE or online editor. It seems some of the .h files are now included by default (I think). I'm sure I'm missing something very simple but can anyone help with a library that will work with Arduino Create or do I need to scrap display and get a newer one? I've tried importing the original but it needs a setup file to allow an import that I don't have.

My original code started with:

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

And this to set up screen

// Set the LCD address to 0x27 and specify display to be 4 lines x 20 characters
LiquidCrystal_I2C lcd(0x27, 20, 4);

But using latest libraries I now get a variety of errors.

Any thoughts on what I've missed?

Thanks
Darrell

LiquidCrystal_I2C lcd(0x27, 20, 4);

That constructor depends on the LCD to I2C expander pin mapping to be the library default pin mapping. That may not be the case.

For an I2C LCD display to work, the I2C address and the I2C backpack to LCD pin mapping must be correct. If the library default settings for either or both are not correct the LCD will not work. You can try to figure out the right pin mapping and use an I2C scanner to find the address, but if you install and use the hd44780 library that is done automatically by the library.

Install the hd44780 library. The hd44780 library is the best available for I2C LCDs. The library is available in the Library Manager. Go to Library Manager (in the IDE, Sketch, Include Libraries, Manage Libraries) and in the Topics dropdown choose Display and in the Filter your search box enter hd44780. Select and install the hd44780 library by Bill Perry.

The class that you want to use is the hd44780_I2Cexp class. There are examples to show how to use the library. The nice thing about the hd44780 library is that it will autodetect the I2C address and the I2C backpack to LCD pin mapping.

In the examples, there is a diagnostic sketch that will help us to help you if you still have trouble with the display. Run the diagnostic sketch and post the results in a new post.

But using latest libraries I now get a variety of errors.

We cannot help with the errors if we don't know what they are. Post the entire error message(s). Paraphrasing the errors always leaves out important information.

groundFungus:

LiquidCrystal_I2C lcd(0x27, 20, 4);

That constructor depends on the LCD to I2C expander pin mapping to be the library default pin mapping. That may not be the case.

Ah, but he said it worked before!

You are of course correct. He needs to start afresh with the HD44780 installed in the most recent IDE, and use its examples which will show what includes are - or are not - required.

darrelletherington:
Hi

. . .

My original code started with:

#include <Wire.h>
#include <WString.h>
#include <LiquidCrystal_I2C.h>
. . .
Any thoughts on what I've missed?

Thanks
Darrell

To answer your question - you have missed the fact that there is more than one library named 'LiquidCrystal_I2C' and you are probably not using the same one that you used previously.

The remedy has been mentioned already, use the HD44780 library instead.

Don

Hi thanks for than answers, I'll have a play with the HD44780 library - as mentioned it used to work perfectly, no issues with code or library, just somewhere in last 2 years IDE and/or library changed. The hardware is definitely configured okay as that hasn't changed.

Is the HD44780 library available anywhere in a format I can use with online editor which is now my preference?

Thanks for the advice.
Darrell.

I know nothing of the online editor or what libraries work with it.

Hi
All seems to be working fine now, found the library version 1.0.2 and it uploads fine. Everything now compiles again although I had to replace lcd.begin() with lcd.init() which I think is the new correct command (correct me if I'm wrong). I'll try it on the physical hardware later in the week but this seems to compile fine.

Thanks again
darrell.

I'm glad to hear you got it working! Although the hd44780 library does come highly recommended, I think since you already had code using the LiquidCrystal_I2C library it was quite reasonable to just get that code working instead of switching to a new library.

In case you ever do want to try out the hd44780 for another project, I'll go ahead and answer your question:

darrelletherington:
Is the HD44780 library available anywhere in a format I can use with online editor which is now my preference?

All the libraries in the Arduino Library Manager index are pre-installed in the Arduino Web Editor. Since the hd44780 library is in the Arduino Library Manager index, you already have it installed and can just go ahead and use it without having to do anything at all. If you want access to the example sketches of the library, you will need to add it to your "Favorites":

  • Click on the "Libraries" tab on the left side of the Arduino Web Editor screen.
  • Click the "Library Manager" button.
  • In the "Search Library" field, type "hd44780".
  • In the search results, click the star at the right of "HD44780 Extensible hd44780 LCD library".
  • Click the "Done" button.

You will now find the hd44780 library listed under the "Favorites" tab. If you click on the "> Examples" at the bottom of that library entry, it will open a menu of the library's example sketches.