Hi, I need some help with a code :)

Hi, im new here, and when I tried an Arduino Code which is funtional, the next error appears:
“int LiquidCrystal::init()” is private within this context

In file included from C:\Users\PCW10\AppData\Local\Temp\Rar$DIa1900.47720\Sketch-Ardu-OHM\Sketch-Ardu-OHM.ino:2:0:
C:\Users\PCW10\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:154:9: note: declared private here
int init();
^~~~
exit status 1
‘int LiquidCrystal_I2C::init()’ is private within this context.

I’m using this library: Arduino - LiquidCrystal

And this is the entery code:

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


/*________________________________
  |Original Sketch By Aaron Kable|
  --------------------------------
  Monitoreo de PC mediante: Arduino + Open hardware monitor, Con LCD 20x4 
  Sketch modificado Por "Fenrir93" 22/11/2016
  
 */
LiquidCrystal_I2C lcd(0x27,20,4); // Declaramos nuestra LCD

/*Creamos Carateres especiales para nuestro monitor*/
  byte line5[8] =
  {// full
    B11111,
    B00000,
    B11111,
    B11111,
    B11111,
    B11111,
    B00000,
    B11111
  };

  byte line4[8] =
  {// 80%
    B11111,
    B00000,
    B11110,
    B11110,
    B11110,
    B11110,
    B00000,
    B11111
  };

  byte line3[8] =
  {// 60%
    B11111,
    B00000,
    B11100,
    B11100,
    B11100,
    B11100,
    B00000,
    B11111
  };

  byte line2[8] =
  {// 40%
    B11111,
    B00000,
    B11000,
    B11000,
    B11000,
    B11000,
    B00000,
    B11111
  };

  byte line1[8] =
  { //  20%
    B11111,
    B00000,
    B10000,
    B10000,
    B10000,
    B10000,
    B00000,
    B11111
  };

  byte line0[8] =
  { // empty
    B11111,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B11111
  };
  
  byte loadchar[8] =
  { // Caracter % para la grafica
    B11111,
    B00000,
    B10010,
    B00100,
    B01000,
    B10010,
    B00000,
    B11111
  };
  byte tempchar[8] =
  { // termometro
    B00100,
    B01010,
    B01010,
    B01010,
    B01010,
    B10001,
    B10001,
    B01110
  };

String inputString = "";  //String de entrada compuesto

boolean NewData = false;

//Declaramos strings de datos fraccionando el string compuesto
String CPUT = ""; //Temperatura de CPU
String GPUT = ""; // Temperatura de GPU
String GPUFC = ""; // % de control del ventilador de la GPU
String MotherT= ""; // Temperatura de la MotherBoard
String HDDT = ""; // Temperatura del disco duro
//Variables para conversiones matematicas, a partir de inputString
int Cload= 0; // Variable de la carga actual del Procesador
int Gload= 0; //variable de la carga actual de la GPU
int CFanSpeed= 0; //Variable RPM Ventilador de CPU (revisar conector en motherboard)
int SpeedMap= 0; // Variable de conversion de RPM a %(0 a 100);
int RLoad= 0; // % de Uso de la ram total 0 a 100
int Aviso1= 0; //Variable extra para proporcionar un aviso visual o auditivo, cuando la temperatura llegue a cierto Valor
int Aviso2= 0; //Variable extra para proporcionar un aviso visual o auditivo, cuando la temperatura llegue a cierto Valor

void setup() {
 
  // setup LCD
  lcd.init();
  //lcd.backlight(); //Si borramos los "//" del inicio la retroiluminacion del lcd se activa al encender la PC
  Serial.begin(9600);
  // Reservamos 400 bits para inputString:
  inputString.reserve(400);

  lcd.backlight();
  lcd.setCursor(2,0);
  lcd.print("Monitor de temp.");
  lcd.setCursor(3,1);
  lcd.print("Arduino & OHM");
  lcd.setCursor(4,2);
  lcd.print("By Fenrir_93");
  lcd.setCursor(7,3);
  lcd.print("Para T!");
  delay(4000);
  lcd.clear();
  lcd.noBacklight();
  //Descripcion de los datos que se imprimiran en la LCD  
  lcd.backlight();
  lcd.setCursor(1,0);
  lcd.print("CPU-Temp-Fan-Load");
  lcd.setCursor(1,1);
  lcd.print("GPU-Temp-Fan-Load");
  lcd.setCursor(6,2);
  lcd.print("RAM Load");
  lcd.setCursor(4,3);
  lcd.print("Mother & HDD");
  delay(4000);
  lcd.clear();
  lcd.noBacklight();

  
  

  /*Declaramos pines 12 y 13 como salida*/
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  
  
  //Creamos los carater especiales
  lcd.createChar(6, line0); // No se puede usar"0"
  lcd.createChar(1, line1);
  lcd.createChar(2, line2);
  lcd.createChar(3, line3);
  lcd.createChar(4, line4);
  lcd.createChar(5, line5);
  lcd.createChar(7, loadchar);
  lcd.createChar(8, tempchar);
  

}
int iHome = 1;
int diff = 1;
int count = 5; 
int dely = 0;


