ESP8266 WiFi Touchscreen Thermostat
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.
Join the DZone community and get the full member experience.Join For Free
Digi-Key Electronics’ Internet of Things (IoT) Resource Center Inspires the Future: Read More
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.
- 6 modes - Auto, Off, LOLO, LO, HI, HIHI.
- 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.
-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 for Arduino
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
The relay module input is connected to pin 51 on the Arduino. We also connect VCC and GND.
ArduinoDS1302 VCC VCC GND GND 11 CE 10 IO 9 CLK
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:
#define DEFAULT_AP_SSID "XXXX" #define DEFAULT_AP_PASSWORD "XXXX" #define DEFAULT_CLOUD_USERNAME "XXXX" #define DEFAULT_CLOUD_PASSWORD "XXXX"
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
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.
Published at DZone with permission of Igor Jarc , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.