ESP8266 nodeMCU

Hi!

I am trying to setup 2 LCDs, 1 by 1, with nodeMCU ESP8266, the first display is LCD1602 address 0x27, the scond is LCD 20x4 address 0x3F, all I get is a blank screen , its light, but no change.

Pinout: D1 to SCL, D2 to SDA, Vin to VCC, GND to GND

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows

byte customChar[8] = {
  0b00000,
  0b01010,
  0b11111,
  0b11111,
  0b01110,
  0b00100,
  0b00000,
  0b00000
};

void setup()
{
  lcd.init(); // Initialize the LCD I2C display
  lcd.backlight();

  lcd.createChar(0, customChar); // create a new custom character

  lcd.setCursor(2, 0); // move cursor to (2, 0)
  lcd.write((byte)0);  // print the custom char at (2, 0)
}

void loop()
{
}

Your code makes no mention of an LCD at address 0x3F. Is that intentional or have you posted the wrong sketch ?

I don't want to type the same code just to change the first line from 0x27 to 0x3F.

Sorry, I thought that you wanted to use 2 screens at once, hence my comment

What voltage do the screens run at, bearing in mind that the ESP8266 is a 3.3V device ?

The ESP is at 3.3V, the VIN pin is comming from the USB, therefore its 5V, I tried with both options, no difference. I think the initialization of the display fails as it does not display anything.

With this code I am able to get the backlight to work, but no success in output chars.
Specs: NodeMCU8266
IDE: Arduino 1.8.19
OS: Windows 7

/*
*	Hello_World.ino
*
*	Author: Frank Häfele
*	Date:	01.12.2023
*
*	Object: Print Hello World on LCD Display
*/

#include <LCD-I2C.h>


LCD_I2C lcd(0x27, 16, 2); // Default address of most PCF8574 modules, change according

void setup() {
    // If you are using more I2C devices using the Wire library use lcd.begin(false)
    // this stop the library(LCD-I2C) from calling Wire.begin()
    lcd.begin();
    lcd.display();
    lcd.backlight();
}

void loop()
{
    lcd.print("     Hello"); // You can make spaces using well... spaces
    lcd.setCursor(5, 1); // Or setting the cursor in the desired position.
    lcd.print("World!");
    lcd.write('T');
    delay(500);

    // Flashing the backlight
    for (int i = 0; i < 5; ++i)
    {
        lcd.backlight();
        lcd.backlight();
        lcd.write('T');

        delay(500);
        lcd.backlightOff();
        lcd.write('T');

        delay(500);
    }

    lcd.backlight();
    lcd.clear();
    delay(500);
}

This is the diag, why is there no I2C device found?

⸮⸮)Af⸮⸮⸮⸮⸮
********************************************************************
Serial Initialized
--------------------------------------------------------------------
I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool
--------------------------------------------------------------------
hd44780 lib version: 1.3.2
--------------------------------------------------------------------
Reported Arduino Revision: 1.8.19
Arduino Board: ESP8266_NODEMCU_ESP12E
CPU ARCH: ESP8266 - F_CPU: 80000000
--------------------------------⸮⸮⸮@0I!Ì⸮⸮⸮B⸮
********************************************************************
Serial Initialized
--------------------------------------------------------------------
I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool
--------------------------------------------------------------------
hd44780 lib version: 1.3.2
--------------------------------------------------------------------
Reported Arduino Revision: 1.8.19
Arduino Board: ESP8266_NODEMCU_ESP12E
CPU ARCH: ESP8266 - F_CPU: 80000000
--------------------------------------------------------------------
SDA digital pin: 4 (GPIO4)
SCL digital pin: 5 (GPIO5)
--------------------------------------------------------------------
Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - YES
Checking for I2C pins shorted together - Not Shorted
--------------------------------------------------------------------
Scanning i2c bus for devices..
Total I2C devices found: 0
No I2C devices found

Where did that output come from ?

Have you tried running an I2C scanner on your hardware ?

The LCD can run with "3V" ?

The original Hitachi one can. Who knows what the newer chips can do? Try to figure out the chip(s) in the display board and find specs for then.

It's more than an LCD, though, "oc".
This module has an I2C backpack too.
So, when ESP 3V I2C bumps into a 5v I2C arrangement, life gets tough.
It's not clear/-er to me what "tried both options" really means.

This is the output from I2CexpDiag in the hd44780_I2Cexp i/o class in the hd44780 library (Kind of says most of this in the output - :grinning:)

@ArakelTheDragon
One thing I noticed is that some board symbols changed in the boards.txt file the recent esp8266 core
The NODEMCU ESP-12 and ESP-12E both used to define a single symbol now they have separate symbols.
I2Cexpdiag has been updated to support these new symbols. This will be available in the next hd44780 library release.

This does not affect the issue of not seeing the i2c slave.
It only affects the output where it prints the digital pint for SDA and SCL.
What is missing on that line is that the SDA is D2 and SCL is D1

i.e.
The current I2CexpDiag code doesn't print the Dx pin symbol for the NODEMCU boards with the newer ESP8266 core.

i.e. it should have printed:

SDA digital pin: 4 (GPIO4) D2
SCL digital pin: 5 (GPIO5) D1

So on the nodemcu board you selected
SDA is digital pin 4 which is GPIO4 which is mapped to symbol D2
SCL is digital pin 5 which is GPIO5 which is mapped to symbol D1

i.e. D2 is the same pin as digital pin 4 and D1 is the same pin as digital pin 5

