Project tutorial
Matrix Orbital GTT TFT Thermometer Stage 1

Matrix Orbital GTT TFT Thermometer Stage 1 © MIT

This project demonstrates how easy it is to display temperature information on a Matrix Orbital GTT HMI using a DS18S20 and an Arduino Uno.

  • 5,786 views
  • 0 comments
  • 14 respects

Components and supplies

Apps and online services

Matrix Orbital GTT GUI Designer
Free fast development GUI/HMI Software for the Matrix Orbital GTT Intelligent TFT Series of displays.
Ide web
Arduino IDE

About this project

Matrix Orbital GTT Thermometer in Action

Hello everyone! This project is meant to demonstrate how easy it is to interface a Matrix Orbital GTT Intelligent TFT HMI display with an Arduino Uno through I2C. A DS18S20 temperature sensor is used to obtain temperature information, which is then processed by the Uno. Once the Arduino processes the temperature information, it updates the GTT's bar graph, and label.

Hardware

  • GTT Series Intelligent TFT HMI Display
  • Arduino Uno
  • Bread Board
  • 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

The GTT Designer Suite allows users to easily drag and drop widgets on screen. Images and font files can also be imported for use when creating GUI's. For this project, we've dragged in a Bar graph, 3 Image Toggles, a label, and a Thermometer image. The Bar graph is used to visually represent the current temperature. The label displays the current temperature value numerically. Two of the image toggles are used to indicate whether or not the Arduino and DS18S20 temperature sensor are connected and operating properly. Finally, the third image toggle allows users to turn the display's backlight on and off.

You can download our free and fast GUI design software here.

The project files can be downloaded here

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

For this demo, we'll be using 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

Step 5: Code

//GTT Arduino Thermometer Demo Stage 1
//Arduino Uno with Matrix Orbital GTT70A and DS18S20
//Created by Divino, 19/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 "GTTProject21.c"
#include "GTTProject21.h"
#define I2C_Address 0x28  //Define default 8bit I2C address of 0x50 >> 1 for 7bit Arduino
// Buffer for incoming data
uint8_t rx_buffer[64];
// Buffer for outgoing data
uint8_t tx_buffer[64];
#include <stdlib.h>
OneWire ds18s20(2); //sensor on pin 2
byte addr[8]; //Buffer to store One wire Address
bool probeConnected; //Bool to determine indicate if the DS18S20 is connected
gtt_device gtt; //Declare the GTT device
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(500);  
 resetDisplay();  
 delay(3000);  
 gtt_set_screen1_image_toggle_2_state(&gtt, 1); //If the Arduino can establish communication with the GTT, Arduino connection indicator appropriately      
}
void loop() {
 // put your main code here, to run repeatedly:  
 probeConnected = searchForTempProbe(); //Search for the DS18S20
 if(probeConnected){ //If the probe is connected
  int16_t temp = readTempProbe(); //Read the temperature      
  char buf[] = {0};
  sprintf(buf,"%d",temp); //Convert the temperature value to a string
  gtt_set_screen1_bar_graph_1_value(&gtt, temp); //Update the GTT bar graph
  gtt_set_screen1_dynamic_label_2_text(&gtt, gtt_make_text_ascii(buf)); //Update the GTT label
 }   
 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 appropriately
  gtt_set_screen1_dynamic_label_2_text(&gtt, gtt_make_text_ascii("NA")); //Update the GTT label to "NA"
 }  
}
void resetDisplay() {
 Serial.println("resetting display");
 char command[] = { 254, 1 };
 i2cWrite(&gtt, command, sizeof(command));
}
/* The Code used in the searchorTempProbe and readTempProbe function is 
* sample code taken from https://playground.arduino.cc/Learning/OneWire */
byte searchForTempProbe(){
 ds18s20.reset_search();
 if ( !ds18s20.search(addr)) {
   Serial.print("No more addresses.\n");
   ds18s20.reset_search();
   delay(250);
   return 0;
 }
   Serial.print("R=");
 for( byte i = 0; i < 8; i++) {
   Serial.print(addr[i], HEX);
   Serial.print(" ");
 }
 Serial.println();
 if ( OneWire::crc8( addr, 7) != addr[7]) {
     Serial.print("CRC is not valid!\n");
     gtt_set_screen1_image_toggle_3_state(&gtt, 0); //Set the probe indicator to "Disconnected"
     return 0;
 }
 if ( addr[0] == 0x10) {
     Serial.print("Device is a DS18S20 family device.\n");
     gtt_set_screen1_image_toggle_3_state(&gtt, 1); //Set the probe indicator to "Connected"  
     return 1;
 }     
 else {
     Serial.print("Device family is not recognized: 0x");
     Serial.println(addr[0],HEX);
     gtt_set_screen1_image_toggle_3_state(&gtt, 0); //Set the probe indicator to "Disconnected"
     return 0;
 }
}
byte readTempProbe(){
 byte present = 0;
 byte data[12];
 float temp;
 ds18s20.reset();
 ds18s20.select(addr);
 ds18s20.write(0x44,1);// start conversion, with parasite power on at the end
 delay(750);// maybe 750ms is enough, maybe not
 // we might do a ds.depower() here, but the reset will take care of it.
 present = ds18s20.reset();
 ds18s20.select(addr);    
 ds18s20.write(0xBE);// Read Scratchpad
 for ( byte i = 0; i < 9; i++) {// we need 9 bytes
   data[i] = ds18s20.read();
 }  
 temp = ( (data[1] << 8) + data[0] ) * 0.5;    
 temp= (temp * 9/5) + 32;
 Serial.print("Temp = ");  
 Serial.println(temp);
 return temp;
}     
int i2cWrite(gtt_device* gtt_device, char* data, byte data_length) {//Write an array of bytes over i2c
 Wire.beginTransmission(I2C_Address);  
 for (int i = 0; i < data_length; i++) {
   Wire.write(data[i]);        
 }
 Wire.endTransmission();  
 return 0;
}
byte i2cRead(gtt_device* gtt_device) { //Wait for one byte to be read over i2c  
 byte data;
 Wire.beginTransmission(I2C_Address);  
 Wire.requestFrom(I2C_Address, 1);     
 if(Wire.available()<1) 
 {
   return -1;
 }
 else{
   data = Wire.read();  
   Serial.println(data);
   return data;
 } 
}

