Chat here is you are connecting ESP-xx type modules to existing AVR based Arduino

Moderator: igrr

User avatar
By BenB2018
#83731 Hi All, I am finding that code that works for Arduino Nano, Leonardo, Mega with I2c , 5.0vdc, and the NHD-0216K3Z-FL-GEW-V3, DOES NOT work with the I2C of the ESP8266. The ESP8266 uses 3.3v signals, so I used a Level shifter to connect the NHD-0216K3Z-FL-GEW-V3 to the I2C pins of the ESP8266.

I have tried using Wire.setClock(20000); from 10000 to 100000 no change in display
I have tried using Wire.setClockStretchLimit(500); // in µs from 500 to 15000 no change in display

I2C operation with LCD backpacks using the PCF8574 and PCVF8574A work very well with the ESP8266

Here is my test code

/*
ESP8266 Wire library currently supports master mode up to approximately 450KHz.
Before using I2C, pins for SDA and SCL need to be set by calling
Wire.begin(int sda, int scl), i.e.
Wire.begin(0, 2) on ESP-01, else they default to pins 4(SDA) and 5(SCL).
Wire.begin(4, 5) on ESP-01, else they default to pins 4(SDA) and 5(SCL).

This coding works with Nano, Leonardo, Mega but not with ESP8266
*/

#include <Wire.h> //I2C library

#define PIN_SCL D1 //SCL on pin D1 or GPIO5 for ESP-12F, ESP8266 NodeMCU
#define PIN_SDA D2 //SDA on pin D2 or GPIO4 for ESP-12F, ESP8266 NodeMCU

const byte LCDa = 0x28; //LCD address on I2C bus

void setup()

{

Wire.begin(PIN_SDA, PIN_SCL); //
Wire.setClockStretchLimit(500); // in µs
Wire.setClock(50000); //sets I2C speed to 50kHz for NHD LCD display

}
// **** Start Loop Code *************************************************************

void loop()
{
LCDextclear();
delay (1000);

LCDextline1col1();
Wire.beginTransmission(LCDa);
Wire.write("*Hello World!!*"); // for writing string variables
Wire.endTransmission();
delay (1000);

LCDextline2col1();
Wire.beginTransmission(LCDa);
Wire.write("1234567890123456"); // for writing string variables
Wire.endTransmission();
delay (1000);

}
// **** End Loop Code *************************************************************

// Clear the NHD Extended LCD Screen
void LCDextclear() {
Wire.beginTransmission(LCDa);
Wire.write(0xFE);
Wire.write(0x51);
Wire.endTransmission();
delay(2);
}

// Set Cursor to Line #1, Col #1 NHD Extended LCD Screen
void LCDextline1col1() {
Wire.beginTransmission(LCDa);
Wire.write(0xFE);
Wire.write(0x45);
Wire.write(0x00);
Wire.endTransmission();
delay(2);
}

// Set Cursor to Line #2, Col #1 NHD Extended LCD Screen
void LCDextline2col1() {
Wire.beginTransmission(LCDa);
Wire.write(0xFE);
Wire.write(0x45);
Wire.write(0x40);
Wire.endTransmission();
delay(2);
}

// Set Backlight On NHD Extended LCD Screen
void LCDextbklght() {
Wire.beginTransmission(LCDa);
Wire.write(0xFE);
Wire.write(0x53);
Wire.write(8); // brightness value 1 to 8
Wire.endTransmission();
delay(2);
}
// Set Contrast of NHD Extended LCD Screen
void LCDextcontrast() {
Wire.beginTransmission(LCDa);
Wire.write(0xFE);
Wire.write(0x52);
Wire.write(40);
Wire.endTransmission();
delay(2);
}
//*****************************************************************************

Is there any way to get the NHD-0216K3Z-FL-GEW-V3 working with an ESP8266 on I2C?

Does anyone have any solution?

Thanks