What is going on with the LCD I2C library?

I'm having an issue with the LCD I2C library.
It says POSITIVE not declared???

This is strange because just a few months ago I used the library and it compiled fine and the project worked great.

The new project wont compile... I re-opened the old project (the one that worked) and now it wont compile either.

Any assistance with this would be great.
Thanks.

Did you forget to post your code and a link to where the LCD library was downloaded from ?

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

// Pins
int TR_PIN = A1;  // Thermistor
int SetPin = A3 ; // Pot
int LED_B = 9;    // PWM capable
int LED_G = 10;   // PWM capable
int LED_R = 11;   // PWM capable
int relayPin = 3; // PWM capable
const byte relaySensor = 4;   //
const byte button = 2;        // toggle switch

// Constants
int SensorTimer = 7000;  // 7  seconds

//Variables
int sensorVal;
int setVal;
int sensorTemp;
int setTemp;
int tempDiffPos;
int tempDiffNeg;
int count;
int sensorCount;
int MainsPollVal;
int MainsPollValA;
bool State;
float realTemp;
float trueTemp;
double a1, b1, c1, d1, r2, r1, vo, tempC, tempF, tempK;

unsigned long TimeNow;
unsigned long LastTime;

void setup() {
  // put your setup code here, to run once:
  lcd.begin(16, 2);
  Serial.begin(9600);

  pinMode(LED_B, OUTPUT);
  pinMode(LED_G, OUTPUT);
  pinMode(LED_R, OUTPUT);
  pinMode(SetPin, INPUT);
  pinMode(relayPin, OUTPUT);
  pinMode(relaySensor, INPUT);
  pinMode(button, INPUT);
  pinMode(TR_PIN, INPUT);

  a1 = 3.354016E-03 ;
  b1 = 2.569850E-04 ;
  c1 = 2.620131E-06 ;
  d1 = 6.383091E-08 ;
  r1 = 9720.0;

  tempDiffPos = 0.00;
  tempDiffNeg = 0.00;
}

