How to display sensors data on Dwin-HMI(DMG19480C088_03W)

Description

DWIN specialized in making High quality and cost effective HMI touch screens display.

In this tutorial I am going to make a display for three sensors and these sensors data will display on the DWIN-HMI TFT display with the help of TTL converter and Arduino. So by this you will learn how to display or send the data to DWIN-HMI with the help of any Microcontroller. So let’s start with it and stay tune here to get the solution for Dwin-HMI display.

Dwin

This DMG19480C088_03W has resolution of 1920×480 and can be easily used within range of 9-12 voltage & compatible with controller boards like Arduino Uno, Arduino Nano, Arduino Mega, PIC microcontrollers, 8051 family of microcontrollers, etc.

For this product or more different product you can contact Dwin supplier or their Team, contact details are given above for any query related with Product, please reach to them if you have any.

You can use this coupon DWINROCK0760 to get discount & ๐ˆ๐Ÿ ๐ฒ๐จ๐ฎ ๐ฐ๐š๐ง๐ญ ๐ญ๐จ ๐ ๐ž๐ญ ๐Ÿ๐ซ๐ž๐ž ๐ฌ๐š๐ฆ๐ฉ๐ฅ๐ž๐ฌ ๐ฒ๐จ๐ฎ ๐œ๐š๐ง ๐œ๐จ๐ง๐ญ๐š๐œ๐ญ ๐ญ๐ก๐ž๐ฆ.

Tool Installation

For tool installation, I already explained in the first tutorial of Dwin you can check this by clicking on given link. And this is require to proceed further so please check it, how to install the tools, then you can proceed further in this project to design GUI as you saw in the output video/YouTube so go through first Tutorial which is given below.

GUI Designing

For GUI there are few steps which you have to follow for proceeding further in a easy way.

Step1 :- First you have to make a new folder then go in GUI tool and click on new project and give the path of this project. Then convert that image which we are going to use for GUI, with the help of inbuilt tool โ€œPicture conversionโ€ . At the time of converting images give the path of Project folder.

Step2 :- After converted images you have to make ICL file of every images and icons and then save these file in DWIN_SET folder with the name starting from 32..33โ€ฆ34โ€ฆโ€ฆ..64 and so on this is the rule, because memory is divided in different section so you have to name like this only, you can see ICL tool in below image through this you have to make ICL file.

As in this we have icons & image so, I have made two ICL file and these file are saved in the DWIN_SET folder as you can see in below image.

Step3 :- Now as we have three data box, so there we need to add data variable widget with different VP addresses. Add that widget at the place of respective sensor box. And do other settings as per image which is given below. And remember you have to give different VP address to all three data box.

Now add Icon variable for Gas-sensor as you in the output it has two transition RED and Green, for this we need to add those images which we already made an ICL file, so for this add Icon variable widget at the place of Gas-sensor and in this widget add that Icon file 4, and do other setting as per given image.

Now GUI design is ready, So click on save and then click on generate button.

Step4:- we have to upload the project in the display, for this you require a SD card, in that copy that DWIN_SET folder and then plug this SD card in the display before connecting power supply, then connect power supply and it will take few secs to upload project in it, when unloading is done you will get this type of blue screen with same data on it ,after this just remove power supply and SD card and then connect the power supply in it.

Circuit & Arduino code

After done with GUI design you have to connect Display with other components as given in below circuit. As here I have used Ultrasonic, Gas-sensor and Temperature sensor for this project so you can find all these components in the circuit. As all component sending the data to Display so here display is receiving the signal from Arduino and this signal in the form of frame of HEX, here is the example of this frame which I have use in the code.

Frame[8]={0x5a, 0xa5, 0x05, 0x82, sensor_H, sensor_L, sensor_value_H, sensor_value_L } this is the frame which display is receiving from Arduino, and here sensor_L & sensor_H is the address for that particular sessor & sensor_value_H & sensor_value_L is the sensor value in High byte and Low byte respectively.

Circuit-Diagram :-

Example :- If we have put the VP address for a sensor box as 5100 so here sensor_H=0x51 and sensor_L will be 0x00. And this sensor will send the data over these two sensor_value_H, sensor_value_L values of that frame. This is the concept which I have used in the code.

Code

#include <Wire.h>
#include <Adafruit_MLX90614.h>
Adafruit_MLX90614 mlx = Adafruit_MLX90614();

/* Adresses of all sensors */
#define distance_inch     0x51
#define distance_cm       0x52
#define temp_sensor       0x53
#define gas_sensor        0x54

/* Data frame for all sensors */
unsigned char   distance1[8]={0x5a, 0xa5, 0x05, 0x82, distance_inch, 0x00, 0x00, 0x00};
unsigned char   distance2[8]={0x5a, 0xa5, 0x05, 0x82, distance_cm, 0x00, 0x00, 0x00};
unsigned char        temp[8]={0x5a, 0xa5, 0x05, 0x82, temp_sensor, 0x00, 0x00, 0x00};
unsigned char         gas[8]={0x5a, 0xa5, 0x05, 0x82, gas_sensor, 0x00, 0x00, 0x00};

long duration;
int distanceCm, distanceInch;
int temp_value=0;

const int echoPin = 2;
const int trigPin = 3;
const int gasPin = 4;

void setup() 
{
  Serial.begin(115200);
  mlx.begin();
  pinMode(echoPin, INPUT);
  pinMode(trigPin, OUTPUT);
  pinMode(gasPin, INPUT);
  digitalWrite(gasPin,LOW);
}
void loop() 
{
  /* For distance-sensor */
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distanceCm = duration * 0.0340 / 2;
  distanceInch = duration * 0.01330 / 2;

  distance1[6] =highByte(distanceInch);
  distance1[7] =lowByte(distanceInch);
  Serial.write(distance1,8);
  
  distance2[6] =highByte(distanceCm);
  distance2[7] =lowByte(distanceCm);
  Serial.write(distance2,8);

  /* For temparatue-sensor */
  temp_value=mlx.readObjectTempC();
  temp[6] =highByte(temp_value);
  temp[7] =lowByte(temp_value);
  Serial.write(temp,8);

  /* For gas sensor */
  if(digitalRead(gasPin)== HIGH)
  {
    gas[7] =1;
    Serial.write(gas,8);
  }
  else
  {
    gas[7] =0;
    Serial.write(gas,8);
  }
}

As you can see here in code I have declare four frame here two frame for distance measurements and other two are Gas-sensor & Temperature sensor. And their address also mentioned above you can check in code. After that I am sending the particular sensor data to respective frame to display in that display-box. And you can find the code section for each components, because I have commented all the things in the code itself.

Now I think you understood the circuit and code working also, so now upload the code in the Arduino board, here I have used the Arduino nano but if you want to use other you can use it, Before uploading don’t forget to select the port and board and at the time of uploading remove that Rx & TX pin after upload connect them.

Testing/Output

Here is the output video you can see it for reference and if you are facing any difficulties you can watch the YouTube video, link is given below please find that. Or if you have any doubt please ask in comment section, I will try to give answer as soon as possible. And for any product query reach to them Email Id :- rock@dwin.com.cn

YouTube-Video
Click Here

Leave a Reply

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