Tried downloading I2C library, does not work

Hello, I have recently downloaded a library regarding the I2C bus as shown in Using LCD Displays with Arduino - YouTube, 27.10 . This library does not work, I then tried to go to manage libraries and download the I2C library in the arduino online editor, it did not work. What library should I use and how come I continually get an error message// no matching function for call to 'LiquidCrystal_I2C::LiquidCrystal_I2C(const int&, ... const int&)' //. for the code LiquidCrystal_I2C lcd(i2c_addr, en, rw, d4, d5, d6, d7, bl, POSITIVE); // ? (For the Liquid Crystal Display.

Not very describing.....

I use a very good library for I2C displays.
#include <Wire.h> #include <hd44780.h> #include <hd44780ioClass/hd44780_I2Cexp.h> Look at mylcd in the code below. Skip the other junc.

//boolean debug = false;

#include <SoftwareSerial.h>
#include <TinyGPS++.h>

#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>

//#define BACKLIGHT_PIN     13

hd44780_I2Cexp mylcd; // declare lcd object: auto locate & config exapander chip

// LCD geometry
#define LCD_COLS 20
#define LCD_ROWS 4

// The TinyGPS++ object
TinyGPSPlus gps;
TinyGPSCustom vdop(gps, "GPGSA", 17);//Pick upVdop

//Create GPS channel using digital i/o
#define RX 2
#define TX 3
SoftwareSerial mySerial(RX, TX);  // pick any 2 unused digital pins (not pins 0 or 1)

#define arr_size 20

int time_adj; // adjust: +1 for winter time, +2 for summer time
int act_cnt = 0;
char activity[] = "<><>";
unsigned long next_act_print, Start_Up_Time = millis();
//unsigned int speed_age, hdop_age, alt_age, dir_age, sat_age;
unsigned long speed_age, hdop_age, vdop_age, alt_age, dir_age, sat_age;

unsigned long speed_print, dir_print, alt_print, time_print, date_print, sat_print, hdop_print = 0L;
unsigned long vdop_print, next_menue_print, avg_print = 0L;
unsigned long speed_warning_end, alt_warning_end;
int last_alt, last_speed, last_dir, prev_speed;
unsigned long avg_alt, avg_ant;
boolean average_alt_inc_flag;
int avg_arr[arr_size + 1], inp_index;
long unsigned avg_sum;

  boolean ok_test(int, int, int, int);

  boolean ok_test(int(a), int(b), int(val), int(norm))
  if (norm == 0) norm = val;
  return ( (val >= ((norm * a) / 100)) && (norm <= ((val * b) / 100) ) );
boolean lim_test(int, int, int, int);

boolean lim_test(int(a), int(val), int(norm))
  if (norm == 0) norm = val;
  return (abs(val - norm) <= a );

void setup()
  int status;

  status = mylcd.begin(LCD_COLS, LCD_ROWS);
  if (status) // non zero status means it was unsuccesful
    status = -status; // convert negative status value to positive number

    // begin() failed so blink error code using the onboard LED if possible
    hd44780::fatalError(status); // does not return
  // initalization was successful, the backlight should be on now

  mySerial.begin(9600);  // 9600 is the default baud rate for my Neo6m units
  Serial.begin(115200);// For PC, serial monitor

  // Print start message to the LCD
  mylcd.setCursor(0, 1);
  mylcd.print("Ver. 20210919a");
  // Print start message to the PC
  Serial.println("Starting up");//sent to PC
  Serial.println("Ver. 20210919a");

  //initialize age and print flags
  next_act_print, Start_Up_Time, avg_print = millis();
  speed_age, hdop_age, alt_age, dir_age, sat_age = 999;
  speed_print, dir_print, alt_print, time_print, date_print, sat_print, hdop_print, vdop_print = millis();

  last_alt, last_speed, prev_speed, last_dir = -1;
  average_alt_inc_flag = false;
  avg_alt = 0L;
  avg_ant = 0;
  for ( inp_index = 0; inp_index < arr_size; inp_index++)
    avg_arr[inp_index] = 0;
  inp_index = 0;
  avg_sum = 0L;
  //  time_adj = 2;// Will be set for winter or summer time, +1 for winter time, +2 for summer time, april t o m october

Chances are good that library has worked for countless others before you.

I'm not familiar with that library and I believe @Railroader suggested some includes that might help.

However, whenever you start a project with a new I2C device, the first thing you should load and run is the I2C scanner. can be found here.

You also need to post your display and how you have it connected to the arduino. Your code:

LiquidCrystal_I2C lcd(i2c_addr, en, rw, d4, d5, d6, d7, bl, POSITIVE);

seems to have a lot more connections than a simple I2C.

1 Like

Thank you. I am just as of right now working with just the LCD

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup()
lcd.init(); // initialize the lcd

lcd.setCursor(0, 0);
lcd.setCursor(2, 1);

(BTW, I do not know much about LCDs, thank you for your help if you reply past this message)

Unfortunately there are several libraries for the LCD that have similar (or identical) names, but are slightly different. Your error is caused by either the wrong library, or a change in the correct library since the video was made.

The best current library for I2C liquid crystal displays is the hd44780 library by Bill Perry, which is what is used in the code in reply #1. It can be downloaded using the library manager in the IDE. Run the example code under File > Examples > hd44780 > ioClass > hd44780_I2Cexp > I2CexpDiag to verify you have everything hooked up proper.

1 Like

I've seen a library that has that type constructor, that particular library lets you specify the pin mapping between the I2C expander board and the LCD display, with the POSITIVE being the polarity of the backlight pin if I recall correctly.

Thank you. I will try the hd44780 libra. ry and get back to you

By the way, for these two libraries : #include <hd44780.h> #include <hd44780ioClass/hd44780_I2Cexp.h> : how am I supposed to add them in my programming? Like, what commands can I use with this?

Look in the snippet, the entire beginning, of the posted code and see how it is done there.

That is the pin mapping of the PCF8574 I2C expander pins to the LCD pins. There are several different mappings used by different I2C backpacks on the market. That is one of the big advantages of Bill Perry's (@bperrybap) hd44780 library, it automatically detects the pin mapping as well as auto detects the I2C address.