Go Down

Topic: Problems with I2C 2004 display (Read 3287 times) previous topic - next topic


Jun 29, 2014, 09:50 pm Last Edit: Jun 29, 2014, 09:53 pm by bperrybap Reason: 1

Did you move the entire folder "LiquidCrystal" contained within the .zip or just one of the files within? The entire folder should be moved.

Also, try removing or renaming any other LCD libraries you have installed. Both in you sketchbook/Libraries and in Program Files (x86)/Arduino/Libraries. Just drag the whole folder of the old one out onto the desktop temporarily or something.

It's possible the one you installed may be conflicting with the one that comes with the IDE. I may have had to do that with my project but I don't remember.

I used the auto install feature within arduino ide 1.0.5 according to the arduino website guide - and the library is called LiquidCrystal_I2C, which shouldn't interfere with the other, as it is named otherwise (According to my understanding)

The error of missing "POSITIVE" is indicating that the wrong library is being used,
which is due to the either the wrong library installed, or fm's LiquidCrystal library being installed incorrectly.

So I'm with snowman in that I would bet cash money, and lots of it, that there is a library
installation issue.

fm's LiquidCrystal library is not called LiquidCrystal_I2C
It is called LiquidCrystal
If LiquidCrystal_I2C was the name of the zip/library you installed,
you have installed the incorrect library.
The latest zip of  fm's LiquidCrystal library is LiquidCrystal_V2.1.1.zip

If you installed the LiquidCrystal_I2C library
in order to use fm's LiquidCrystal library you will have to fully uninstall LiquidCrystal_I2C

The issue is that fm's LiquidCrystal library is replacement for the standard LiquidCrystal
library and there can be header file collisions with other libraries.
Essentially, fm's LiquidCrystal library can be thought of as multiple libraries bundled together in one library.
In reality it is one library but can support many different interfaces by using different constructors.
Because of this it can be a bit confusing because the constructor names don't always match
up with the library name.
For example  in this case, the library name is LiquidCrystal but the constructor
name is LiquidCrystal_I2C

The zip image that fm created really isn't quite correct for using the IDE to install it.
I'd recommend installing manually.
You can install it in your home sketchbook/libraries directory instead of replacing
the LiquidCrystal library that came with the IDE
but you have to make sure it is named "LiquidCrystal" and that there is no other
LiquidCrystal IC2 library installed.

BulldogLowell's advice on the constructor is wrong for fm's LiquidCrystal library.
The constructor he provided was for the LiquidCrystal_I2C library which works differently.

So while both fm's LiquidCrystal library and the LiquidCrystal_I2C library both have a constructor
called LiquidCrystal_I2C, that is used to initialize the library for a PCF8574 based LCD backpack,
they are different libraries and use very different parameters in the constructors.

fm's LiquidCrystal library works with any backpack so it requires that you tell it how the PCF8547 is wired to the LCD.
LiquidCrystal_I2C library only supports a particular wiring so it does not need to now how it is wired up
but it may not work with your backpack.

The examples on Terry's yourduino.com site, referenced above are for fm's LiquidCrystal library not
the LiquidCrystal_I2C library.

You can only have one of these libraries installed at a time other wise, strange things can happen
since they collide with each other and the IDE can pick the wrong one or potentially even pick and choose different ones
at different points of time during the build process.
Which is why you see the POSITIVE error message.

--- bill


So, how would i go about uninstalling librarys? Simply just moving them, and/or renaming them - then start/re-start the arduino ide?
And should i remove every library containing the words liquid*?
And now you really must be patient with me. I've searched my computer for a folder called sketchbook without any luck. Can i get some clarification?

Also, i am not able to google search the v2.1.1 library - is it called any different perhaps?


If you go to File -> Preferences in your Arduino IDE, right at the top, it will show you the location of your sketchbook folder.

As for uninstalling libraries, for this case at least, I would move any folder with the word "Liquid", "crystal" or "LCD" in it's name completely out of your libraries folder. From both library locations.

Then follow the directions I posted above.


If you go to File -> Preferences in your Arduino IDE, right at the top, it will show you the location of your sketchbook folder.

As for uninstalling libraries, for this case at least, I would move any folder with the word "Liquid", "crystal" or "LCD" in it's name completely out of your libraries folder. From both library locations.

Then follow the directions I posted above.

This made a lot of sense.
Nothing left with LCD, liquid or crystal remaining in either folder :)

Ran a i2c scanner in the meantime;
I2C device found at address 0x27  !

So it's there allright


I'm up and running with the library from Snowman815901 - i'm quite pleased :)

You all been a great help! And this isnt the last you heard from me, because now i'll venture in to serial communications with an engine management, and how to get it to display on the arduino LCD :D

Thank you very much everybody

Code: [Select]

/* YourDuino.com Example Software Sketch
20 character 4 line I2C Display
Backpack Interface labelled "LCM1602 IIC  A0 A1 A2"
terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <Wire.h>  // Comes with Arduino IDE
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>

/*-----( Declare Constants )-----*/
/*-----( Declare objects )-----*/
// set the LCD address to 0x20 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

/*-----( Declare Variables )-----*/

void setup()   /*----( SETUP: RUNS ONCE )----*/
  Serial.begin(9600);  // Used to type in characters

  lcd.begin(20,4);         // initialize the lcd for 20 chars 4 lines and turn on backlight

// ------- Quick 3 blinks of backlight  -------------
  for(int i = 0; i< 3; i++)
  lcd.backlight(); // finish with backlight on 
//-------- Write characters on the display ----------------
// NOTE: Cursor Position: CHAR, LINE) start at 0 
  lcd.setCursor(0,0); //Start at character 4 on line 0
  lcd.print("     RSMTUNING      ");
  lcd.print("   Megasquirt 1   ");
  lcd.print("   Race-display     ");
  lcd.print("  Under udvikling  ");
  lcd.setCursor(0,0); //Start at character 4 on line 0
  lcd.print("   RPM: 1000");
  lcd.print("   MAP: 127 kpa");
  lcd.print("   AFR: 12.5");
  lcd.print("  Temp: 88");

// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
//  lcd.setCursor(0,0); //Start at character 0 on line 0
//  lcd.print("Start Serial Monitor");
//  lcd.setCursor(0,1);
//  lcd.print("Type chars 2 display");   

}/*--(end setup )---*/

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
    // when characters arrive over the serial port...
    if (Serial.available()) {
      // wait a bit for the entire message to arrive
      // clear the screen
      // read all the available characters
      while (Serial.available() > 0) {
        // display each character to the LCD

}/* --(end main loop )-- */

/* ( THE END ) */


You don't have to move/remove the original LiquidCrystal library that came with the IDE.
Libraries in your user sketchbook area override libraries that came with the IDE as long
as the names of the directories are the same.
So if you name the directory "LiquidCrystal" when you installed fm's LiquidCrystal library
it would override the LiquidCrystal library that same with the IDE.

As a small note:
For the time being, the IDE rejects library directory names that have a dot/period in them
So if you rename a library from foo to foo.sav then the library will not be used.
The only drawback is that you will see a warning when the IDE starts up.
Sometimes this is useful in certain situations or for testing as you can simply rename the directory
and restart the IDE to get the IDE to ignore a library.

So for example, if left the original LiquidCrystal library in place and installed fm's library down in
your sketchbook directory, it would override the IDE LiquidCrystal library if you named it LiquidCrystal.
If at some point you wanted to use the original LiquidCrystal again, if you renamed fm's library directory
to LiquidCrystal.sav then it would be ignored and you would use the original IDE library.
However when the IDE starts it will give you a warning that it is ignoring that library.

--- bill

Go Up