How to work with an LCD using I2C in industrial automation

Working with LCD displays using industrial PLC I2C communication
September 8, 2020 by
How to work with an LCD using I2C in industrial automation
Boot & Work Corp. S.L., Marti Guillem Cura


A Liquid-Crystal Display (LCD) is a flat-panel display or another electronically modulating optical device that uses the light-modulating properties of liquid crystals combined with polarizers. It is very common to use them to get and upgrade electronic systems and display the results. In this post, we are going to talk about how to use them using the I2C communications of your PLC controller.

Industrial Shields PLCs

Hardware requirements

How to connect it?

There are a lot of liquid-crystal displays in the market; in our case, we will be using a 16x2 size DEM 16215 an HW-061 I2C interface module. For the industrial Arduino PLC we will use an M-Duino 50RRA+ WiFi/BT

We will provide a 24V power to the PLC Arduino that will provide 5V to power the LCD. The LCD has 16 pins but we will only use a total of 12 as we will be working with a 4 bit data length interface. The pins that we will use for the characters are the ones 11 to 14.

Look for the I2C communication pins on the side of the controller Arduino since you will connect the SCL and SDA pins of the PLC to those of the I2C module. Then using the I2C wire you will connect the LCD display. Depending on your components, check out the documentation to know the pins to connect between the LCD and the I2C module.

Software interface

Our industrial controllers are programmed using Arduino Ide, which is a C language-based software. They can also be programmed using C directly but it is much easier working with Arduino IDE as it provides lots of libraries that help in the programming.

Industrial Shields provides boards to program the PLCs for industrial automation. Basically, you do not need to define the pins and whether they are inputs or outputs since everything is automatically configured using the boards. 

To install Industrial Shields boards, this link explains everything:

After installing the Industrial Shields boards, you will add de I2C Liquid Crystal library that must have been previously downloaded (see requirements). To install the library, you will download it as a ZIP and then select the Sketch option in the Arduino program. Then click on Include Library and Add .ZIP library. Then choose the I2C Liquid Crystal that you have downloaded and it will be automatically set up.

The I2C Liquid Crystal library uses an I2C communication so make sure you use the Arduino Wire library too.

If you do not know the I2C address are you working with, check this post about how an I2C Scanner worksKnowing the address is the first step in order to work properly with this project.
How to work with an LCD using I2C


To work properly, the Wire and LiquidCrystal_I2C libraries must be included.

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

First, you have to call the following statement to create the LiquidCrystal class and set up all the configurations. You will set the address of the I2C device and the number of rows and columns of your LCD. If the I2C address is unknown, you can check our post about how to know it.

LiquidCrystal_I2C lcd(0x3F, 16, 2);

When the display is turned on, it has default configurations, however, resetting the Arduino does not reset the LCD, so you cannot assume that it is in that state when a sketch is started (and the LiquidCrystal constructor is called). To set all the internal settings, you should call the begin function before doing anything.


The I2C Liquid Crystal library provides a wide range of options to work with it. However, you will only use some of them since they are the most important functions to quickly start working. For more precise use, see all the documentation on the library GitHub.

The ones that you will be using are the following:

  • lcd.print(“  x  ”): This will work as the print function, printing the text on the LCD screen.

  • lcd.clear(): It will clear the display and set the cursor to position zero.

  • lcd.setCursor(uint8_t col, uint8_t row): This will set the cursor to the position you have selected.

  • lcd.backlight(): It will turn on the LCD backlight. 

A code will be shown below to see how to display some text on the LCD:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x3F, 16, 2);
void setup()
// initialize the LCD
// Turn on the blacklight and print a message.
void loop(){}

Thinking about switching to open source? 

Contact us and our team will help you to find the solution that best suits your needs.

​Search in our Blog

How to work with an LCD using I2C in industrial automation
Boot & Work Corp. S.L., Marti Guillem Cura September 8, 2020
Share this post

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.

Industrial PLC comparison >>>