Member lcd.init not found error

code

#include "ESP8266WiFi.h"
#include <Wire.h> // This library is already built in to the Arduino IDE
#include <LiquidCrystal_I2C.h> //This library you can add via Include Library > Manage Library >

LiquidCrystal_I2C lcd(0x38, 16, 2);

void setup()
{
Serial.begin(9600);
WiFi.mode(WIFI_STA);
WiFi.disconnect();
// lcd.init(); // initializing the LCD
lcd.backlight(); // Enable or Turn On the backlight
lcd.print("Please Wait!");
if (Serial.available()) {
// Wait a bit for the entire message to arrive
delay(100);
// Clear the screen
lcd.clear();

// Write all characters received with the serial port to the LCD.
while (Serial.available() > 0) {
lcd.write(Serial.read());
}
}
delay(1000);

}

void loop()
{
int n = WiFi.scanNetworks();
if (n == 0)
{

lcd.setCursor(0, 0);
lcd.print("no networks found"); // Start Print text to Line 1
lcd.setCursor(0, 1);
lcd.print("--------"); // Start Print Test to Line 2
}

else
{
lcd.setCursor(0, 0);
lcd.print(n);
lcd.setCursor(0, 1);
lcd.print(" networks found ");
delay(2000);
for (int i = 0; i < n; ++i)
{
// Print SSID and RSSI for each network found
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print(i + 1);
lcd.print(": ");
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(WiFi.SSID(i));
/*
Serial.print(" (");
Serial.print(WiFi.RSSI(i));
Serial.print(")");
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"");/
delay(2000);
}
}

// Wait a bit before scanning again
delay(5000);

}

error

if i dont remove the lcd.init line i get member init not found
if i comment out the line it compiles but nothing on screen or serial monitor, only garbeled letters and
chars on serial monitor, i need help, i2c esp 8266.

The example code you are showing here and the example code you showed here: SainSmart LCD1602 Module Display [how do i use this?] - #34 by multimedia - Displays - Arduino Forum
are different and are for different libraries.

While the "libraries" may have the same name, and provide a LiquidCrystal_I2C.h header file, different LiquidCrystal_I2C classes are initialized differently, have different functionality and have different API functions.

It appears that you may have installed multiple libraries with a LiquidCrystal_I2C.h header and LiquidCrystal_I2C class.

If you have done this, then things can get very strange since the IDE can end up picking up portions of both libraries or portions of more than one at different points during the compilation/link process.

I would recommend using my hd44780 library package instead.
It is available in the IDE library manager so it can quickly and easily be installed from the IDE gui using the library manager.
With other i2c LCD libraries you must specify the i2c address. Most libraries are also hard coded to work with backpacks that use a specific pin mapping between the PCF8574 and the hd44780 LCD display and if your backpack doesn't use that pin mapping, it won't work.
A few libraries allow the sketch to configure the PCF8574 pin mappings and backlight control.
If the pin mappings are not specified correctly, it will not work.
The hd44780 library can auto detect everything, the i2c address, the pin mappings, and the backlight control.
You can read more about it here: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library

The hd44780 github page contains information about the library including installation instructions.
Use the IDE library manager to install it as it is easier and faster than trying to do it manually or using the zip install.
Also, by using the IDE library manager it ensures that the library is installed properly not to mention that you will also get the latest tested version of the library.

The library package includes support for several different h/w i/o interfaces used to communicate with the LCD module.

Each i/o interface has its own i/o class and its own set of examples.
The examples for each i/o class are grouped together in a directory by the name of the i/o class.
While all the examples are always available regardless of which h/w you actually have, using an example for an i/o class that is for different h/w will not work.
It will compile but obviously will not work.
The i/o class you will want to use for a PCF8574 i2c backpack which contains an i2c i/o expander chip is hd44780_I2Cexp
That i/o class includes a diagnostic sketch (I2CexpDiag) which will test the i2c signals and internal RAM of the LCD module to verify that the the library is properly communicating with the LCD module.
It is useful to first run this sketch to verify that the library is properly talking to your backpack and LCD module.
Read the instructions in the sketch for how to run it and what to expect on the serial monitor.

After running the diagnostic sketch, you can run and look at other sketches for the hd44780_I2Cexp i/o class like the HelloWorld sketch to see what header files need to be included and how to declare the lcd object.

The hd44780 library contains additional capabilities not available in other libraries like

  • return status to tell if API functions are not working correctly (usually do to i2c communication issues)
  • ability to enable automatic line wrapping
  • ability to read the display RAM or LCD status
  • faster than other libraries as Arduino can run in parallel with LCD commands/instructions

I would recommend first running the diagnostic skech I2CexpDiag to verify that everything is working, then you can run and look at the other examples included in the hd44780_I2Cexp i/o class (like HelloWorld) to see the what header files need to be included and how to declare the lcd object.

--- bill

Also, many if not most of the i2c lcd libraries out there will not work with the ESP8266 modules because of the way they are handling delays during initalization.
So even if the code compiles, it may end up getting watchdog timeouts and not work.

The hd44780 package has been tested and works with ESP8266 modules.

--- bill

i have tried all kinds and having issues with any lib and sketch but ppl on YT are getting it to work they are sometimes sharing there links to libs and code and sometimes not but i have tried the code and had no luck, i just dont know what to do :confused: btw what is hd44780 and have you got a link? and all these libraries with same name is the most annoying thing ever, they all need there own version number or something it makes a confusing subject even more confusing!

and i know they are different i been trying everything so the code is going to be different on different examples! i cant try the same stuff expecting different results i am not crazy but this library nonsense is making me crazy :slight_smile:

Ok this is weird, i used the hd44780 library hello world i2c example uploaded it and it looked blank so i turned the contrast at the back and the previous wifi test script displayed even after reset button, no idea how that happened but seems it is working without the lcd.init line, i dont know why the hello world script didnt replace the old example though, i guess its half resolved, i will keep working onit and try and report back.

Got it working quite well now
thanks bill :slight_smile:

Video will be up at around 3pm youtu.be/6G1_loGBvCs

multimedia:
/ btw what is hd44780 and have you got a link? and all these libraries with same name is the most annoying thing ever, they all need there own version number or something it makes a confusing subject even more confusing!

When using embedded h/w and doing s/w at this level, it is important to slow down a bit and take time to read the information provided. I provided a link for more information about hd44780 in the post.

I do agree that many libraries having a LiquidCrystal_I2C.h and LiquidCrystal_I2C class is a real mess.
However, for better or worse, there is only one available in the Arduino IDE library manager.
So if you were using the one from the library manager as you comment says in your code, you would not be seeing multiple LiquidCrystal_I2C libraries.
But I would still recommend using hd44780 over any of the LiquidCrystal_I2C "libraries" as hd44780 has many benefits/features over them.

multimedia:
Ok this is weird, i used the hd44780 library hello world i2c example uploaded it and it looked blank so i turned the contrast at the back and the previous wifi test script displayed even after reset button, no idea how that happened but seems it is working without the lcd.init line, i dont know why the hello world script didnt replace the old example though, i guess its half resolved, i will keep working onit and try and report back.

But why did you not follow my recommendations for bringing up the library with your hardware?
You should have run the I2CexpDiag sketch first.

Keep in mind that a reset on the Arduino board (either from pressing it or from auto reset from doing an upload) does not reset the backpack or the LCD.
So if the hd44780 code initialized everything and then you run your example code using LiquidCrystal_I2C code it "might" work.
However, the sketch code you provided in the initial post will not work correctly since it does not make any API calls that would initialized the backpack and LCD. The LCD powers up in 8 bit mode and the initialization code puts the LCD into 4 bit mode to work with the PCF8574.
By not calling any initialization API function your sketch, the LCD will be in 8 bit mode after powering up and will not work.

When testing at this level, you must power cycle the board in order to make sure that the library code is able to properly initialize and communicate with the device.

I still highly recommend that you use the hd44780 library package and test your LCD device using the included diagnostic sketch.

multimedia:
Got it working quite well now

What is "it"?
Are you meaning the hd44780 library package with the hd44780_I2Cexp i/o class? or something else?

--- bill

I dont understand half of what you mean by api calls and diag thing, all i know is its working but when i try putting a gsm module the lcd cut out and i had to re upload a hello world script to get it working again, esp 8266 really needs 5v pin as i thing having 2 x 5v devices on 3v pins is not good for the esp and it corrupts the uploaded code somehow. its working again but i wanted to have access to lat and long from gsm to a stand alone esp AP :confused:

LCD screen + GSM? How are you powering the setup? The GPRS/GSM shields are power hungry and typically need a separate 2 amp supply.

oh so it maybe the usb 3 that is not got enough amps :slight_smile: that makes sense!

looking at the spec sheet it actually sais Power supply range: voltage is 4.6-5.2v; current is 1A or more (the current is very important).

multimedia:
I dont understand half of what you mean by api calls and diag thing, all i know is its working ...

Again what is IT ?

I think you may need to do some studying on C/C++ language and s/w and s/w development terminology in general.
It will likely make things easier moving forward.
More reading and less doing in some cases can be helpful.

About the diag sketch. Go back and have a read of post #1

I think I was pretty clear about the diag sketch in that post.
The hd44780 library package comes with a diagnostic sketch (I2CexpDiag) that will run tests to ensure that the library and h/w are properly working.

Also, when mixing 3v and 5v devices, you must be very careful how things are connected or you can damage things.
i.e. you can't hook up a 5v device output to a 3v only input device.
If you do, you can fry the 3v device.

That is why I have warnings about using using 3v modules such as the ESP & ARM based Arduino modules with 5v LCD backpacks in the sketch code.

Reading is your friend.
I suggest you spend some time reading about 3v and 5v interfacing and level shifters to educate yourself on the issues and to understand how to properly connect together these types of 3v and 5v devices.
It typically requires either using voltage level shifters or making modifications to the actual i2c backpack.

--- bill

it was the other way round, the device (lcd) is 5v input and is in the esp 3v output pin, i should put into the vcc (5v) pin but it didnt work so put back onto the 3v pin. and i like learning by doing, reading is not my strong point. i dont like c generally, i like things that are easy to remember like bash php not really python or c if i can help it, or i would definitely make my own libraries if i was into c :slight_smile: thanks for you're help though i appreciate it.

multimedia:
it was the other way round, the device (lcd) is 5v input and is in the esp 3v output pin, i should put into the vcc (5v) pin but it didnt work so put back onto the 3v pin. and i like learning by doing, reading is not my strong point. i dont like c generally, i like things that are easy to remember like bash php not really python or c if i can help it, or i would definitely make my own libraries if i was into c :slight_smile: thanks for you're help though i appreciate it.

It is not the other way around. The backpack and LCD is a 5v device and the ESP is a 3v device.
Both devices output AND input on the i2c signals as the i2c bus is bidirectional.
i2c is still bidirectional even if you are only writing to a device.
i.e. each end the master and the slave will look at the i2c SDA and SCL pins as well as drive them even if the master is only writing to the slave.

The ESP will output 3v and expect no higher than 3v, on SDA and SCL.
While the backpack and LCD can typically run at 3v, the LCD and in particular the backlight typically are going to want more than 3v.
So if the backpack VCC is 5v, you have the EXACT scenario I described in post #11 a 5v device outputting 5v signals into a 3v device.
Here is a link to the i2c wikipedia page: I²C - Wikipedia
It is definitely worth reading to get an overview of how i2c works, to get a basic understanding of some of the electrical issues involved.

Because of all this, you have to take precautions when hooking up 3v and 5v devices.

I understand that you may like to jump right in and do trial and error type "doing" and experimentation, but you need to slow down a bit and do some reading in advance.
Reading is very critical to gaining knowledge especially in technical fields like h/w and embedded s/w programming so you need to start forcing yourself to slow down a bit and read more.
If you continue to skip over the step of reading, then you are likely to run into issues like getting stuck or burning up h/w.

--- bill

I do understand what your saying but as i said it didnt work in 5v pin so put back onto 3 and it all seems to be more than fine running for hours now, if more current was in there it might be an issue which is why i wanted it to work on 5v pin but for some reason it didnt power up!

multimedia:
I do understand what your saying but as i said it didnt work in 5v pin so put back onto 3

You got very lucky.

Typically when a 5v signal is fed into a 3v part the 3v part is damaged.
That is what happened when you hooked 5v up to the backpack; the backpack pulled the SDA and SCL i2c signals up to 5v.

This is why just trying things is a bad idea; this is particularly case when dealing with components that use different voltages.

I would still recommend doing some reading about your parts and their interfaces to avoid such issues.

--- bill

I'm not going to repeat myself after this 1 last time, I am not lucky, the device wanted 5volts not 3, the 5 v pin on the esp for some reason didn't power the 5v device so it is in the 3v output pin, if anything it shouldn't power up or it maybe more dim than expected and the esp should struggle to power it, but 5v pin didn't power it 3 v pin did and its working its not as bright (the text) as expected the back-light is more than bright enough though, I hope this clears it up for you, unless of course you are saying it is supposed to run at 3v and no more and in which case as it did not power up with the 5v pin I can assume it has over volt protection and that maybe the reason it did not power up, when i read the vcc on the board i assumed that meant 5v but there isn't too much difference between the 2 in any case and was only plugged in for a second.

the screen came with an arduino kit that had no data sheets not even a model number to search google with and the board itself (i2c) would take any extra energy anyway so i wasn't too worried.

Yes you were lucky. You hooked things up incorrectly and luckily nothing got fried.
I understand the h/w you have and it was fairly clear to me how you hooked things up even prior to this recent post; however, I don't think that you understand it or at least you don't appreciate the issues involved with mixing 3v and 5v components.
The i2c backpack and LCD are 5v devices. They have no voltage protection in them, there is no need. The voltage protection would need to be on the 3v side to protect it from the 5v side.
While the i2c backpacks and LCDs typically will work at 3v they were intended to run at 5v.

The key to understand is that a 3v device can usually drive signals into a 5v device (the 3v high signals are out of spec for a 5v input but it typically will work) but when a 5v device drives a signal into a 3v device it can fry the 3v device if the 3v device does not have 5v tolerant inputs.

There is a HUGE difference between 5v and 3v especially if there is low resistance current path.
If a 3v only device is connected to a 5v device that is driving the signal at 5v then the 3v device will be fried.
1 second is a long time when dealing with mismatched voltages. Things can be fried in mere microseconds.
It doesn't even take a voltage difference between components to fry things.
For example, if one component is driving a signal high and is connected to another component that is also driving the same signal low, there is short and that will often fry the component on one end or the other.
The voltage of each component in this situation is irrelevant.
In reality it isn't the voltage or voltage differential that matters it is the current, but as you should know with ohms law, the bigger the voltage differential or the lower the resistance, the higher the current.

When playing with h/w at this level, you have to have a pretty good understanding of how the signals work to ensure the pins connected to the signals are driving them properly and that the two ends are compatible with each other from a voltage and current perspective.
Something as simple as a grounded signal to a microcontroller pin can fry the internal h/w for the pin if the microcontroller drives the pin high.

But hey, it is your stuff.
My preference is to go in with adequate knowledge to ensure that I don't do any damage to my components.
And to gain the needed knowledge requires reading.

--- bill

I did not, I checked the specs online and it sais 5v that what I did, put it into 5v nothing came up i put into 3v and it worked end of story! i don't see why you write an essay about it!

nothing has been fried and I am not lucky! all i did was follow instructions, you didn't ask what i2c board I was using or anything.

search for 1Pcs Iic I2c Serial Interface Board Module Lcd1602 Address Changeable New Ic X on ebay and see for yourself! i did everything that I could of.

This 5 mins delay is so annoying 2 mins max delay not 5 should be used for forum i make mistakes all the time and have to wait 5 mins when i have other things todo! furthermore the button i click is quick edit its not very quick if i have to wait 5 mins!

You are all over the map in your posts. In this thread you started off with example code that was for a library that is for driving a backpack based on a PCF8574 i2c i/o expander backpack that is connected to a hd44780 display.
And the sketch included headers and a code for a ESP8266 module.
Now you are talking about a OSOYOO Mega2560 + 3.2" TFT LCD Display + LCD Shield Expansion Board ???
WTF?

If you had a ESP module and hooked up the 4 pins from the i2c LCD backpack (VCC, GND, SDA, SCL) directly to the ESP module with VCC from the backpack going to 5v that is WRONG and you are lucky you didn't fry the ESP module.
(the specific backpack you have is irrelevant since this is a 3v vs 5v i2c issue)
You can't directly connect 3v and 5v i2c signals.

Trying things to see if they work, in this type of environment is risky.
In this case, yes, you got lucky. I'd have to look closely at your specific backkpack and ESP module but more than likely you got luckly that the pullups on your backpack were big enough that they reduced the current on the i2c signals enough that the SDA and SCL signals didn't fry the ESP module.

I'm done trying to explain things and give you information.

--- bill