Introduction: ESP8266 WiFi Touch Screen Thermostat (EasyIoT Cloud)

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
  • Time display
  • Connected to EasyIoT Cloud and can be controlled in WEB interface or native mobile application over internet

Step 1: Materials

  • Arduino Mega 2560
  • ESP8266 WiFi module
  • BMP180 Digital Barometric Pressure Sensor
  • DHT22 Digital Temperature And Humidity Sensor
  • 1 Channel Isolated 5V Relay Module
  • RTC DS1302 Real Time Clock Module
  • 3.2" TFT LCD Module Touch Panel+ TFT 3.2" LCD Shield Expansion Board

Step 2: 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 ESP8266 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

Step 3: Source Code

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.

Additional libraries are here: lib.

Step 4: 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