Given that no slave is not seen, my guess would be one or multiple of these:

  • incorrect i2c bus voltage (connecting Nodemcu to 5v bus)
  • incorrect board type selected (this affects the pin mappings)
  • connection issue (bad / incorrect wiring)

I would not recommend hooking up an ESP part directly to a 5v i2c bus since it is a 3v part.
I ALWAYS use a level shifter to avoid any logic level issues and avoid any potential damage to the ESP part by connecting it to a 5v bus.

The correct board type must always be selected since the board selected affects how the pin numbers are mapped to the physical pins on the board.

The Arduino pin mapping and labeling on the ESP parts can be confusing.
This is due to how the ESP core does is mapping and the often poor and inconsistent labeling on the ESP modules.
Because of this it isn't always obvious that the wires are connected to the incorrect pins.
i.e there is a difference between D2 and 2 as those are not the same physical pin on the module.

This can get even more confusing depending on how the board is labeled.
Some boards will label the digital pins D1, D2, D3, ....
And some just use numbers, 1, 2, 3 ....
And on some boards that have just a number (not Dx) the numbers are Dx numbers and some boards that just have a number are showing GPIO numbers.
So that means a pin labeled might be D1 or it might be GPIO1 which is digital pin 1and those are not the same pin since D1 is not necessarily the same pin as GPIO1 or 1
But pin N is always the same as GPIOn
i.e. digital pin 1 is GPIO1

The cause of the D1 vs 1, etc... not being the same pin

The ESP core does is pin mapping using constants. This is WAY more efficient than the goofy multiple table lookups that the Arduino.cc cores do. The ESP way allows the mappings to be done at compile time with ZERO overhead at runtime, whereas the Arduino.cc way requires multiple table lookup which is a a dramatic slow down (particularly on the AVR core) since the mapping has to be looked every single time the pin is used.
The draw back to the ESP way is it creates some potential confusion due to the use of Dx symbols and the different and inconsistent ways board makers label their boards.

--- bill

I tried everything, the LCD is on 3V, the LCD scanner returns the address 0x3F or another depending on the LCD I use, the pins are correct.

The latest code I tried still does not work with this display 128x64:

//    FILE: I2C_LCD_minimal.ino
//  AUTHOR: Rob Tillaart
// PURPOSE: demo I2C_LCD library
//     URL: https://github.com/RobTillaart/I2C_LCD


#include "I2C_LCD.h"


I2C_LCD lcd(0x3F);


void setup()
{
  Serial.begin(9600);
  while (!Serial);
  Serial.println(__FILE__);
  Serial.print("I2C_LCD_LIB_VERSION: ");
  Serial.println(I2C_LCD_LIB_VERSION);
  Serial.println();

  Wire.begin();
  lcd.begin(20, 4);

  //  display fixed text once
  lcd.setCursor(0, 0);
  lcd.print("millis: ");
}


void loop()
{
  lcd.setCursor(8, 0);
  lcd.print(millis());
  delay(1000);
}


//  -- END OF FILE --

This is the latest diagnostic on a different library with the 128x64 display:

⸮dOI⸮⸮,MH⸮0⸮⸮l⸮⸮̤h|⸮⸮L⸮B⸮
********************************************************************
Serial Initialized
--------------------------------------------------------------------
I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool
--------------------------------------------------------------------
hd44780 lib version: 1.3.2
--------------------------------------------------------------------
Reported Arduino Revision: 1.8.19
Arduino Board: ESP8266_NODEMCU_ESP12E
CPU ARCH: ESP8266 - F_CPU: 80000000
--------------------------------------------------------------------
SDA digital pin: 4 (GPIO4)
SCL digital pin: 5 (GPIO5)
--------------------------------------------------------------------
Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - YES
Checking for I2C pins shorted together - Not Shorted
--------------------------------------------------------------------
Scanning i2c bus for devices..
 i2c device found at address 0x3F
Total I2C devices found: 1
--------------------------------------------------------------------
Scanning i2c bus for all lcd displays (4 max)
LCD 0 begin() failed: -3
No working LCD devices

If I use this display(LCD 16x2), the diag becomes better, but still nothing is displayed:

⸮EP⸮V⸮⸮LH⸮⸮GxIh^XAT⸮⸮⸮Nh⸮0P
********************************************************************
Serial Initialized
--------------------------------------------------------------------
I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool
--------------------------------------------------------------------
hd44780 lib version: 1.3.2
--------------------------------------------------------------------
Reported Arduino Revision: 1.8.19
Arduino Board: ESP8266_NODEMCU_ESP12E
CPU ARCH: ESP8266 - F_CPU: 80000000
--------------------------------------------------------------------
SDA digital pin: 4 (GPIO4)
SCL digital pin: 5 (GPIO5)
--------------------------------------------------------------------
Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - YES
Checking for I2C pins shorted together - Not Shorted
--------------------------------------------------------------------
Scanning i2c bus for devices..
 i2c device found at address 0x27
Total I2C devices found: 1
--------------------------------------------------------------------
Scanning i2c bus for all lcd displays (4 max)
 LCD at address: 0x27 | config: P01245673H | R/W control: Yes
Total LCD devices found: 1
--------------------------------------------------------------------
LCD Display Memory Test
Display: 0
 Walking 1s data test:	PASSED
 Address line test:	PASSED
--------------------------------------------------------------------
Each working display should have its backlight on
and be displaying its #, address, and config information
If all pixels are on, or no pixels are showing, but backlight is on, try adjusting contrast pot
If backlight is off, wait for next test

And the last display I have is.

"And the last display I have is."

That requires an/the SSD1306 library.

1 Like

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