GTT Design: Arduino Thermometer

GTT Designer Software Support

Moderator: Mods

Post Reply
Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 118
Joined: Thu Sep 24, 2015 9:38 am

GTT Design: Arduino Thermometer

Post by Daniel Divino » Thu Apr 19, 2018 2:25 pm
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.

- 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)

- 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.
GTT Thermometer Project Screenshot.jpg
GTT Thermometer Project Screenshot.jpg (53.75 KiB) Viewed 99 times
You can download our GUI design here.

You can download our free and fast GUI design software 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.
gtt_arduino_schematic.jpg (45.92 KiB) Viewed 99 times
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

Code: Select all

//Arduino Uno with Matrix Orbital GTT70A and DS18S20
//Created by Divino, 19/047/2018
#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
 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 */
byte searchForTempProbe(){
 if ( ! {
   Serial.print("No more addresses.\n");
   return 0;
 for( byte i = 0; i < 8; i++) {
   Serial.print(addr[i], HEX);
   Serial.print(" ");
 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");
     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.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.write(0xBE);// Read Scratchpad
 for ( byte i = 0; i < 9; i++) {// we need 9 bytes
   data[i] =;
 temp = ( (data[1] << 8) + data[0] ) * 0.5;    
 temp= (temp * 9/5) + 32;
 Serial.print("Temp = ");  
 return temp;
int i2cWrite(gtt_device* gtt_device, char* data, byte data_length) {//Write an array of bytes over i2c
 for (int i = 0; i < data_length; i++) {
 return 0;
byte i2cRead(gtt_device* gtt_device) { //Wait for one byte to be read over i2c  
 byte data;
 Wire.requestFrom(I2C_Address, 1);     
   return -1;
   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.

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.

Let us know if you like this demo, or if you have any questions!

Matrix Orbital Team
Daniel Divino
Technical Support
Matrix Orbital

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 118
Joined: Thu Sep 24, 2015 9:38 am

Re: GTT Design: Arduino Thermometer

Post by Daniel Divino » Wed Apr 25, 2018 9:48 am

Hi Everyone! I just wanted to let you know we've updated the demo and implemented user controlled temperature limits. The user will be able to set low temperature and high temperature limits and an audible alert will be triggered if the temperature exceeds either of those limits.

Our stage 2 demonstration video can be found on our Youtube page here.

GTT Thermometer stage 2.jpg
GTT Thermometer stage 2.jpg (35.65 KiB) Viewed 65 times
Matrix Orbital's GTT Arduino Thermometer Stage 2 uses all of the same hardware and software as stage 1, but a couple of modifications have been made to the GUI.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.

You can download the updated GUI design here.

The Updated Arduino code can be downloaded here.
Daniel Divino
Technical Support
Matrix Orbital

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest