Arduino Projects

Arduino HMI TFT LCD Module Electrical Load controller



Arduino HMI TFT LCD Module Electrical Load controller- The 10.1” HMI Intelligent TFT LCD Module used in this video is sponsored by the Stone Technologies. Stone Technologies is a professional Manufacturer of HMI Intelligent TFT LCD modules.  Depending on the application the Stone Technologies offers Industrial Type, Advanced type, and Civil Type Intelligent TFT LCD modules available in different sizes. The one I am using in this series of videos is the Civil Type 10.1 inch HMI display Module. For more information visit

In this article, you will learn how to control electrical loads using 10.1” HMI TFT LCD Display Module and Arduino Uno. The control commands are sent serially from the HMI Touchscreen display Module through the max232 board to the Arduino. The Arduino then Turns ON and Turns OFF the desired load depending on the command. Using the same button you can Turn ON and Turn OFF the load, the buttons used on the HMI GUI works as the Toggle switches. For the demonstration purposes, I have connected 220Vac light bulbs which you can replace with other AC or DC loads. Be very careful while working on the 220Vac as it can be really dangerous, wear protective gloves. Make this project at your own risk. This project is entirely based on my previous three tutorials.

In tutorial number1 I explained how to design a graphical user interface using the images designed in Adobe Photoshop. How to use the button function, data variable function, Hardware parameter function and how to use the Drag adjustment, and Slider Scale function for controlling the screen brightness.

In tutorial number 2 I explained the commands used for reading and writing, how to control the user interface without pressing the on-screen buttons… how to access the brightness control register and so on.

In tutorial number 3, I explained how to monitor a sensor in real-time using Arduino and the HMI Touchscreen TFT LCD display module. So, I highly recommend first, watch my previous tutorials and then you can resume from here.

In this project I am using the same GUI, but with a little modification.


This time I added the control button on the main screen image, and also added the control panel images designed in Adobe Photoshop.


This image is the main image of the control panel, while the image given below is the image which will be used as the button click effect.


In this tutorial, we will cover

  1. Complete Circuit Diagram
  2. Arduino Interfacing with the HMI TFT LCD Module, and
  3. Arduino Programming

Without any further delay let’s get started!!!

The purchase links of the HMI TFT LCD Module and other components used in this project are given below:


12v Adaptor:

Arduino Uno

Arduino Nano

MAX232 board:

RS232 Cable:

2-channel relay module:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Arduino HMI TFT LCD Module Load Controller Circuit Diagram:


As you can see the circuit diagram is really simple. The 10.1 inch TFT LCD Module and Arduino is powered up using a 12v adaptor or battery. All the grounds are connected together. The DIN pin of the TFT LCD module which is data-in is connected with the TX pin of the db9, the DOUT pin which is the data-out pin is connected with the RX pin of the DB9. The VCC pin of the MAX232 board is connected with the Arduino’s 5 volts, the ground of the MAX232 is connected with the Arduino’s ground, while the TX and RX pins of the MAX232 Board are connected with the Arduino’s pin number 2 and Pin number 3. Later in the programming, I will explain, why am I using pin number 2 and pin number 3 as the Serial Port.

A two-channel relay module is connected with the Arduino’s pin number 12 and pin number 13. You can use a readymade relay module or follow the same connections and build the one by yourself. It’s very simple. The relays used in this project are of the type SPDT “Single Pole and Double Throw”. This type of relay has a total of 5 pins, two relay coil pins, common, normally open, and normally closed. The one side of the relay coil is connected with the 12 volts while the other side of the relay coil is connected with the collector of the 2n2222 NPN transistor. The emitter is connected with the ground, while the base is connected with the 10k ohm resistor. The 10k ohm resistor and the transistor together are used to control the relay which is also called the relay driver. If you want to learn in detail about the electro-mechanical relays, and relay driver design calculations then read my article available on you can find a link in the description.


