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

 

Main features of thermostat

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

 

 

 

Materials

-Arduino Mega 2560

Arduino Mega 2560Arduino Mega 2560
$9.97
$6.99

 

-ESP8266 WiFi module

ESP8266 ESP-01 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-01 Serial WIFI Wireless Transceiver Module
$2.11
$17.00
ESP8266 ESP-03 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-03 Serial WIFI Wireless Transceiver Module
$2.07
$2.15
ESP8266 ESP-12 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-12 Serial WIFI Wireless Transceiver Module
$2.06
$1.75
ESP8266 ESP-05 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-05 Serial WIFI Wireless Transceiver Module
$1.88
ESP8266 ESP-07 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-07 Serial WIFI Wireless Transceiver Module
$2.18
$1.88

 

-BMP180 Digital Barometric Pressure Sensor

BMP180 Digital Barometric Pressure SensorBMP180 Digital Barometric Pressure Sensor
$1.22
$1.29

 

-DHT22 Digital Temperature And Humidity Sensor

DHT22 Digital Temperature And Humidity SensorDHT22 Digital Temperature And Humidity Sensor
$2.67
$2.45

 

-1 Channel Isolated 5V Relay Module

1 Channel Isolated 5V Relay Module1 Channel Isolated 5V Relay Module
$1.34
$1.12

 

-RTC DS1302 Real Time Clock Module 

RTC DS1302 Real Time Clock Module RTC DS1302 Real Time Clock Module
$0.99
$0.82

 

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

3.2 TFT LCD + 3.2 TFT LCD Shield3.2 TFT LCD + 3.2 TFT LCD Shield
$22.99
$15.45

 

See buying guide at the end for details and please shop in our store to support EasyIoT framework.

 

Build

Connections

Arduino Meaga 2560 TFT display

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

ESP8266

ESP8266 is used as 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 ESP8266 module. Follow Connenct 5V Arduino and ESP8266 tutorial to connect ESP module to Arduino. Arduino Serial1 RX pin is 19, Tx 18 and Reset pin is 12. For 3.3V power supply we will use 3.3 V from TFT shield expansion board. See picture below where to connect 3.3 V.

BMP180 

Arduino BMP180 module
VCC VCC
GND GND
20 SDA
21 SLC

DHT22

Arduino DHT22
VCC 1 VCC
GND 4 GND
8 2 DATA

Relay module

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

RTC DS1302

Arduino DS1302
VCC VCC
GND GND
11 CE
10 IO
9 CLK

Source Code

Additional libraries are here: lib.

ESP8266 source program 

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

Arduino Mega 2560 program

Arduino Mega 2560 program is available at GitHub

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


#define DEFAULT_AP_SSID "XXXX"
#define DEFAULT_AP_PASSWORD "XXXX"
#define DEFAULT_CLOUD_USERNAME "XXXX"
#define DEFAULT_CLOUD_PASSWORD "XXXX"

 

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

Configure EasyIoT Cloud

Automation

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

Sensor.Parameter4 - temperature 1

Sensor.Parameter5 - temperature 2

Sensor.Parameter6 - humidity 1

 

Future improvements

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

See more tutorials at ​http://iot-playground.com/build​

 

Buying guide

 

To support this site and EasyIoT framework development please buy in our store.

 

Arduino Mega 2560

For bigger Arduino projects.

3.2 TFT LCD + 3.2 TFT LCD Shield

Mega 2560 ATmega2560-16AU Board for arduino + 3.2 TFT LCD + 3.2 TFT LCD Shield

Best price if you need Meaga 2560, TFT screen and shiels.

BMP180 Digital Barometric Pressure Sensor

The BMP180 is the new digital barometric pressure sensor of Bosch Sensortec, with a very high performance.

DHT22 Digital Temperature And Humidity Sensor

The DHT22 is a basic, low-cost digital temperature and humidity sensor.

1 Channel Isolated 5V Relay Module

Be able to control various appliances, and other equipments with large current.

RTC DS1302 Real Time Clock Module

The DS1302 is a Real Time Clock (RTC) or TimeKeeping Chip with a build-in Trickle-Charger

Plastic Project Box Enclosure-6.2

ESP8266 ESP-01 Serial WIFI Wireless Transceiver Module

ESP8266 Serial WIFI Wireless Transceiver Module

ESP8266 ESP-03 Serial WIFI Wireless Transceiver Module

ESP8266 serial WIFI model ESP-03

ESP8266 ESP-12 Serial WIFI Wireless Transceiver Module

ESP8266 serial Port WIFI wireless module ESP-12

ESP8266 ESP-05 Serial WIFI Wireless Transceiver Module

ESP8266 ESP-05 Serial WIFI Wireless Transceiver Module

5V 2A Charger Micro USB

For Raspberry Pi or sensor modules, cheap and easy power solution.


Comments   

#7 Bert Groothuis 2021-07-04 18:42
Hello,

If I verify your code in Arduino IDE i recieve a error message about MQTT *myMqttPtr; (row 107).

This ino I loaded from GITHUB: https://github.com/iot-playground/EasyIoT-Cloud/blob/master/ESP8266_mqtt_serial_gw/ESP8266_mqtt_serial_gw.ino

I tried a lot of Librarys but it won't help.
I don't understand this error.
Please help.

Thanks.
Bert From The Netherlands.
#6 Bederna Laszlo 2019-01-25 18:19
Hello,
I would like build this project, but i have DHT22 module (not only sensor), and serial monitor write DHT reading failed, and false temperature on display. How can i modify the code for DHT22 module?
Thansk and regards
Laszlohttps://components101.com/sensors/dht22-pinout-specs-datasheet

The sensor work perfectly in another application.
+1 #5 Gabor Tercs 2018-12-02 21:28
Hello. This is a great project. I built this and everything seems to work on the hardware part, but I cannot see how to connect to iot-cloud. Can you elaborate a little more, please. I added different modules and also automation, but I do not get any data sent. Can you please do a step by step guide, or at least give some more hints?
Thank you, Gabor
#4 profile 2018-11-01 09:42
Need cheap hosting? Try webhosting1st, just $10 for an year.

#3 Marco 2018-01-09 23:51
Good evening I'm Marco and I'm new. I built the circuit and programmed both arduino and esp8266 the thermostat works but does not connect to the AP I go in "CMD_CONNECT_TO_AP timeout". Can you help me to understand what's wrong?
I scrupulously followed what was written in the project section.
As for ESP8266 I use a D1 Mini I updated it with the firmware "v0.9.5.2 AT Firmware"
Thanks in advance.
#2 Super User 2017-11-06 10:36
Quoting Joe:
Can you confirm, does this project work for heating and cooling or just heat?



For heating only. You can easy modify this project and add additional DO output to control cooling.
#1 Joe 2017-10-18 15:44
Can you confirm, does this project work for heating and cooling or just heat?

You have no rights to post comments

Forum latest

  • No posts to display.