//Dibujamos la graficas con los caracteres especiales
void graph(int load, int width){
  
  
 
  float weight = 100/width;
  float full_cells_f = load/weight;
  int full_cells = full_cells_f;

  int i = 0;
  while(i<full_cells){
    lcd.write(5);
    i++;
  }
  // escalamos las celdas
  int wt = weight;
  int test = (load-(wt*full_cells))/2;
  if (test == 0){
    test = 6;
  }
  if (load < 100){
    lcd.write(test);
  }
  i++;
  while(i<width){
    lcd.write(6);
    i++;
  }
  
  }
  void loop() {
    
  if (NewData) {    
    //Limpiamos la LCD al empezar
    //Emepzamos a distribuir nuestros datos en el LCD (Nota: esta distribucion es para una lcd 20x4)
    lcd.backlight(); //encendemos la retroiluminacion del LCD
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.write(8);
    lcd.print(CPUT);
    lcd.print((char)223);
    lcd.setCursor(5,0);
    lcd.print(SpeedMap);
    lcd.setCursor(0, 1);
    lcd.write(8);
    lcd.print(GPUT);
    lcd.print((char)223);
    lcd.setCursor(5,1);
    lcd.print(GPUFC);
    lcd.setCursor(9,1);
    lcd.write (7);
    graph(Gload,10);
    lcd.setCursor(9, 0);
    lcd.write(7);
    graph(Cload,10);
    lcd.setCursor(1,2);
    lcd.print("RAM");
    lcd.setCursor(9,2);
    lcd.write(7);
    graph(RLoad,10);
    lcd.setCursor(0,3);
    lcd.print("Mother:");
    lcd.write(8);
    lcd.print(MotherT);
    lcd.print((char)223);
    lcd.setCursor(12,3);
    lcd.print("HDD:");
    lcd.write(8);
    lcd.print(HDDT);
    lcd.print((char)223);
    /*Calculo de ventilador del CPU, de RPM a %*/
    SpeedMap= map(CFanSpeed,0,3080,0,100);// En este caso el numero 3080 indica las RPM maxima del ventilador.
    /*Valor para activar el led del pin13 cuando la temperatura llegue o supere cierto valor*/
    if(Aviso1 >= 50){
      digitalWrite(13,HIGH);
    }                       //Se enciende al llegar  a los 50 o mas grados en este ejemplo
     else{
        digitalWrite(13,LOW);
      }                      //Se apaga si menor a dicha temperatura
      if(Aviso2 >= 50){
      digitalWrite(12,HIGH);
    }                       //Se enciende al llegar  a los 50 o mas grados en este ejemplo
     else{
        digitalWrite(12,LOW);
      }                      //Se apaga si menor a dicha temperatura
/*Borramos el Input*/
    inputString = "";
    NewData = false;
  }
}

int b[8];// b #0
void serialEvent() {
  b[0] = 0;
  while (Serial.available()) {
    // Obtener el nuevo byte:
    char inChar = (char)Serial.read(); 
    // Agregarlo a inputString:
    inputString += inChar;
    // Si el carácter entrante coincide habilitamos:
   
    if (inChar == '\n') {
      //Establecemos los separadores ","
      b[1] = inputString.indexOf(',');
      b[2] = inputString.indexOf(',', b[1]+1);
      b[3] = inputString.indexOf(',', b[2]+1);
      b[4] = inputString.indexOf(',', b[3]+1);
      b[5] = inputString.indexOf(',', b[4]+1);
      b[6] = inputString.indexOf(',', b[5]+1);
      b[7] = inputString.indexOf(',', b[6]+1);
      b[8] = inputString.indexOf(',', b[7]+1);
      b[9] = inputString.indexOf(',', b[8]+1);
      b[10] = inputString.indexOf(',', b[9]+1);
      //Seleccionamos los strings de entrada para poder imprimirlos en la lcd
      CPUT = inputString.substring(b[0],b[1]);
      GPUT = inputString.substring(b[3]+1,b[4]);
      GPUFC = inputString.substring(b[5]+1,b[6]);
      MotherT = inputString.substring(b[7]+1,b[8]);
      HDDT = inputString.substring(b[8]+1,b[9]);
      //Declaramos strings para conversion a "int" 
      String RPM = inputString.substring(b[2]+1,b[3]);
      String loadHold = inputString.substring(b[1]+1,b[2]);
      String loadHold2 = inputString.substring(b[4]+1,b[5]);
      String RL = inputString.substring(b[6]+1,b[7]);
      //Convertimos Los string a "int" para crear avriables para la funcion de la grafica de Load
      Cload = loadHold.toInt();
      Gload = loadHold2.toInt();
      CFanSpeed = RPM.toInt();
      RLoad = RL.toInt();
      Aviso1 = CPUT.toInt();
      Aviso2 = CPUT.toInt();
     NewData = true;
    } 
  }
  
}

I wish somebody helps me.
Sorry for my English level :wink:

Is a bit confusing.

Have you gotten a simple example program, unmodified, to work with you LCD device as you have it wired?

a7

Yes, the LCD works perfectly with a simple code
(Hello World! code) Obiusly using I2C and the library installed

i was able to build your code without error. i have LiquidCrystal_I2C installed. My version of LiquidCrystal.h has only 131 lines. The error reports 154:9, line 154 column 9

since the error is with LiquidCrystal_I2C.h, i can only suggest reinstalling the library

1 Like

Ok, I will try It.

Anyway, What version of LiquidCrystal_I2C do you have installed?

1.1.4

I couldn’t find that version searching with the library manager, how can I get it??

The number of colunms on the LCD and the number of lines are missing.

See: Arduino - LiquidCrystalBegin

Ex: lcd.init(16,2);

RV mineirin

Thanks for your help but, when I add lcd.init (20, 4) the next error appears:
“No matching function for call to LiquidCrystal_I2C::int(int, int)”
C:\Users\PCW10\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:87:8: note: candidate expects 0 arguments, 2 provided
exit status 1
no matching function for call to ‘LiquidCrystal_I2C::init(int, int)’

Sorry, I wrote it wrong.
it is not lcd.init (16,2);
the correct form is: lcd.begin (16,2);

https://www.arduino.cc/en/Reference/LiquidCrystalBegin

RV mineirin