Which LiquidCrystal_I2C library

Had a hard drive fail on my main pc so had to reinstall yonks of programs including Arduion IDE.

My codes are stored thankfully on other drives however, I cannot seem to find the library for LiquidCrystal_I2C that I used originally (there are many when I searched)

The original library uses lcd.init() rather than lcd.begin() and throws up the below error message as it cannot find the correct library.

I do remember having to go to the library h file I think, and change the address of the particular 16x2 lcd's I use.

Arduino: 1.8.19 (Windows 10), Board: "Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)
C:\Users\Jeff\Desktop\Electronics stuff\Birthdays Arduino\ClockBday3_withTestandCompensation_Final\ClockBday3_withTestandCompensation_Final.ino: In function 'void setup()':

ClockBday3_withTestandCompensation_Final:67:7: error: 'class LiquidCrystal_I2C' has no member named 'init'

   lcd.init ();                  // initialize the lcd

       ^~~~

Multiple libraries were found for "Adafruit_I2CDevice.h"

 Used: C:\Users\Jeff\Documents\Arduino\libraries\Adafruit_BusIO

 Not used: C:\Users\Jeff\Documents\Arduino\libraries\Adafruit_BusIO-master

exit status 1

'class LiquidCrystal_I2C' has no member named 'init'



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

1 Like

This file has init() (the "lcd." part was your naming), but it also has begin()... so maybe/~maybe

It is really easy to change any sketch that used any of the LiquidCrystal_I2C libraries to use the hd44780 library. That library automatically detects I2C address and LCD to I2C backpack pin mapping. The library is available in the Library Manager. The class that you want to use is the hd44780_I2Cexp class.

If you like, post one of your programs and I will make and document the changes required. It is only a few lines in the code.

The hd44780 library is really superior to the LiquidCrystal counterparts. It is faster and it is actively maintained. And the author (Bill Perry) is available for questions.

Ok...thanks....found this one that seems to work with existing code .

Cheers...

https://github.com/johnrickman/LiquidCrystal_I2C

groundFungus.....really like the idea of your suggestion for the hd44780 ...
code I used in this latest attempt is below., thankyou...

[code]
/* Birthday Clock uses DS1307 RTC ....maybe replace later with DS3231 for better time keeping but seems ok for now
    Arduino pro mini with LEDs on pin 8 and the scan switch on pin 9
    I2C to 16 x 2 LCD display and to the rtc
    Can add extra birthdays if required in the "People birthdays[]" ..order is their name then the day then month of their birthday
    In the "scan" there probably is a better way to look and the month number in People birthdays[] but I used simple "if"
    So the program runs the "clock" showing current date on the top line and time on the bottom line
    When a birthday comes up, it switches over to print "Happy Birthday" top line and their name on the second line
    The LEDs flash at the beginning and end of this section and then goes back to the clock display for approx 8 seconds.
    If the "scan" button " is pressed and held for a few seconds, the display will run through all the names and their day and month of their birthdate.
    commented out serial prints were used during testing
    rtc adjust can be un-commented for adjusting the time etc. either manually as I did for Thailand or automatically for your local time via PC
    So uncomment whichever, adjust and upload, then comment out and reload again (with a battery in the rtc naturally)

   
*/

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "RTClib.h"
RTC_DS1307 rtc;
LiquidCrystal_I2C lcd(0x27, 16, 2);
byte scanButton = 9;
byte buttonState;
byte ledPin = 8;
byte testButton = 7;
byte tbState;
//int ledState = 0;
const long interval (200);



char daysOfTheWeek[7][12] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

