Display temperature on Arduino Esplora LCD

This example will read the temperature using the built in temperature sensor on the Arduino Esplora and display it on the LCD

esplora
esplora

Code

 

#include <Esplora.h>
#include <TFT.h>
#include <SPI.h>
 
char tempCelsius[3];
char tempFahrenheit[3];
 
void setup()
{
//setup the LCD
EsploraTFT.begin();
EsploraTFT.background(0,0,0); 
EsploraTFT.stroke(255,255,255);
EsploraTFT.setTextSize(2);
EsploraTFT.text("Temperature",0,0);
 
}
 
void loop()
{
// read the temperature sensor in Celsius, then Fahrenheit:
String celsius = String(Esplora.readTemperature(DEGREES_C));
String fahrenheit = String(Esplora.readTemperature(DEGREES_F));
celsius.toCharArray(tempCelsius, 3);
fahrenheit.toCharArray(tempFahrenheit, 3);
EsploraTFT.stroke(255,255,255);
EsploraTFT.text(tempCelsius, 0, 30);
EsploraTFT.text(tempFahrenheit, 0, 60);
// wait a second before reading again:
delay(1000);
EsploraTFT.stroke(0,0,0);
EsploraTFT.text(tempCelsius, 0, 30);
EsploraTFT.text(tempFahrenheit, 0, 60);
}

 

Links
Atmega32U4 Esplora Game Board Module Leonardo Updated Version FZ0606 Free Shipping

1.8 inch TFT LCD For Arduino Esplora