กลับไปหน้ารวมไฟล์
matrix-orbital-gtt-tft-thermometer-stage-2-93a4be-en.md

This project builds upon our previous Stage 1 GTT Thermometer demo. We've implemented 4 additional buttons, and 2 dynamic labels to create an interactive HMI for setting high and low temperature limits. The Arduino will continually take readings and update the GTT's bar graph and label. If the temperature exceeds either of the two limits, the GTT's piezo buzzer and feedback motor will be activated to alert the user.

Project Perspective

Matrix Orbital GTT TFT Thermometer Stage 2 is a sophisticated exploration of professional-grade display technology and high-performance UI design. By focusing on the essential building blocks—the Matrix Orbital GTT display and a DS18S20 sensor—you'll learn how to communicate and create a visually stunning thermometer using a specialized software logic and a robust hardware setup.

Technical Implementation: GTT Graphics and Data

The project reveals the hidden layers of simple temperature visualization:

  • Interface layer: The Matrix Orbital GTT acts as the high-resolution eye of your project, providing a full-color TFT screen with its own onboard processor for graphics rendering.
  • Sensing layer: The DS18S20 Sensor provides temperature data to the Arduino via a single-wire digital interface.
  • Communication layer: Data is sent from the Arduino to the GTT display using the I2C protocol.
  • UI Logic layer: The Arduino code follows a specialized "sequential reporting" strategy: it requests and performs sensor reads every 800 milliseconds and updates the GTT's bar graph and text fields.

Hardware

  • GTT Series Intelligent TFT Display
  • Arduino Uno
  • Breadboard
  • Male-to-male Jumper cables
  • 4.7k Ohm resistor
  • DS18S20 Temperature Sensor
  • 4pin Bread Board cable
  • USB to Mini-USB cable
  • Power Adapter (optional)

Software

  • GTT GUI Designer Software
  • Arduino IDE

Step 1: Designing the User Interface

Our previous GTT Designer project was modified for this demo. Two labels are implemented to display the high and low temperature limits. Four buttons add control, allowing users to manually set the high and low temperature limits. Each button label has been changed to a '+' or '-' to indicate their function appropriately.

The bar graph, indicator toggles, and current temperature label that were implemented in the previous stage are still present here.

You can download our free and fast GUI design software here

The project files can be downloaded here

GTT Designer GUI Software

Once the design is completed, the project can be deployed to the GTT. You'll need to connect your PC to the GTT's Mass Storage header, and hit "Deploy" in the GTT Designer. All the necessary files will be generated and deployed directly to the display.

Step 2: Connecting the GTT

Similar to our Stage 1 demo, we'll continue to use I2C to communicate between the Arduino Uno and the GTT. Using the Bread Board Cable, connect the 4 pin header to the GTT's I2C header. Then connect the Red Bread Board Cable lead to 5V power, and connect the Black lead to ground. The Yellow (SDA) and Green (SCL) leads need to be connected to the Arduino Uno's SDA pin (A4) and SCL pin (A5) respectively. No I2C pull-up resistors are required for communication with the GTT. Additional power can be applied through the displays barrel jack.

Step 3: Connecting the DS18S20

A 4.7k Ohm pull-up resistor must be placed in parallel with the D18S20's power and data pins, otherwise the sensor will be unable to communicate properly. The data pin can be connected to any digital pin on the Arduino; in this case we selected pin 2.

Step 4: Installing Libraries

Before continuing, download and unzip the the following GTT Client Libraries. These libraries can also be found within the most recent GTT Firmware release. Once downloaded, copy over the contents of GttClient into \Users\YourUserName\Documents\Arduino\libraries\gtt. GTT Client Library

GTT Client Library

The OneWire library will also be required for this demo. You can install the OneWire library through the Aduino IDE Library Manager.

Step 5: Code

