PlatformIO Community

What library do I need to use for this code for controlling an LCD I2C display?

My code is like so -

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

void setup()
{
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(16, 0);
  lcd.print(" MEOW ");
}

void loop()
{
  lcd.setCursor(16, 1);
  lcd.autoscroll(); // Set diplay to scroll automatically
  lcd.print(" ");   // set characters
  delay(700);
}

but the first line gives an error saying a constructor cannot be found. Any help?

What’s this constructer supposed to do? When I look into the LiquidCrystal_I2C library is see

A constructor that wants the I2C address, and number of columns and rows. And there’s no other constructor which takes that many arguments as your code shows.

If you have code which calls into another constructor then you’re probably using a different library. Which one do you want / have you installed in the Arduino IDE?

I’ve installed the LiquidCrystal_I2C library, but I’m not sure if I need to use it or the default LiquidCrystal library.

Okay so yeah, the first google result when searching for

leads to https://forum.arduino.cc/index.php?topic=214356.0 wich points to this library being used:

Which already has a library.json for PlatformIO with the name

So according to docs you should add in your platformio.ini

lib_deps = 
  LiquidCrystal

while removing any other references to LiquidCrystal_I2C in the platformio.ini.

Also refer https://platformio.org/lib/show/136/LiquidCrystal/installation.

Just one problem - the LiquidCrystal library (at least the one by Arduino) don’t have direct support for I2C displays, and I can’t find one that does. Am I missing something?

The library name is indeed double. PIO also tells you this during installation.

C:\Users\Maxi\.platformio\platforms>pio lib --global install LiquidCrystal
Library Storage: C:\Users\Maxi\.platformio\lib
Library Manager: Installing LiquidCrystal
Library Manager: Warning! More than one package has been found by LiquidCrystal requirements:
 - bitbucket-fmalpartida/LiquidCrystal @ 1.5.0
 - arduino-libraries/LiquidCrystal @ 1.0.7
Library Manager: Please specify detailed REQUIREMENTS using package owner and version (showed above) to avoid name conflicts
Library Manager: LiquidCrystal @ 1.5.0 has been installed!

so what you’d actually want to do is to delcare

 lib_deps = 
   bitbucket-fmalpartida/LiquidCrystal

(possible since PIO 5.0.0) to make it unambigious. You’ll then receive the library with the correct code.

(You also already receive the correct library since as you can see it autochoose bitbucket-fmalpartida/LiquidCrystal @ 1.5.0 for me when saying LiquidCrystal)

I seriously don’t know what’s happening. I can see the library is installed and the code is running, but nothing shows up on my display.

What display do you have exactly?

Does the same code compile in the Arduino IDE and run correctly?

Also if you have installed any LiquidCrystal library in the global library storage, please remove it, those can still cause conflicts.

So - I don’t know what I did, but it’s now working. Thank you very much for the help.