This is a seven-channel relay module, but out of these 7 relays, I will be using only two relays. One relay will be connected with the Arduino’s digital pin 12 and the other relay will be connected with the Arduino’s digital pin 13.

Arduino Interfacing with MAX232 and HMI TFT LCD module:


The HMI TFT LCD display module connection with the MAX232 board and Arduino remain the same as explained in my previous tutorial, the link is given above. This time only the relay module is added. All the connections are done as per the circuit diagram.

HMI TFT LCD Module Control Panel GUI:

As you can see in the images above, I am using the same GUI, this time I added the control button on the main screen. So, when I click on the control button it takes me to the image8 which is the control panel user interface.


This time I used the Return pressed key value function. I selected the variable memory as 0011, which is the same for all the buttons. But the keys values are different. For the load1 I selected 0001, for the load2 I selected 0002, and so on up to 0005. You can select any Keys value you want. Finally, when I click on the Back button it takes me to the main screen. So that’s all about the GUI of the HMI TFT LCD Display Module. Now, let’s have a look at the Arduino programming.

Arduino HMI TFT LCD Load Controller Programming:

Arduino HMI TFT LCD Load Controller Program Explanation:

#include <SoftwareSerial.h>

SoftwareSerial max232(2,3);

I started off with the SoftwareSerial library. The SoftwareSerial is basically a library that enables the Serial Communication on digital pins other than the Arduino’s default Serial Port. Using the SoftwareSerial library we can create multiple software serial ports with speeds up to 115200bps.

In this particular project, you can also use the Arduino’s default Serial port which is on Pin number 0 and pin number 1. But trust me this will really make you tired, because each time you upload a program, you will have to remove the wires. That’s why I always say never use the Arduino’s default Serial Port for the communication with other devices. The Arduino’s default Serial Port should only be used for debugging purposes.

I created a software Serial Port with the name max232 on the Arduino’s pin number 2 and pin number 3. Pin number 2 is the RX while pin number 3 is the TX.

char data;

String mystring;

int load1 = 13;

int load1f = 0;

int load2 = 12;

int load2f = 0;

Then I defined a variable data of the type character. Then I defined another variable mystring of the type String. Then I defined pins for the relays which are connected with the Arduino’s pin number 13 and 12. The load1f and load2f will be used as the flags.

void setup()




pinMode(load1, OUTPUT);

pinMode(load2, OUTPUT);

digitalWrite(load1, LOW);

digitalWrite(load2, LOW);


In this void setup function, I activated the serial communication and set the loads as OUTPUT.

Then starts the void loop function.

if (max232.available()>0)


data =;

mystring = mystring + byte(data) ;



The above condition means if the Arduino has received data from the HMI TFT LCD display Module, simply read the max232 port store the character in variable data. Convert the received character into the byte and add it with the mystring to make the complete message.

if (max232.available() == 0)







mystring = “”;


This condition means if there is no more data on the max232 port then execute the load1control() and load2control() functions and finally empty the mystring variable.

void load1control()


if (mystring.endsWith(“101”)&& (load1f == 0))


mystring = “”;

if(digitalRead(load1) == LOW)



Serial.println(“load1 High”);


load1f = 1;


if (mystring.endsWith(“101”) && (load1f == 1))


mystring = “”;

if(digitalRead(load1) == HIGH)



Serial.println(“load1 LOW”);


load1f = 0;



Load1control() function is a user defined function, it has no return type and doesn’t take any argument as the input.

if (mystring.endsWith(“101”)&& (load1f == 0))

This condition means if the mystring ends with the 101 and load1f is 0 then empty the mystring variable, and check if the load is off then turn on the load. And change the load1f status from 0 to 1.

if (mystring.endsWith(“101”) && (load1f == 1))

If the same button is pressed again and the load1f is equal to 1, empty the mystring variable , and if the load1 is high then turn OFF the load1, and again change the load1f status from 1 to 0.

Similarly for the load2.

The same way you can do it for all the 5 buttons.

For the complete step by step explanation and practical demonstration, watch the video given below.

Watch the video tutorial:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button