char monthOfYear [13][4] = {" ", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEPT", "OCT", "NOV", "DEC"};


struct People {        // set up the struct
  char name[10];
  byte day;
  byte month;
};

const People birthdays[] = {
  {"OPO", 21, 9},      // my people name, day and month of birthday
  {"MUM", 14, 4},
  {"NAD", 20, 1},
  {"TON", 1, 6},
  {"TOOSAFE", 12, 5},
  {"JACKPOT", 7, 3},
  {"SAWITA", 3, 6},
  {"JEFF", 25, 2}

};




void setup ()
{
  Serial.begin(9600);             // for serial monitor
  pinMode(scanButton, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);
  pinMode(testButton, INPUT_PULLUP);

  lcd.init ();                  // initialize the lcd
  //lcd.begin();
  lcd.backlight();              // to power ON the back light
  if (! rtc.begin())            // real time clock check
  {
    lcd.print("Couldn't find RTC");
    while (1);
  }
  if (! rtc.isrunning())
  {
    lcd.print("RTC is NOT running!");
  }
  //rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));//auto update from computer time
  //rtc.adjust(DateTime(2022, 6, 7, 13, 23, 0));// to set the time manually

  digitalWrite(ledPin, LOW);   // make sure led is off to begin with
}




void loop() {
  buttonState = digitalRead(scanButton); // check if scan button changed
  if (buttonState == LOW) {
    scanBirthdays();
  }

  tbState = digitalRead(testButton);    //check if test button has been pressed
  if (tbState == LOW) {
    testButtonCode();
  }

  DateTime now = rtc.now();      // check rtc

  // Serial.print("The year now is  ");
  // Serial.println(now.year());
  // Serial.print("The month now is  ");
  // Serial.println(now.month());
  // Serial.print("The day now is "  );
  // Serial.println(now.day());

  for (uint8_t x = 0; x < sizeof (birthdays) / sizeof(birthdays[0]); x++) {  // loop through list ....const People birthdays
    //Serial.print ("Checking ");
    //Serial.println(birthdays[x].name);


    if ( birthdays[x].month == now.month() &&
         birthdays[x].day == now.day()) {   // see if any birthdays match todays day and month
      for (int j = 0; j < 10; j++) {
        digitalWrite(ledPin, HIGH);        // flash LED 10 times
        delay(interval);
        digitalWrite(ledPin, LOW);
        delay(interval);
      }
      //Serial.print("Happy Birthday ");
      //Serial.println(birthdays[x].name);
      lcd.setCursor(0, 0);                        //if they do then show on the LCD display
      lcd.print(" HAPPY BIRTHDAY ");
      lcd.setCursor(0, 1);
      lcd.print("                ");
      lcd.setCursor(6, 1);
      lcd.print(birthdays[x].name);
      lcd.print("    ");
      for (int i = 0; i < 10; i++) {     //flash LED 10 times again
        digitalWrite(ledPin, HIGH);
        delay(interval);
        digitalWrite(ledPin, LOW);
        delay(interval);
      }



    }

    else {
      Clock();                                      // jump to display clock
    }                                             // placing clock here gives 8 second clock display
    // if above for loop operates
  }
}

//*************************************end of loop**************************************************
void Clock() {
  // print bottom line on 16 x 2 display
  DateTime now = rtc.now();                // check time on real time clock
  lcd.setCursor(1, 1);                     // display on LCD
  lcd.print("TIME");
  lcd.print(" ");

  if (now.hour() < 10) {
    lcd.print("0");
  }
  lcd.print(now.hour());
  lcd.print(':');
  if (now.minute() < 10) {                 // "0" leading if less than 10
    lcd.print("0");
  }
  lcd.print(now.minute());
  lcd.print(':');
  if (now.second() < 10) {
    lcd.print("0");
  }
  lcd.print(now.second());
  lcd.print("  ");

  //print top line on 16 x 2 display
  lcd.setCursor(0, 0);
  lcd.print(" ");
  lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
  lcd.print("  ");
  lcd.print(now.day());
  lcd.print('/');
  lcd.print(now.month());
  lcd.print('/');
  int thaiYear = now.year() + 543;         // Thai year = +543 years
  lcd.print(thaiYear);
  lcd.print("  ");
  delay(1000);
}

//*******************************end of "clock"******************************************************

void scanBirthdays() {
  for (uint8_t x = 0; x < sizeof (birthdays) / sizeof(birthdays[0]); x++) {

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(birthdays[x].name); //scan the struct and look for names
    lcd.print(" BIRTHDAY");
    lcd.setCursor(0, 1);
    lcd.print(" ");
    lcd.print(birthdays[x].day);  //select the one that co-incides with the number through the for loop
    lcd.print(" of ");

    int monthValue = birthdays[x].month;

    switch (monthValue) {
      case 1:
        lcd.print("JANUARY");
        break;
      case 2:
        lcd.print("FEBRUARY");
        break;
      case 3:
        lcd.print("March   ");
        break;
      case 4:
        lcd.print("April   ");
        break;
      case 5:
        lcd.print("MAY     ");
        break;
      case 6:
        lcd.print("JUNE     ");
        break;
      case 7:
        lcd.print("JULY     ");
        break;
      case 8:
        lcd.print("AUGUST   ");
        break;
      case 9:
        lcd.print("SEPTEMBER");
        break;
      case 10:
        lcd.print("OCTOBER  ");
        break;
      case 11:
        lcd.print("NOVEMBER ");
        break;
      case 12:
        lcd.print("DECEMBER");
        break;
      default:
        lcd.print("ERROR   ");
        break;

    }
    delay(4000);
  }
}



void testButtonCode() {
  lcd.print("    HAPPY       ");
  lcd.setCursor (0, 1);
  lcd.print(" BIRTHDAY TEST  ");

  for (int i = 0; i < 20; i++) {     //flash LED 20 times
    digitalWrite(ledPin, HIGH);
    delay(interval);
    digitalWrite(ledPin, LOW);
    delay(interval);
  }

}

//************************************program end***********************************************
[/code]

Edit:.....Downloaded the library you referred to and looked at the "Hello World" example and, as you say, just needs a few line changes and additions...seems simple enough....Cheers

Here is the code with the changes (marked with ************ ). Untested cause I don't have the hardware handy. Compiles with one warning, unrelated to the library change, that you might want to fix.

warning: initializer-string for array of chars is too long [-fpermissive]
char monthOfYear [13][4] = {" ", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEPT", "OCT", "NOV", "DEC"};

All that is changed is the #includes, the constructor, added the LCD geometry and the changed the begin function.

/* Birthday Clock uses DS1307 RTC ....maybe replace later with DS3231 for better time keeping but seems ok for now
    Arduino pro mini with LEDs on pin 8 and the scan switch on pin 9
    I2C to 16 x 2 LCD display and to the rtc
    Can add extra birthdays if required in the "People birthdays[]" ..order is their name then the day then month of their birthday
    In the "scan" there probably is a better way to look and the month number in People birthdays[] but I used simple "if"
    So the program runs the "clock" showing current date on the top line and time on the bottom line
    When a birthday comes up, it switches over to print "Happy Birthday" top line and their name on the second line
    The LEDs flash at the beginning and end of this section and then goes back to the clock display for approx 8 seconds.
    If the "scan" button " is pressed and held for a few seconds, the display will run through all the names and their day and month of their birthdate.
    commented out serial prints were used during testing
    rtc adjust can be un-commented for adjusting the time etc. either manually as I did for Thailand or automatically for your local time via PC
    So uncomment whichever, adjust and upload, then comment out and reload again (with a battery in the rtc naturally)
*/

#include <Wire.h>
// ************ #include <LiquidCrystal_I2C.h>
#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
#include "RTClib.h"

RTC_DS1307 rtc;
// ************ LiquidCrystal_I2C lcd(0x27, 16, 2);
hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip

//  ************ LCD geometry
const int LCD_COLS = 16;
const int LCD_ROWS = 2;

byte scanButton = 9;
byte buttonState;
byte ledPin = 8;
byte testButton = 7;
byte tbState;
//int ledState = 0;
const long interval (200);

char daysOfTheWeek[7][12] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

char monthOfYear [13][4] = {" ", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEPT", "OCT", "NOV", "DEC"};

struct People          // set up the struct
{
   char name[10];
   byte day;
   byte month;
};

const People birthdays[] =
{
   {"OPO", 21, 9},      // my people name, day and month of birthday
   {"MUM", 14, 4},
   {"NAD", 20, 1},
   {"TON", 1, 6},
   {"TOOSAFE", 12, 5},
   {"JACKPOT", 7, 3},
   {"SAWITA", 3, 6},
   {"JEFF", 25, 2}
};

void setup ()
{
   Serial.begin(9600);             // for serial monitor
   pinMode(scanButton, INPUT_PULLUP);
   pinMode(ledPin, OUTPUT);
   pinMode(testButton, INPUT_PULLUP);

   // ************ lcd.init ();                  // initialize the lcd
   lcd.begin(LCD_COLS, LCD_ROWS);
   //lcd.begin();
   lcd.backlight();              // to power ON the back light
   if (! rtc.begin())            // real time clock check
   {
      lcd.print("Couldn't find RTC");
      while (1);
   }
   if (! rtc.isrunning())
   {
      lcd.print("RTC is NOT running!");
   }
   //rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));//auto update from computer time
   //rtc.adjust(DateTime(2022, 6, 7, 13, 23, 0));// to set the time manually

   digitalWrite(ledPin, LOW);   // make sure led is off to begin with
}

void loop()
{
   buttonState = digitalRead(scanButton); // check if scan button changed
   if (buttonState == LOW)
   {
      scanBirthdays();
   }

   tbState = digitalRead(testButton);    //check if test button has been pressed
   if (tbState == LOW)
   {
      testButtonCode();
   }

   DateTime now = rtc.now();      // check rtc

   // Serial.print("The year now is  ");
   // Serial.println(now.year());
   // Serial.print("The month now is  ");
   // Serial.println(now.month());
   // Serial.print("The day now is "  );
   // Serial.println(now.day());

   for (uint8_t x = 0; x < sizeof (birthdays) / sizeof(birthdays[0]); x++)    // loop through list ....const People birthdays
   {
      //Serial.print ("Checking ");
      //Serial.println(birthdays[x].name);

      if ( birthdays[x].month == now.month() &&
            birthdays[x].day == now.day())     // see if any birthdays match todays day and month
      {
         for (int j = 0; j < 10; j++)
         {
            digitalWrite(ledPin, HIGH);        // flash LED 10 times
            delay(interval);
            digitalWrite(ledPin, LOW);
            delay(interval);
         }
         //Serial.print("Happy Birthday ");
         //Serial.println(birthdays[x].name);
         lcd.setCursor(0, 0);                        //if they do then show on the LCD display
         lcd.print(" HAPPY BIRTHDAY ");
         lcd.setCursor(0, 1);
         lcd.print("                ");
         lcd.setCursor(6, 1);
         lcd.print(birthdays[x].name);
         lcd.print("    ");
         for (int i = 0; i < 10; i++)       //flash LED 10 times again
         {
            digitalWrite(ledPin, HIGH);
            delay(interval);
            digitalWrite(ledPin, LOW);
            delay(interval);
         }
      }

      else
      {
         Clock();                                      // jump to display clock
      }                                             // placing clock here gives 8 second clock display
      // if above for loop operates
   }
}

//*************************************end of loop**************************************************
void Clock()
{
   // print bottom line on 16 x 2 display
   DateTime now = rtc.now();                // check time on real time clock
   lcd.setCursor(1, 1);                     // display on LCD
   lcd.print("TIME");
   lcd.print(" ");

   if (now.hour() < 10)
   {
      lcd.print("0");
   }
   lcd.print(now.hour());
   lcd.print(':');
   if (now.minute() < 10)                   // "0" leading if less than 10
   {
      lcd.print("0");
   }
   lcd.print(now.minute());
   lcd.print(':');
   if (now.second() < 10)
   {
      lcd.print("0");
   }
   lcd.print(now.second());
   lcd.print("  ");

   //print top line on 16 x 2 display
   lcd.setCursor(0, 0);
   lcd.print(" ");
   lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
   lcd.print("  ");
   lcd.print(now.day());
   lcd.print('/');
   lcd.print(now.month());
   lcd.print('/');
   int thaiYear = now.year() + 543;         // Thai year = +543 years
   lcd.print(thaiYear);
   lcd.print("  ");
   delay(1000);
}

//*******************************end of "clock"******************************************************

void scanBirthdays()
{
   for (uint8_t x = 0; x < sizeof (birthdays) / sizeof(birthdays[0]); x++)
   {

      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print(birthdays[x].name); //scan the struct and look for names
      lcd.print(" BIRTHDAY");
      lcd.setCursor(0, 1);
      lcd.print(" ");
      lcd.print(birthdays[x].day);  //select the one that co-incides with the number through the for loop
      lcd.print(" of ");

      int monthValue = birthdays[x].month;

      switch (monthValue)
      {
         case 1:
            lcd.print("JANUARY");
            break;
         case 2:
            lcd.print("FEBRUARY");
            break;
         case 3:
            lcd.print("March   ");
            break;
         case 4:
            lcd.print("April   ");
            break;
         case 5:
            lcd.print("MAY     ");
            break;
         case 6:
            lcd.print("JUNE     ");
            break;
         case 7:
            lcd.print("JULY     ");
            break;
         case 8:
            lcd.print("AUGUST   ");
            break;
         case 9:
            lcd.print("SEPTEMBER");
            break;
         case 10:
            lcd.print("OCTOBER  ");
            break;
         case 11:
            lcd.print("NOVEMBER ");
            break;
         case 12:
            lcd.print("DECEMBER");
            break;
         default:
            lcd.print("ERROR   ");
            break;
      }
      delay(4000);
   }
}

void testButtonCode()
{
   lcd.print("    HAPPY       ");
   lcd.setCursor (0, 1);
   lcd.print(" BIRTHDAY TEST  ");

   for (int i = 0; i < 20; i++)       //flash LED 20 times
   {
      digitalWrite(ledPin, HIGH);
      delay(interval);
      digitalWrite(ledPin, LOW);
      delay(interval);
   }
}

//************************************program end***********************************************

You do have warnings enabled in the IDE, don't you? File, Preferences, Compiler Warnings check box to All.

image

My OCD would not let that warning go.

The source of the warning:

char monthOfYear [13] [4]
"SEPT" // is 5 characters.

char daysOfTheWeek[7][12] 
char monthOfYear [13] [4]

I would make those arrays const to move them from SRAM.

const char daysOfTheWeek[7][12]
const char monthOfYear [13] [4]

Suggested mods to existing reported errors done, changed the setting in the IDE, yet to add the library and changes for the LCD. All good...Thanks

Little things that catch one out........ "Sept" ....DOHHH!!!...missed it.
Like you said with Compiler warnings turned on initially I would have probably seen it.
Sh*** happens when a PC drive goes down and one has to reload everything....Cheers

That has happened to me a couple of times so I do try to keep my backups current.

If there is a good side to having to reload everything it is that the accumulated Windows garbage that slows things down is gone.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.