-Premise (you freely can skip this if you are uninterested about my past experience).
I'm new to the Arduino world. Many years ago, when no one except professionals and very few amateurs did that, I enjoyed to make and program (assembly) MC68HC11/12 microcontrollers.
Being restricted to home, after an accident, I decided to give a try to Arduino boards (I have an UNO and a DUE). It was pretty easy to do almost anything I wanted to do with the UNO but now I'd like to shift to DUE. - end of premise.
I know this topic has been covered more than one time in the past on this forum but I could not find a way to make this to work. I have a basic Amazon/Ebay 20x4 I2C display (HD44780 based with I2C backpack) that worked flawlessly with the UNO. I connected it to the DUE (Vcc 5V, GND, SCL-21, SDA-20) after removing the pull-up SMD resistors from the backpack. The hardware interface seems to work fine, as the I2C scanner sketch finds the device at 0x27, however I could not find any version of LiquidCrystal_I2C library that works with DUE. I mean ALL of them give variable errors during compile.
If it happens to you to have a LiquidCrystal_I2C library that WORKS with DUE, would you mind to share it with me?
I agree with @david_prentice, give the hd44780 library by Bill Perry a try. If you get errors with that library, please post the code and errors. Bill, the author of the library, is very likely to see your post and will help you to get it working if we cannot.
If you have errors, please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.
thank you for your kind answers. This is the code (the original code from "Hello World!" sample included with LiquidCrystal_I2C 1.1.2). I'm using Arduino IDE 2.0.0 though:
//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
#include <C:\Users\XXXXXXXXX\OneDrive - XXXXXXXX\Documenti\Arduino\libraries\LiquidCrystal_I2C-1.1.2\LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(3,0);
lcd.print("Hello, world!");
lcd.setCursor(2,1);
lcd.print("Ywrobot Arduino!");
lcd.setCursor(0,2);
lcd.print("Arduino LCM IIC 2004");
lcd.setCursor(2,3);
lcd.print("Power By Ec-yuan!");
}
void loop()
{
}
And this is what I get:
C:\Users\SimoneMeggiato\AppData\Local\Temp\arduino-sketch-8535BE6235A46E5A7F2B765A3121734E\sketch\HelloWorld.pde.cpp.o: In function `setup':
C:\Users\XXXXXXXXXXX\OneDrive - XXXXXXXXXXXXXXX\Documenti\Arduino\libraries\LiquidCrystal_I2C-1.1.2\examples\HelloWorld/HelloWorld.pde:11: undefined reference to `LiquidCrystal_I2C::init()'
C:\Users\XXXXXXXXXXX\OneDrive - XXXXXXXXXXXXXXX\Documenti\Arduino\libraries\LiquidCrystal_I2C-1.1.2\examples\HelloWorld/HelloWorld.pde:12: undefined reference to `LiquidCrystal_I2C::init()'
C:\Users\XXXXXXXXXXX\OneDrive - XXXXXXXXXXXXXXX\Documenti\Arduino\libraries\LiquidCrystal_I2C-1.1.2\examples\HelloWorld/HelloWorld.pde:14: undefined reference to `LiquidCrystal_I2C::backlight()'
C:\Users\XXXXXXXXXXX\OneDrive - XXXXXXXXXXXXXXX\Documenti\Arduino\libraries\LiquidCrystal_I2C-1.1.2\examples\HelloWorld/HelloWorld.pde:15: undefined reference to `LiquidCrystal_I2C::setCursor(unsigned char, unsigned char)'
C:\Users\XXXXXXXXXXX\OneDrive - XXXXXXXXXXXXXXX\Documenti\Arduino\libraries\LiquidCrystal_I2C-1.1.2\examples\HelloWorld/HelloWorld.pde:17: undefined reference to `LiquidCrystal_I2C::setCursor(unsigned char, unsigned char)'
C:\Users\XXXXXXXXXXX\OneDrive - XXXXXXXXXXXXXXX\Documenti\Arduino\libraries\LiquidCrystal_I2C-1.1.2\examples\HelloWorld/HelloWorld.pde:19: undefined reference to `LiquidCrystal_I2C::setCursor(unsigned char, unsigned char)'
C:\Users\XXXXXXXXXXX\OneDrive - XXXXXXXXXXXXXXX\Documenti\Arduino\libraries\LiquidCrystal_I2C-1.1.2\examples\HelloWorld/HelloWorld.pde:21: undefined reference to `LiquidCrystal_I2C::setCursor(unsigned char, unsigned char)'
C:\Users\XXXXXXXXXXX\AppData\Local\Temp\arduino-sketch-8535BE6235A46E5A7F2B765A3121734E\sketch\HelloWorld.pde.cpp.o: In function `__static_initialization_and_destruction_0':
C:\Users\XXXXXXXXXXX\OneDrive - XXXXXXXXXXXXXXX\Documenti\Arduino\libraries\LiquidCrystal_I2C-1.1.2\examples\HelloWorld/HelloWorld.pde:7: undefined reference to `LiquidCrystal_I2C::LiquidCrystal_I2C(unsigned char, unsigned char, unsigned char)'
collect2.exe: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1
C:\Users\XXXXXXXXXXX\OneDrive - XXXXXXXXXXXXXXX\Documenti\Arduino\libraries\LiquidCrystal_I2C-1.1.2\examples\HelloWorld/HelloWorld.pde:11: undefined reference to `LiquidCrystal_I2C::init()'
That error is what happens when you use code from one of the many versions of libraries named LiquidCrystal_I2C with the wrong version.
That is a good reason to use the hd44780 library. Another good reason is that the hd44780 library will automatically determine the I2C address and the pin mapping between the LCD and the I2C backpack. It really is not difficult to change code written for a LiquidCrystal_I2C library to work with the hd44780 library. Just put in the right includes, the constructor and the begin() function in setip(). The rest of the functions from the LiquidCrystal_I2C library are the same. See the "Hello World" sketch in the hd44703_I2Cexp class examples.
_
My recommendation is to install the hd44780 library and then run the included diagnostic sketch I2CexpDiag that is one of the included examples for the hd44780_I2Cexp i/o class.
I2CexpDiag is the first sketch you should run for this type of hd44780 LCD device after installing the hd44780 library.
It will ensure that everything is working.
It tests the i2c signals (including checking for i2c signal pullups) and do an internal check on the LCD memory and will report any issues that it detects.
No configuration is needed as the hd44780 library can auto locate the i2c address of the device and auto detect the pin mapping used by the backpack.
Here is a link to the hd44780 wiki and the hd44780_I2Cexp i/o class:
--- bill
Some additional thoughts
Beyond the various build & link issues you can potentially run into from there being several different "LiquidCrystal_I2C" libraries that work differently, there can also be a few other issues.
The most common issues that I see are improper i2c signals and every so often are timing related, and
With respect to improper i2c signals I see two main issues:
Missing pullups on the i2c signals.
i2c is an open collector bus. It requires a pullup on each signal to create the HIGH signals.
Most Arduino boards do not have pullups on them, and so there must be an external one on each signal. Most of the PC8574 based i2c backpacks for hd44780 LCDs have a pullup on each i2c signal. But some don't. If you have an Arduino board that doesn't have any pullups on them and also have a LCD backpack that doesn't have any pullups, then it won't work no matter what library you use.
Now in some cases it may "work" on an Arduino board without pullups like an UNO because the UNO turns on the AVR internal pullups. However, the internal pullups are quite weak and are way out of spec, so it can have issues like being flaky or in some cases may not work at all. I do not recommend relying on AVR internal pullups; eventually it will bite you.
With respect to timing:
Some libraries are only "working" by luck. What I mean by that is they are not properly handling the timing of various hd44780 chipset instructions.
In some cases it may "work" on an UNO but then fail on a much faster processor.
The hd44780 library resolved the trick. I did try it before to ask for support but it didn't worked; I suppose it was a flaw in my code as now it works like a charm.
Please mark the thread as solved so that other members that wish to help will not waste their time opening the thread only to find that you no longer need help.