// MAIN LOOP
void loop() {

  while ((setTemp == 0) && (digitalRead(button) == LOW)) {
    Start_Up();
  }

  while (digitalRead(button) == HIGH) {
    count = 0;
    MainsPollVal = 0;
    MainsPollValA = 0;
    SetTempVal();
  }

  // show state ture
  if (State == true) {
    lcd.setCursor(0, 1);
    lcd.print("^");
  }

  // check sensor
  TimeNow = millis();
  if (LastTime <= TimeNow - SensorTimer) {
    sensorPoll();
    LastTime = TimeNow;
    Serial.print(State);
  }

  tempDiffPos = (trueTemp - setTemp);
  tempDiffNeg = (setTemp - trueTemp);

  while ((MainsPollVal == 10) || (MainsPollVal - MainsPollValA == 10)) {
    MainsPollValA = MainsPollVal;
    Fault();
    if (digitalRead(button) == HIGH) {
      break;
    }
  }


  // COOLING
  while ((trueTemp - setTemp >= 0) && (State == true)) {
    digitalWrite(relayPin, HIGH);
    // digitalWrite(LED_B, HIGH);
    digitalWrite(LED_G, LOW);
    digitalWrite(LED_R, LOW);
    delay(25);
    Display();
    MainsCheck();
    Fade_Blue();
    // check sensor
    TimeNow = millis();
    if (LastTime <= TimeNow - SensorTimer) {
      sensorPoll();
      LastTime = TimeNow;
      Serial.print(State);
    }
     if (digitalRead(button) == HIGH) {
      break;
    }
    if (setTemp - trueTemp >= 0) {
      digitalWrite(relayPin, LOW);
      MainsPollVal = 0;
      MainsPollValA = 0;
      State = false;
      lcd.clear();
      break;
    }
    if ((MainsPollVal == 10) || (MainsPollVal - MainsPollValA == 10)) {
      MainsPollValA = MainsPollVal;
      Fault();
      break;
    }

  }
  //GOOD TEMP
  while ((((setTemp - trueTemp > 0) && (setTemp - trueTemp < 1.75)) || ((trueTemp - setTemp > 0) && (trueTemp - setTemp < 1.75))) && (State == false))  {
    // digitalWrite(LED_G, HIGH);
    digitalWrite(LED_B, LOW);
    digitalWrite(LED_R, LOW);
    digitalWrite(relayPin, LOW);
    Display();
    Fade_Green();
    // check sensor
    TimeNow = millis();
    if (LastTime <= TimeNow - SensorTimer) {
      sensorPoll();
      LastTime = TimeNow;
      Serial.print(State);
    }
     if (digitalRead(button) == HIGH) {
      break;
    }
    if (trueTemp - setTemp > 1.6) {
      State = true;
      break;
    }
  }

  // HIGH SET TEMP
  if (setTemp - trueTemp > 1.75) {
    // digitalWrite(LED_R, HIGH);
    digitalWrite(LED_B, LOW);
    digitalWrite(LED_G, LOW);
    digitalWrite(relayPin, LOW);
    // State = false;
    Fade_Red();
  }
}
//StartUP
void Start_Up() {
  lcd.setCursor(0, 0);
  lcd.print(" !  Mmmmmmmm  ! ");
  lcd.setCursor(0, 1);
  lcd.print("  KOEL'D  BEER  ");
  digitalWrite(relayPin, LOW);
  analogWrite(LED_B, random(10, 255));
  delay(50);
  analogWrite(LED_G, random(10, 255));
  delay(50);
  analogWrite(LED_R, random(10, 255));
  delay(50);
}
// TEMP SENSOR VALUE
// read temp sensor and return temp value
int sensorPoll() {
  // READ REAL TEMP
  sensorCount++;
  vo = analogRead(TR_PIN);
  vo = vo / (1023.0 / 5.0);

  // voltage divider calculation
  // vo = 5 * r2 /(r1+r2)
  // solve for r2
  // get the exact value for voltage divider r1

  r2 = ( vo * 7840) / (5.0 - vo);

  //equation from data sheet
  tempK = 1.0 / (a1 + (b1 * (log(r2 / 32500))) + (c1 * pow(log(r2 / 20040), 2.0)) + (d1 * pow(log(r2 / 11210), 3.0)));
  tempC  = (tempK - 273.15);
  tempF  = ((tempC * 1.8) + 32.0) * 10;
  realTemp = map(tempF, 1350, 860, 350, 740);
  trueTemp = realTemp / 10;
  return trueTemp;
}
// SET TEMPURATURE
// read potentiometer for setting temperature
int SetTempVal() {
  lcd.setCursor(0, 0);
  lcd.print("  KOEL'D  BEER  ");
  lcd.setCursor(0, 1);
  lcd.print(" SET TEMP     ");
  setVal = analogRead(SetPin);
  setTemp = map (setVal, 2.0, 880.0, 28.0, 80.0);   // change 120 to 80
  lcd.setCursor(14, 1);
  lcd.print(setTemp);
  delay(100);
  State = true;
  return setTemp;
}
//LED FADE
void Fade_Blue() {
  for (int b = 15; b <= 255; b++) {
    analogWrite(LED_B, b);
    delay(5);
  }
  for (int b = 255; b >= 15; b--) {
    analogWrite(LED_B, b);
    delay(5);
  }
}
void Fade_Green() {
  for (int g = 15; g <= 255; g++) {
    analogWrite(LED_G, g);
    delay(5);
  }
  for (int g = 255; g >= 15; g--) {
    analogWrite(LED_G, g);
    delay(5);
  }
}
void Fade_Red() {
  for (int r = 15; r <= 255; r++) {
    analogWrite(LED_R, r);
    delay(5);
  }
  for (int r = 255; r >= 15; r--) {
    analogWrite(LED_R, r);
    delay(5);
  }
}
// CHECK MAINS SENSOR
// check mains voltage sensor for voltage
int MainsCheck() {
  if (digitalRead(relaySensor) == LOW) {
    digitalWrite(relayPin, HIGH);
    MainsPollVal++;
    delay(20);
    return MainsPollVal;
  }
}
//FAULT
void Fault() {
  digitalWrite(LED_B,LOW);
  lcd.setCursor(0, 0);
  lcd.print("     SYSTEM     ");
  lcd.setCursor(0, 1);
  lcd.print("     FAULT!     ");
  digitalWrite(LED_R, HIGH);
  delay(500);
  digitalWrite(LED_R, LOW);
  delay(500);
}

void Display() {
  lcd.setCursor(0, 0);
  lcd.print("SENSOR      ");
  lcd.setCursor(12, 0);
  lcd.print(trueTemp);
  lcd.setCursor(1, 1);
  lcd.print("  SET        ");
  lcd.setCursor(14, 1);
  lcd.print(setTemp);
  // show state ture
  if (State == true) {
    lcd.setCursor(0, 1);
    lcd.print("^");
  }
}

