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
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.