Wemos Mini and I2C LCD example

Sometimes a nice big LCD is useful for your projects, in this example we will interface to an I2C LCD using our ESP32. Now these I2C LCD’s consist of 2 parts usually an HD44780 16×2 LCD and an I2C backpack which connects to the LCD exposing the standard power and I2C pins.

This is a typical module you can buy, you can see the backpack which is obviously on the back of the LCD

We will now look at the connections and a simple layout

 

Layout

Connect the pins as follows:

Wemos Mini LCD1602
GND GND
3v3 VCC
D2 SDA
D1 SCL

 

Remember the backpack and lcd connections are already made for you

 

 

Code

You will need an updated I2C LCD library, the original one I couldn’t get to work but this one does seem to work – LiquidCrystal_I2C-master

You will need to import this into the IDE as usual

Now my example below required the I2C address to be changed to 0x3F, a lot of the example I have looked at are 0x27


#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3F,16,2); // set the LCD address to 0x3F for a 16 chars and 2 line display

void setup()
{
lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Hello world");
lcd.setCursor(1,0);
lcd.print("ESP32 I2C LCD");

}

void loop()
{
}

All going well you should see the messages in the code on your LCD display

 

Link

You can pick up one these modules for under $3

1pcs Blue Display IIC/I2C/TWI/SPI Serial Interface 1602 16X2 LCD Module