Download the GTT_Arduino_Thermometer_Demo.ino file. Navigate to the GTTProject21>Output folder, and grab the.c and.h files generated by the GTT Designer Suite. Place both files in the GTT_Arduino_Thermometer_Demo.ino source directory, then open the.ino file.

If everything is setup properly, the.c and.h file will open along with the GTT_Arduino_Thermometer_Demo.ino code.

From there, you can upload the program to the Uno. The GTT will reset immediately after the program is uploaded. After a few seconds, the Thermometer demo screen will be displayed on the GTT. The image toggles will be set, indicating the connection status of the Arduino and the DS18S20 probe. If the probe becomes disconnected at any point, the indicators will provide visual notification that no temperature probe can be found.

Code

GTT Arduino Thermometer Demo Github Repository
This repository contains all the files necessary to run this project.

Custom parts and enclosures

External TFT Enclosure
External TFT Enclosure for the Matrix Orbital GTT HMI TFT [Thinkiverse](https://www.thingiverse.com/thing:2849496)

Schematics

Project Schematic
Schematic for the GTT, Arduino, DS18S20
Gtt arduino schematic naqdqiy0dm

Comments

Similar projects you might like

Matrix Orbital GTT TFT Thermometer Stage 2

Project tutorial by MatrixOrbital

  • 710 views
  • 0 comments
  • 2 respects

Analog Clock with LED Matrix and Arduino

Project tutorial by LAGSILVA

  • 12,237 views
  • 8 comments
  • 39 respects

Digital And Binary Clock With Two LED Matrix And RTC

Project tutorial by LAGSILVA

  • 6,117 views
  • 10 comments
  • 27 respects

Easy Thermometer v1

Project tutorial by hixel

  • 931 views
  • 1 comment
  • 3 respects

Matrix Orbital EVE2 TFT, Servo and an AMS Magnetic Sensor

Project showcase by MatrixOrbital

  • 580 views
  • 0 comments
  • 4 respects

Tiny Calendar and Clock Featuring Moon Phase in a LED Matrix

Project showcase by LAGSILVA

  • 6,076 views
  • 6 comments
  • 33 respects
Add projectSign up / Login