'int LiquidCrystal_I2C::init()' is private within this context

Error:
exit status 1
'int LiquidCrystal_I2C::init()' is private within this context

Code here:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "DHT_NEW.h"
DHT _dht1;
LiquidCrystal_I2C _lcd1(0x27, 16, 2);
int _dispTempLength1=0;
boolean _isNeedClearDisp1;
LiquidCrystal_I2C _lcd2(0x27, 16, 2);
int _dispTempLength2=0;
boolean _isNeedClearDisp2;
unsigned long _dht1LRT = 0UL;
unsigned long _dht1Tti = 0UL;
int _disp1oldLength = 0;
int _disp2oldLength = 0;

void setup()
{
    Wire.begin();
    delay(10);
    _lcd2.init();
    _lcd2.backlight();
    _lcd1.init();
    _lcd1.backlight();
    _dht1.setup(4);
    _dht1LRT = millis();
    _dht1Tti = millis();
}
void loop()
{
    if (_isNeedClearDisp2) 
    {
        _lcd2.clear();
        _isNeedClearDisp2= 0;
    }
    if (_isNeedClearDisp1) 
    {
        _lcd1.clear();
        _isNeedClearDisp1= 0;
    }
    //Плата:1
    if(_isTimer(_dht1Tti, 500.0)) 
    {
        if(_isTimer(_dht1LRT,(_dht1.getMinimumSamplingPeriod()))) 
        {
            _dht1.readSensor();
            _dht1LRT = millis();
            _dht1Tti = millis();
        }
    }
    if (!(0)) 
    {
        _dispTempLength2 = ((((String("h:")) + ((_floatToStringWitRaz(_dht1.humidity,2)))))).length();
        if (_disp2oldLength > _dispTempLength2) 
        {
            _isNeedClearDisp2 = 1;
        }
        _disp2oldLength = _dispTempLength2;
        _lcd2.setCursor(int((16 - _dispTempLength2)/2), 1);
        _lcd2.print((((String("h:")) + ((_floatToStringWitRaz(_dht1.humidity,2))))));
    }
     else 
    {
        if (_disp2oldLength > 0) 
        {
            _isNeedClearDisp2 = 1;
            _disp2oldLength = 0;
        }
    }
    if (!(0)) 
    {
        _dispTempLength1 = ((((String("t:")) + ((_floatToStringWitRaz(_dht1.temperature,2)))))).length();
        if (_disp1oldLength > _dispTempLength1) 
        {
            _isNeedClearDisp1 = 1;
        }
        _disp1oldLength = _dispTempLength1;
        _lcd1.setCursor(int((16 - _dispTempLength1)/2), 0);
        _lcd1.print((((String("t:")) + ((_floatToStringWitRaz(_dht1.temperature,2))))));
    }
     else 
    {
        if (_disp1oldLength > 0) 
        {
            _isNeedClearDisp1 = 1;
            _disp1oldLength = 0;
        }
    }
}
String  _floatToStringWitRaz(float value, int raz)
{
    return String(value,raz);
}
bool _isTimer(unsigned long startTime, unsigned long period)
{
    unsigned long currentTime;
    currentTime = millis();
    if (currentTime>= startTime) 
    {
        return (currentTime>=(startTime + period));
    }
     else 
    {
        return (currentTime >=(4294967295-startTime+period));
    }
}

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

Which LiquidCrystal_I2C library did you install?

I don't think you can use two I2C displays with the same I2C address. I think you will need to figure out how to change the address on one of your displays.

1 Like

How does having 2 LCDs with the same address work? Many backpacks have solderable jumper pads to change the address.

Are you sure that the code that you have uses the LiquidCrystal_I2C library that you have installed? There are several libraries with the name LiquidCrystal_I2C. The are not all the same and code from 1 may not run in another. Those LiquidCrystal_I2C libraries are old and most are not maintained. The newest and best library for I2C LCD with the hd44780 controller (1602, 2004) is the hd44780 library by Bill Perry. The library is available via the IDE library manager.

For an I2C LCD display to work, the I2C address and the I2C backpack to LCD pin mapping must be correct. If the library default settings for either or both are not correct the LCD will not work. You can try to figure out the right pin mapping and use an I2C scanner to find the address, but if you install and use the hd44780 library that is done automatically by the library.

1 Like

What the mess...

Are you know about unsigned arithmetic?
Why not do it like this:

bool _isTimer(unsigned long startTime, unsigned long period)
{
    unsigned long currentTime  = millis();
    return (currentTime - startTime > period);
 } 
1 Like

Yes this is a very important question.
As there are several and they work differently.

The LiquidCrystal_I2C library in the IDE manager has an init() function.

The fmalpartida newLiquidCrystal LiquidCrystal_I2C i/o class uses begin() instead of init. While it has an init() function, it is a private function for the library and not to be called by sketch code.
The error cited is consistent with installing this library.

--- bill

1 Like

Thanks everyone for your reply, but I just reinstalled the library and everything worked fine.

Thanks for your reply, but this was a quickly written sample code for the forum.

I strongly suspect that you have now installed a different library

1 Like

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