https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

I found this link after I googled the issue. I followed what that thread said but it hasn’t been helping.

I found this link after I googled the issue. I followed what that thread said but it hasn’t been helping.

I think that means that you did not download the library from there. I am not sure what you are referring to with regards to a thread as I though that bitbucket was a file repository rather than a discussion forum.

It sounds to me as though the library that you are using has changed since you first wrote the code. In the LiquidCrystal_I2C library that I have POSITIVE is defined in an enum in LCD.h

Please post the full error message

HTH.

UKHeliBob:
I think that means that you did not download the library from there. I am not sure what you are referring to with regards to a thread as I though that bitbucket was a file repository rather than a discussion forum.

there was a thread on this forum that led to the file repository.

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Uno"

Koel_d_Beer_3.0:3:53: error: 'POSITIVE' was not declared in this scope

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

                                                     ^

Multiple libraries were found for "LiquidCrystal_I2C.h"
 Used: E:\Customer Arduino\libraries\LiquidCrystal_I2C-1.1.2
 Not used: E:\Customer Arduino\libraries\NewLiquidCrystal_lib
exit status 1
'POSITIVE' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Besides: why does the line "LiquidCrystal_I2C lcd(0x27.." etc. need so many parameters? An I2C library only needs an address (like 0x27), and sometimes the number of rows and columns of the display! Certainly no pin numbers...

Erik_Baas:
Besides: why does the line "LiquidCrystal_I2C lcd(0x27.." etc. need so many parameters? An I2C library only needs an address (like 0x27), and sometimes the number of rows and columns of the display! Certainly no pin numbers...

I don't know to be honest. Thats just how the example was when I first used it and it worked great, now it doesn't work.

Here's your clue:

LandonW:

Multiple libraries were found for "LiquidCrystal_I2C.h"

Used: E:\Customer Arduino\libraries\LiquidCrystal_I2C-1.1.2
Not used: E:\Customer Arduino\libraries\NewLiquidCrystal_lib

There are multiple libraries that contain a file named LiquidCrystal_I2C.h. Despite the same filenames, the libraries have different APIs. You have multiple of these libraries installed on your computer. The one your code was written for is installed at E:\Customer Arduino\libraries\NewLiquidCrystal_lib, but the Arduino IDE selected the one installed at E:\Customer Arduino\libraries\LiquidCrystal_I2C-1.1.2. Thus, the error.

If you don't have any use for the library at E:\Customer Arduino\libraries\LiquidCrystal_I2C-1.1.2 then you can just delete that folder to solve the issue.

If you do need that library, then there is a trick we can use to force the Arduino IDE to use the right library. You only need to add an #include directive to your sketch for a unique .h file in the correct library above the #include directive for LiquidCrystal_I2C.h. In this case, I2CIO.h will do the trick.

Erik_Baas:
Besides: why does the line "LiquidCrystal_I2C lcd(0x27.." etc. need so many parameters? An I2C library only needs an address (like 0x27), and sometimes the number of rows and columns of the display! Certainly no pin numbers...

LandonW:
I don't know to be honest. Thats just how the example was when I first used it and it worked great, now it doesn't work.

The additional parameters map the pins of an I2C expander to the pins on the LCD module, not all I2C interfaces are connected the same way.

pert:
Here's your clue:There are multiple libraries that contain a file named LiquidCrystal_I2C.h. Despite the same filenames, the libraries have different APIs. You have multiple of these libraries installed on your computer. The one your code was written for is installed at E:\Customer Arduino\libraries\NewLiquidCrystal_lib, but the Arduino IDE selected the one installed at E:\Customer Arduino\libraries\LiquidCrystal_I2C-1.1.2. Thus, the error.

If you don't have any use for the library at E:\Customer Arduino\libraries\LiquidCrystal_I2C-1.1.2 then you can just delete that folder to solve the issue.

If you do need that library, then there is a trick we can use to force the Arduino IDE to use the right library. You only need to add an #include directive to your sketch for a unique .h file in the correct library above the #include directive for LiquidCrystal_I2C.h. In this case, I2CIO.h will do the trick.

Thanks, that worked. I don't remember downloading extra libraries..... oh well.

Again, thank you.

You're welcome. I'm glad to hear it's working now. Enjoy!
Per