Examples > TFT

Esplora TFT Temperature Display

This example for the Esplora with an Arduino TFT screen reads the temperature with the onboard thermisistor, and prints it out on screen.

Hardware Required

  • Arduino Esplora
  • Arduino TFT screen


Attach the TFT screen to the socket on your Esplora, with the label "SD Card" facing up.


To use the screen you must first include the SPI and TFT libraries. Don't forget to include the Esplora library as well.

#include <Esplora.h>
#include <TFT.h>
#include <SPI.h>

To update the screen with text, you'll need to store dynamic content in a char array.

char tempPrintout[3];

In setup(), initialize the screen and clear the background. Set the color for the font with stroke(), and write any static text to the screen. In this case, you'll write "Degrees in C :". This will stay at the top of the screen and not change as long as the sketch runs. Before entering the loop(), set the text size so you can really see the temperature stand out.

void setup(void) {

  EsploraTFT.text("Degrees in C :\n ",0,0);

In loop(), read the temperature in Celsius with Esplora.readTemperature(DEGREES_C), storing it in a string. Convert the string content to a char array, storing it in the global array you declared int he beginning of your program.

void loop() {

  String temperature = String(Esplora.readTemperature(DEGREES_C));
  temperature.toCharArray(tempPrintout, 3);

Set the text color (this would be a good place to change the color of the text depending on the value from the thermometer), and print it to the screen below the static text.

  EsploraTFT.text(tempPrintout, 0, 30);

Wait for one second, then erase the text you just wrote, so you can update it in the next run through loop().

  // erase the text for the next loop
  EsploraTFT.text(tempPrintout, 0, 30);

The complete sketch is below :

SORRY, There is an error at our code repository, please inform to web@arduino.cc