//GTT Arduino Thermometer Demo Stage 2
//Arduino Uno with Matrix Orbital GTT70A and DS18S20
//Created by Divino, 24/04/2018
//support@matrixorbital.ca
//www.matrixorbital.ca/appnotes
#include <gtt.h>
#include <gtt_device.h>
#include <gtt_enum.h>
#include <gtt_events.h>
#include <gtt_ext_types.h>
#include <gtt_packet_builder.h>
#include <gtt_parser.h>
#include <gtt_protocol.h>
#include <gtt_text.h>
#include <Wire.h>
#include <OneWire.h>
#include "GTT_Arduino_Thermometer_Demo_Stage_2.c"
#include "GTT_Arduino_Thermometer_Demo_Stage_2.h"
#include <stdlib.h>
#define I2C_Address 0x28 //Define default 8bit I2C address of 0x50 >> 1 for 7bit Arduino
OneWire ds18s20(2); //sensor on pin 2
gtt_device gtt; //Declare the GTT device
byte addr[8]; //Buffer to store One wire Address
bool probeConnected; //Bool to determine indicate if the DS18S20 is connected
bool tempSensorReady = 1;
uint8_t maxTemp = 90; //Default Max limit
uint8_t minTemp = 60; //Default Low limit
unsigned long tempTimer;
// Buffer for incoming data
uint8_t rx_buffer[64] = {0};
// Buffer for outgoing data
uint8_t tx_buffer[64] = {0};
void setup() {
//Setup I2C bus
gtt.Write = i2cWrite; //Set the write function
gtt.Read = i2cRead; //Set the read function
gtt.rx_buffer = rx_buffer; //Declare a buffer for input data
gtt.rx_buffer_size = sizeof(rx_buffer); //Declare the size of the input buffer
gtt.tx_buffer = tx_buffer; //Declare a buffer for output data
gtt.tx_buffer_size = sizeof(tx_buffer); //Declare the size of the output buffer
Wire.begin(); //Begin I2C communication
Serial.begin(9600);
delay(100);
resetDisplay();
//Wait for display to reset
delay(3000);
gtt_set_screen1_image_toggle_2_state(&gtt, 1); //If the Arduino can establish communication with the GTT, toggle the Arduino connection indicator appropriately
gtt25_set_button_clickhandler(&gtt, MyButtonClick); //Configure the button click handler
setCommunicationChannel(2); //set the communication channel to i2c so button clicks can be returned to the Arduino
tempSensorReady = 1; //Indicate that the DS18S20 is ready for communication
}
void loop() {
if(tempSensorReady){ //If the DS18S20 is ready to start a conversion
probeConnected = searchForTempProbe(); //Search for the DS18S20
startTempConversion(); //Start the temperature sensor reading process
tempTimer = millis(); //Start conversion timer
tempSensorReady = 0; //Toggle SensorReady bool
}
if((millis()-tempTimer)>=800){ //800+ mS after starting the conversion, read the temp
if(probeConnected){ //If the probe is connected
int16_t temp = readTempProbe(); //Read the temperature
char buf[4] = {0};
sprintf(buf,"%d",temp); //Convert the temperature value to a string
gtt_set_screen1_dynamic_label_2_text(&gtt, gtt_make_text_ascii(buf)); //Update the GTT label
gtt_set_screen1_bar_graph_1_value(&gtt, temp); //Update the GTT bar graph
//If the temperature exceeds either the high or low limit, activate the buzzer and motor
if(temp >= maxTemp){
Serial.println("Buzzing High");
activateBuzzerAndMotor(1000, 500);
}
if(temp <= minTemp){
Serial.println("Buzzing low");
activateBuzzerAndMotor(500, 500);
}
}
else { //If the probe isn't connected
gtt_set_screen1_image_toggle_3_state(&gtt, 0); //Set the probe indicator to "Disconnected"
gtt_set_screen1_bar_graph_1_value(&gtt, 0); //Set the GTT bar graph to 0
gtt_set_screen1_dynamic_label_2_text(&gtt, gtt_make_text_ascii("NA")); //Update the GTT label to "NA"
}
tempSensorReady = 1; //Temperature sensor is ready for another conversion
}
gtt_parser_process(&gtt); //Parse for touch events
}
void MyButtonClick(gtt_device* gtt, uint16_t ObjectID, uint8_t State)
{
Serial.println(State);
if (State == 1)
{
char buf[4] = {0};
if (ObjectID == id_screen1_circle_button_1)
{
if((maxTemp-1)>minTemp){
maxTemp--;
Serial.print("maxTemp = ");
Serial.println(maxTemp);
sprintf(buf,"%d",maxTemp); //Convert the temperature value to a string
gtt_set_screen1_dynamic_label_3_text(gtt, gtt_make_text_ascii(buf)); //Update the High limit
}
}
if (ObjectID == id_screen1_circle_button_2)
{
if(minTemp >0)
{
minTemp--;
Serial.print("minTemp = ");
Serial.println(minTemp);
sprintf(buf,"%d",minTemp); //Convert the temperature value to a string
gtt_set_screen1_dynamic_label_1_text(gtt, gtt_make_text_ascii(buf)); //Update the Low limit
}
}
if (ObjectID == id_screen1_circle_button_3)
{
if(maxTemp <110)
{
maxTemp++;
Serial.print("maxTemp = ");
Serial.println(maxTemp);
sprintf(buf,"%d",maxTemp); //Convert the temperature value to a string
gtt_set_screen1_dynamic_label_3_text(gtt, gtt_make_text_ascii(buf)); //Update the High limit
}
}
if (ObjectID == id_screen1_circle_button_4)
{
if((minTemp+1) {
minTemp++;
Serial.print("minTemp = ");
Serial.println(minTemp);
sprintf(buf,"%d",minTemp); //Convert the temperature value to a string
gtt_set_screen1_dynamic_label_1_text(gtt, gtt_make_text_ascii(buf)); //Update the Low limit
}
}
}
}
void resetDisplay() {
Serial.println("resetting display");
char command[] = { 254, 1 };
i2cWrite(&gtt, command, sizeof(command));
}
void setCommunicationChannel(byte channel) {
Serial.println("Setting Communication Channel");
char command[] = { 254, 5, channel };
i2cWrite(&gtt, command, sizeof(command));
}
void activateBuzzerAndMotor(short frequency, short duration) {
Serial.println("Setting Communication Channel");
char command[] = { 254, 183, (byte)(frequency >>8), (byte)(frequency && 0xFF),

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Arduino IDE"
  - "1x GTT Support Tool (Matrix Orbital)"
author: "shassandanish1"
category: "Sensors & Environment"
components:
  - "1x Jumper wires (generic)"
  - "1x Matrix Orbital 4 pin Bread Board Cable"
  - "1x Resistor 4.75k ohm"
  - "1x Matrix Orbital GTT70A TFT HMI"
  - "1x Matrix Orbital 5V Universal Power Adapter"
  - "1x Arduino UNO"
  - "1x Breadboard (generic)"
  - "1x USB A to Mini-B Cable"
  - "1x Matrix Orbital DS18S20 Temperature Probe"
description: "A fun and advanced project to create a professional TFT-display thermometer using the Matrix Orbital GTT."
difficulty: "Advanced"
documentationLinks: []
downloadableFiles:
  - "https://github.com/MatrixOrbital/GTT-Arduino-Thermometer-Demo_Stage_2"
  - "https://github.com/MatrixOrbital/GTT-Arduino-Thermometer-Demo_Stage_2"
encryptedPayload: "U2FsdGVkX1/sFzSkwNkTa+UNiAbtXC9MqMo9R3BdzXhw6eNVsUhxaCSLP7wJNVEVhY5jU0xjsBQymNrCx8+AsTdLeZjQXG+EW+tf2eRj3Nqx1DV9FeLp2HoHZh5APctO1iG4fsIjPeV8Kh3/buQEcA=="
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/matrix-orbital-gtt-tft-thermometer-stage-2-93a4be_cover.jpg"
lang: "en"
likes: 1
passwordHash: "c7c66de0b3ee1c62f503d8438879047e4f3100fa8a871a9fccc908ce2843d31e"
price: 2450
seoDescription: "An advanced and playfully interactive Matrix Orbital GTT thermometer for beginners interested in Arduino TFT graphics projects."
tags:
  - "thermometer"
  - "matrix-orbital"
  - "tft"
  - "gtt"
  - "arduino"
  - "advanced"
title: "Matrix Orbital GTT TFT Thermometer Stage 2"
tools: []
videoLinks:
  - "https://www.youtube.com/embed/AR8z-UDoHkI"
views: 4762