Over a million developers have joined DZone.

ESP8266 WiFi Touchscreen Thermostat

DZone 's Guide to

ESP8266 WiFi Touchscreen Thermostat

Learn to make your own touchscreen thermostat controlled by WiFi with this guide to the parts and code required to build it from scratch.

· IoT Zone ·
Free Resource

In this tutorial, we will show how to build a WiFi touchscreen thermostat. This ESP8266 WiFi touchscreen thermostat is an example of complex sensor build by ESP8266, Arduino Mega 2560 and TFT 3.2" touch screen display. The thermostat is connected to EasyIoT Cloud and can be controlled over the internet.

 Main Features

  • 6 modes - Auto, Off, LOLO, LO, HI, HIHI.
  • Touchscreen.
  • WiFi connected.
  • Four set temperatures (LOLO, LO, HI, HIHI) and weekly schedule.
  • Time display.
  • Additional data display - temperature in another room, air pressure, and weather forecast.
  • Connected to EasyIoT Cloud and can be controlled in a WEB interface or native mobile application over the internet.


-Arduino Mega 2560 $9.97, $8.68

-ESP8266 WiFi Module

ESP8266 ESP-01 Serial WIFI Wireless Transceiver Module $2.19, $17.00

          ESP8266 ESP-03 Serial WIFI Wireless Transceiver Module $2.07, $2.15

ESP8266 ESP-12 Serial WIFI Wireless Transceiver Module $2.08, $1.95

ESP8266 ESP-05 Serial WIFI Wireless Transceiver Module $1.88, $3.89

ESP8266 ESP-07 Serial WIFI Wireless Transceiver Module $2.18, $1.87

-BMP180 Digital Barometric Pressure Sensor

BMP180 Digital Barometric Pressure Sensor $1.59, $1.49

-DHT22 Digital Temperature and Humidity Sensor

DHT22 Digital Temperature And Humidity Sensor $2.72, $2.52

-1 Channel Isolated 5V Relay Module

1 Channel Isolated 5V Relay Module $1.34, $0.58

-RTC DS1302 Real Time Clock Module 

RTC DS1302 Real Time Clock Module $0.99, $0.84 

-3.2" TFT LCD Module Touch Panel+ TFT 3.2" LCD Shield Expansion Board for Arduino

3.2 TFT LCD + 3.2 TFT LCD Shield $22.99, $16.77 



Arduino Mega 2560 TFT Display

This is easy, because we will use a shield. Just put the TFT 3.2" LCD Shield Expansion Board and 3.2" TFT LCD Module Touch Panel on top of the Arduino Mega 2560.


ESP8266 is used as the WiFi gateway to EasyIoT Cloud. It is loaded with firmware written in Arduino IDE. In this case, we will use HW serial1 on Arduino Mega 2560 to connect the module. Follow it to connect the ESP module to the Arduino. The Arduino Serial1 RX pin is 19, Tx 18 and the Reset pin is 12. For the 3.3V power supply, we will use the 3.3 V from the TFT shield expansion board. See the picture below for where to connect the 3.3 V.


ArduinoBMP180 module VCC VCC GND GND 20 SDA 21 SLC


ArduinoDHT22 VCC 1 VCC GND 4 GND 8 2 DATA

Relay Module

The relay module input is connected to pin 51 on the Arduino. We also connect VCC and GND.

RTC DS1302

ArduinoDS1302 VCC VCC GND GND 11 CE 10 IO 9 CLK

Source Code

Additional libraries are here.

ESP8266 source code can be found on GitHub. Upload the program with the ESP8266 Arduino IDE. If you are using ESP-01, then keep DEBUG in the comments. To enable DEBUG to use the ESP8266 NODE MCU, which allows one additional software serial.

The Arduino Mega 2560 program is available on GitHub

Before you upload the program to the Arduino, it is recommended to change the following lines:


Set the access point name and password and EasyIoT Cloud username and password. You can later set those settings on the thermostat touch screen (Settings->WiFi Cloud), but it's easier to change it in the program. The program will automatically add the thermostat to the EasyIoT Cloud and configure the module parameters. Of course, you need to register to EasyIoT Cloud first. 

Configure EasyIoT Cloud


Our thermostat also shows the temperature and humidity in another room and outside. First, add those modules to EasyIoT Cloud. Add three automation programs to forward the value of the sensors (temperature 1, humidity 1 and temperature 2) to the thermostat. In automation (Configure->Automation), add a new program and select the program type to "Forward value." Then select the appropriate module and parameter to forward values. The thermostat parameters are as follows:

Sensor.Parameter4 - temperature 1

Sensor.Parameter5 - temperature 2

Sensor.Parameter6 - humidity 1

Future Improvements

This is the first version of the thermostat. For future versions, there is an idea to add multiple zones to the thermostat. Also, the display graphic design is basic. If we use an SD card attached to the TFT display, we can create screens with nice graphics.

iot ,tutorial ,arduino

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}