Arduino HMI TFT LCD Display Sensor Monitoring

(Last Updated On: January 6, 2020)

Arduino HMI Sensor Monitoring

Description:

Arduino HMI TFT LCD Display Sensor Monitoring- 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 stoneitech.com.

In this tutorial, you will learn how to send the sensors data From Arduino to the HMI Intelligent TFT LCD module using the Serial Communication. For the best understanding, I have used the Variable resistor or potentiometer which of course you can replace with any other sensor you want. The GUI design and the variable memory addresses remain the same.

For the extreme basics read my previous two articles,

10.1” HMI Intelligent TFT LCD Module, Display Panel, & Touchscreen

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.

10.1” HMI intelligent TFT LCD UART Serial Communication

While in tutorial number2 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. So, I highly recommend first, watch my previous tutorials and then you can resume from here.


 In this article, 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!!!

Note: for the step by step explanation, watch the video tutorial given at the end of this article.

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

HMI TFT LCD MODULE Amazon product link: https://amzn.to/3747ybU
Arduino Uno: https://amzn.to/2ZEO2Ad
MAX232 board: https://amzn.to/359kcVS
RS232 Cable: https://amzn.to/2MFGb04

Alibaba Product link: Https://dwz.cn/c7qxhemh
Official website link: Www.stoneitech.com
https://dwz.cn/xnz5pTK9 (Japan)
https://dwz.cn/t2Ji0v4E (UK)
https://dwz.cn/KUJ5kBgu (France)
https://dwz.cn/3Wqh7RAM (Italy)
https://dwz.cn/2XDDEq8f (Spain)
https://dwz.cn/XUUfpHEV (India)
eBay store link: Https://www.ebay.com/str/stonedisplay
Aliexpress store link: https://dwz.cn/PpQlr2RU
Other components and Tools:
Mega 2560: https://amzn.to/2ze1kdu
Super Starter kit for Beginners https://amzn.to/2KJvmKG
Jumper Wires: https://amzn.to/2KMoVXs
Bread Board: https://amzn.to/2MS4q8X
12v Adaptor: https://amzn.to/2Ntr6h1
PCB plate: https://amzn.to/2IUwpCt
Variable Supply: https://amzn.to/2MT4Qfj
Digital Multimeter: https://amzn.to/2Nvft9i
Vero Board / stripboard: https://amzn.to/2MTf9jD
Soldering iron kit:  “best”  You guys should definitely purchase this https://amzn.to/2zfoNuJ
Solder wire: https://amzn.to/2ufUMWf
Wire Stripper: https://amzn.to/2KOqxfU
wirecutter: https://amzn.to/2ucIq14
PCB small portable drill machine: https://amzn.to/2Nu62XF

*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!


HMI TFT LCD Module interfacing with Arduino Circuit Diagram:

Arduino HMI Sensor Monitoring

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 MAX232, 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 variable resistor or Potentiometer is used as the Sensor. The middle leg of the potentiometer is connected with the Arduino’s Analog Pin A0, while the other two legs are connected with the Arduino’s 3.3 volts and ground.


Interfacing MAX232 with Arduino and HMI TFT LCD module:

Arduino HMI Sensor Monitoring

As you can see the HMI TFT LCD Module is connected with the Max232 board through RS232 cable which I modified.

Arduino HMI Sensor Monitoring

Normally the RS232 cable comes with the male and female type DB9 connectors. But we have a small problem,

 

Arduino HMI Sensor Monitoring

As you can see the MAX232 board has the female type DP9 connector, and the HMI intelligent TFT LCD Module also comes with the female type DB9 connector.

Arduino HMI Sensor Monitoring

I replaced the female type DB9 connector with the Male type DB9 connector. I simply soldered three wires. I connected the ground of both the male connectors together, connected the TX pin of the one male connector with the RX pin of the other male connector, similarly connected with the RX of the first male connector with the TX of the other DB9 male connector. Now I can use this cable to connect the HMI TFT LCD Module with the Max232 board without any problem.

Arduino HMI Sensor Monitoring

The VCC of the max232 board is connected with the Arduino’s 5 volts, the ground is connected with the Arduino’s ground, while the TX and RX pins of the Max232 are connected with the Arduino’s pin number 2 and pin number 3.


HMI TFT LCD Module Arduino Sensor Monitoring GUI:

Arduino HMI Sensor Monitoring

The  GUI design remains the same which I used in my previous two tutorials, the variable memory addresses remain the same. Now we will use Arduino to send the sensor data using Serial communication, the received values will be stored in these two memory locations. Let’s have a look at the Arduino’s programming.


Arduino HMI Sensor Monitoring Programming:



Arduino HMI Sensor Monitoring Program Explanation:

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.

#include <SoftwareSerial.h>

SoftwareSerial max232(2,3);

Then I defined the Sensors High and Low bytes. These are the same address used in the GUI. 0x0002 and 0x0006.

#define Sensor1_H               0x00

#define Sensor1_L               0x02

#define Sensor2_H               0x00

#define Sensor2_L               0x06

Then I defined a pin for the potentiometer. A potentiometer is connected with the Analog Pin A0 of the Arduino.

int vr = A0;

These are the same commands which I have already explained in my previous tutorial. You can watch my previous tutorial, the link is given in the description.


unsigned char sensor1_send[8]= {0xA5, 0x5A, 0x05, 0x82, Sensor1_H, Sensor1_L, 0x00, 0x00};

unsigned char sensor2_send[8]= {0xA5, 0x5A, 0x05, 0x82, Sensor2_H, Sensor2_L,  0x00, 0x00};

In the Void setup function, I activated the Serial communication, and set the variable resistor as the input.

void setup()

{

Serial.begin(115200);

max232.begin(115200);

pinMode(vr,INPUT);

}

void loop()

{

First we read the variable resistor and store the value in variable Sensor1 which is of the type integer.

 int sensor1 = analogRead(vr);

In variable sensor2 I stored a random value of -53,

 int sensor2 = -53;


next, I split the sensors values into high and low bytes and stored the values in array at locations 6 and 7.

     sensor1_send[6] = highByte(sensor1);

     sensor1_send[7] = lowByte(sensor1);

finally, it is sent to the HMI TFT LCD Module.

     max232.write(sensor1_send,8);

delay(100);

similarly for the Sensor2.

     sensor2_send[6] = highByte(sensor2);

     sensor2_send[7] = lowByte(sensor2);

     max232.write(sensor2_send,8);

     Serial.println(sensor1);

     delay(100);

}



So, that’s it for now. In the upcoming article, I will explain how to control electrical loads using 10.1” HMI TFT LCD Module and Arduino.  If you have any questions, let me know in a comment. Don’t forget to Subscribe to my Website and YouTube channel “Electronic Clinic”.

 

Watch Video Tutorial:

 

Recommended For You

About the Author: 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

Close