NodeMCU 1.0 and I2C

I’ve been trying to get my lcd screen working with nodemcu with no luck. The library seems to partially work. I am able to turn the display on and off using display() and noDisplay(), but nothing gets output on the lcd. I have the lcd wired to 5V instead of 3.3V like most tutorials show. When I run the scan program, i get the address as 0x27.

I noticed the warning below at the end of the compilation, right before the upload is started
“WARNING: library LiquidCrystal_I2C-master claims to run on (avr) architecture(s) and may be incompatible with your current board which runs on (esp8266) architecture(s).”

I also noticed that for the compilation to succeed, I have to disable the external power supply and rely only on the micro usb connector. Once the code is uploaded, then i can connect the 3.3v/5v power supply to get full brightness on the screen. Changing the brightness is not showing anything.

My I2C is IIC I2C TWI SP​​I Serial Interface Board Module Port For Arduino 1602LCD
The setup is pretty much similar to what is in this link except for the screen size and address

SCL → D1
SDA → D2

any ideas?

/*
14CORE NodeMCU i2C 16x2 LCD SCREEN
Test COde.........................
*/

#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(0x27, 16, 2);

void setup()
{
  lcd.init();   // initializing the LCD
  lcd.backlight(); // Enable or Turn On the backlight 
  lcd.setCursor(0, 1);
  lcd.print("14CORE | 16x2 LCD TEST"); // Start Print text to Line 1
  lcd.setCursor(0, 2);      
  lcd.print("-----------------------"); // Start Print Test to Line 2
}

void loop()
{
  // Nothing Absolutely Nothing!
}

Try including the following line in the sketch:
Wire.begin(4, 5); //GPIO4 = D2 = SDA; GPIO5 = SCL = SCL

You have 2-line LCD. Why is the command lcd.setCursor(0, 2);? It is referring to 3rd line from top.

Anyway, I tried your sketch in my NodeMCU 1.0(ESP-12E); the same warning message was there; but, the sketch got uploaded, and it workked. LCD’s Vcc is at separate 5V with common GND.

Please, reload the following sketch (this is your sketch with slight modification/correction). It works with my setup.

/*
14CORE NodeMCU i2C 16x2 LCD SCREEN
Test COde.........................
*/

#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(0x27, 16, 2);

void setup()
{
  Wire.begin(4, 5); //
  lcd.init();   // initializing the LCD
  lcd.backlight(); // Enable or Turn On the backlight 
  lcd.setCursor(0, 0);  //DP0 of Topline
  lcd.print("14CORE | 16x2 LCD TEST"); // Start Print text to Line 1
  lcd.setCursor(0, 1);   //DP0 of bottom line     
  lcd.print("-----------------------"); // Start Print Test to Line 2
}

void loop()
{
  // Nothing Absolutely Nothing!
}

Thanks. For some reason it is still not working. Are you sure of that Wire.begin(4, 5) ? Could you think of some other reason why it is not working?

sed003:
Thanks. For some reason it is still not working. Are you sure of that Wire.begin(4, 5) ? Could you think of some other reason why it is not working?

I have used the following variant of ESP8266 where D2 and D1 correspond to GPIO4 and GPIO5 respectively.

That's the one I have. Where did you get the I2C library? I had to go through different ones until I found the one I am using now.

sed003:
That’s the one I have. Where did you get the I2C library? I had to go through different ones until I found the one I am using now.

This is the standard Wire.h library that is automatically installed with the IDE. You might have problem with the LiquidCrystal_I2C.h Library; there are so many variants of the library with the same name. I use this one.

LiquidCrystal_I2c.zip (19.9 KB)

Awesome. That one worked. Can I ask where you got it from? I believe even when i search from the ide there are a lot of results that come up.

sed003:
Awesome. That one worked. Can I ask where you got it from? I believe even when i search from the ide there are a lot of results that come up.

I got it from the net when I started working for the first time on I2C LCD about one-and-half years ago.

I have a strange issue. I put the code in a larger program, basically the circuit has a DHT22, PIR motion detector and a photo resistor. The I2C, DHT22 and PIR are plugged in the 5V section of the power supply, the nodemcu and photo resistor are plugged in the 3.3V. I verified that the commons are connected (through the power supply itself)

When i compile and it is time to upload, i get the message below (when the external power source is connected):
WARNING: library LiquidCrystal_I2c claims to run on (avr) architecture(s) and may be incompatible with your current board which runs on (esp8266) architecture(s).
Sketch uses 277472 bytes (26%) of program storage space. Maximum is 1044464 bytes.
Global variables use 30248 bytes (36%) of dynamic memory, leaving 51672 bytes for local variables. Maximum is 81920 bytes.
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

The warning we know is ok, but the rest is not. The only way to upload, is to disconnect the 12V adapter from the power supply. After that I am able to run the test code that was mentioned in the previous postings.

If I try to add more code (event to clear the screen and type something new) the screen will not necessarily show anything. It will either be blank or show garbled characters.

When I put my other code (the one for my project), same thing i do not necessarily get an output. To make matters worse, my code doesn’t run at all. Once i disconnect the PS, then the code starts to run. Connecting the I2C to 3.3V doesn’t work either (only the rest of the code works, but not the I2C)
I wish there was an easy way for me to upload the image of the circuit.

sed003:
I have a strange issue. I put the code in a larger program, basically the circuit has a DHT22, PIR motion detector and a photo resistor. The I2C, DHT22 and PIR are plugged in the 5V section of the power supply, the nodemcu and photo resistor are plugged in the 3.3V. I verified that the commons are connected (through the power supply itself)

When i compile and it is time to upload, i get the message below (when the external power source is connected):
WARNING: library LiquidCrystal_I2c claims to run on (avr) architecture(s) and may be incompatible with your current board which runs on (esp8266) architecture(s).
Sketch uses 277472 bytes (26%) of program storage space. Maximum is 1044464 bytes.
Global variables use 30248 bytes (36%) of dynamic memory, leaving 51672 bytes for local variables. Maximum is 81920 bytes.
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

The warning we know is ok, but the rest is not. The only way to upload, is to disconnect the 12V adapter from the power supply. After that I am able to run the test code that was mentioned in the previous postings.

If I try to add more code (event to clear the screen and type something new) the screen will not necessarily show anything. It will either be blank or show garbled characters.

When I put my other code (the one for my project), same thing i do not necessarily get an output. To make matters worse, my code doesn’t run at all. Once i disconnect the PS, then the code starts to run. Connecting the I2C to 3.3V doesn’t work either (only the rest of the code works, but not the I2C)
I wish there was an easy way for me to upload the image of the circuit.

i try the above code and library, display nothing after upload complete. i only have the i2c connect to vin nodemcu 1.0. please reply if you have solve your problem.