The WiFi_Thermostat and WiFi_Thermostat_mDNS firmware is available in English language for the ESP32 and ESP8266 microcontrollers (Espressif Systems). Experimental version of basic Thermostat firmware with manual output control is only available in the Slovak language.
Support the WiFi thermostat project via PayPal. Support will allow you to add new features in the future and open the source code of the application: PayPal donate
The software implementation is meticulously crafted for microcontroller platforms provided by Espressif Systems, featuring robust WiFi connectivity. Specifically, it seamlessly supports ESP8266 microcontrollers in versions 12E to F, commonly found in Wemos D1 Mini and NodeMCU v2/v3 platforms.
Please note that ESP8266-01/ESP8266-01S microcontrollers and similar standalone chips predating the 12E generation are not compatible with the project's program recording requirements. They do not utilize the DIO flash method, essential for ESPTOOL calls in the project. Uploading firmware to these devices is not supported.
For the ESP32 microcontroller, standalone chips like ESP32-WROOM-32 from Espressif and the equivalent ESP-32S from AI-Thinker can be utilized. All DevKits associated with these chips, including DevKit v1/DevKitC-v4, are fully compatible.
The WiFi thermostat is seamlessly accessible within the LAN network where it is situated, equipped with an intuitive web interface for configuring all thermostat elements. Operating independently of the web application, the thermostat efficiently manages the boiler based on the measured and target temperature, along with hysteresis.
To enhance accessibility, the thermostat can be complemented with an mDNS record, generating a local domain (hostname.local) accessible exclusively within the LAN network via multicast service.
Connectivity configuration for the thermostat on the home WiFi LAN network is facilitated by WiFiManager, securely storing WiFi network data (SSID and password) in the microcontroller's flash memory. The one-time storage ensures persistent configuration memory, allowing full utilization of the thermostat upon gaining connectivity.
Running on the ESP8266/ESP32 microcontroller, the HTTP web server supports multiple independent HTML pages, offering both informative and functional content.
In terms of hardware, the project uses:
ESP8266 / ESP32
DS18B20 temperature sensor on the OneWire bus
Relay SRD-5VDC-SL-C / OMRON G3MB-202P used for boiler switching (Active-LOW signal)
HTML pages running on ESP8266 / ESP32 platform:
/ - root page containing form, current logic output for relay, current and target temperature, hysteresis
/action.html - processes values from the form, writes them to the emulated EEPROM memory, redirects the user back to the root page
/get_data.json - distributes data on current temperature, reference temperature and hysteresis to a third party (computer, microcontroller, other client ...) in JSON format - can be used with an example JSON client that can send data to MQTT Broker, for example to home automation
and other system subpages to control the output, change the mode
The DS18B20 sensor boasts a 12-bit measurement resolution, providing precision at 0.0625 °C increments. The OneWire bus efficiently returns data to the microcontroller within 500 to 1000 ms upon request.
The SRD-5VDC-SL-C electromagnetic relay, a key component in the project, facilitates switching up to 10A at 230V, translating to a power capacity of 2300W. When handling a DC circuit (load), it supports up to 300W (10A at 30V DC). Alternatively, the OMRON G3MB-202P SSR relay is fully compatible with the wiring diagram, designed exclusively for non-inductive loads and AC circuits, with a maximum switching power of 460W (230V, 2A).
The thermostat is designed for year-round use. If control is unnecessary, the output can be physically disconnected, transforming the thermostat into a WiFi thermometer for data retrieval from its location.
The thermostat's logic operates independently every 10 seconds, unrelated to the web server or connected clients, eliminating the need for a keep-alive connection. With each logic execution, the thermostat logs information about the current IP address or mDNS record (if applicable) on the UART thermostat, providing users with accessibility details within the LAN network.
Furthermore, it displays dynamic free memory (HEAP), ranging from 40 to 44kB, and the current output state with notifications of changes, such as when the decision threshold exceeds + or -.
The 3V3 GPIO operating logic of ESP8266 and ESP32 microcontrollers suffices for digital signal changes, but it's crucial to power the relay with 5V from VUSB and VIN, respectively.
Web interface for WiFi thermostat allows:
View in real time the temperature from the DS18B20 sensor, the device uptime, the output value with dynamic change, the currently set configuration data for the thermostat, i. target temperature and hysteresis
Modify the target (reference) temperature in the range of 5 to 50 °C with a 0.25 °C step
Modify hysteresis in the range of 0 to 10 °C with a 0.25 °C step
Program implementation of a thermostat with automatic mode is experimental!
Boiler ON / OFF control - automatic mode:
Example ON / OFF of heating control - VISUALIZATION IS NOT PART OF THE PROJECT
The boiler is active until the target temperature + hysteresis is reached
The visualization of water temperatures shows the so-called heating run-up and subsequent cooling of the water until the heating activity is repeated, when the measured temperature is below the set target temperature - hysteresis
In the basic version of the WiFi thermostat (without mDNS record), a manual control mode (hard ON / OFF) has been seamlessly integrated, offering the flexibility to switch between manual and automatic modes.
The web interface is meticulously crafted to adapt seamlessly to both larger and smaller screens, ensuring a responsive design that caters to widescreen high-definition displays and mobile devices alike.
To enhance performance and efficiency, the interface leverages imported CSS styles from the Bootstrap framework, sourced from an external CDN server. This approach optimally loads client-side resources when accessing pages running on the ESP microcontroller.
By importing CSS styles from an external server, the WiFi thermostat efficiently mitigates power and memory load on the microcontroller, ensuring a smooth and responsive user experience.
To ensure the persistence of thermostat settings even after a power outage, they are stored in the ESP's EEPROM memory, emulated within the flash memory due to the absence of a physical EEPROM chip on the platform.
The reference temperature is assigned to offset 10, while the hysteresis is stored at offset 100. Each value utilizes a maximum of 5 bytes in the EEPROM memory, including the end character. Data overwriting occurs exclusively when the HTML form is submitted, ensuring a gentle operation that prolongs the EEPROM memory's durability.
The output state exclusively resides in RAM memory, with no storage in the flash memory. Upon the device's initial startup, if there's no existing data on the mentioned EEPROM offsets, an automatic writing process initiates with default values—reference temperature: 20.25 °C, hysteresis: 0.00 °C, providing a fail-safe solution.
ESP8266 and ESP32 utilize the EEPROM.put() function coupled with EEPROM.commit() for EEPROM memory read and write operations, respectively. Additionally, EEPROM.get() is employed to retrieve data from EEPROM, supporting any data type, including float() in our specific case. This comprehensive approach ensures efficient and reliable EEPROM memory management for the thermostat.
Utilizing the Refresh meta tag, the web server systematically refreshes the entire page every 30 seconds. To enhance user experience, an approximate time for the upcoming refresh is dynamically inscribed into the HTML page using Javascript.
It is imperative to apply any changes for the thermostat within this timeframe; otherwise, numerical input windows in the form may reset upon page refresh.
Due to the limitations of the built-in Ethernet library, which lacks support for an asynchronous web server (commonly used with microcontrollers such as Espressif ESP8266 / ESP32), a page rewrite becomes necessary to accommodate the constraints of the current implementation. This ensures a seamless and uninterrupted operation of the thermostat interface.
The dynamic data that undergoes frequent changes primarily includes the current output status - Turned on / Turned off, providing operators with real-time information about the output state, visually indicated through color coding.
Due to the system logic operating independently of the web server, the output status may differ from the information presented in the web application. Immediate updates reflecting any change in the output are promptly communicated on the UART monitor.
Additionally, the thermostat's website offers users insights into the device's uptime, showcasing the duration it has been operational, expressed in days, hours, minutes, and seconds. The thermostat is exclusively designed for indoor temperatures! (above 0 °C), with the system logic finely tuned to accommodate these conditions.
Versatile in application, the thermostat can seamlessly replace an existing room thermostat or serve as a temporary substitute for an aquarium/terrarium heater, ensuring a consistent and controlled temperature.
The author of the WiFi thermostat is not responsible for the functionality of the thermostat, boiler failure, electric shock due to improper installation of the thermostat in the network. The thermostat is distributed under the MIT license.
Main page for modification of target temperature and hysteresis - example of switched on output:
Sample data
Target temperature: 22.75 °C
Hysteresis: 0.25 °C
Measured data: 22.49 °C
Output: ON
The thermostat initiates heating when the measured temperature falls to 22.49 °C and below. Upon reaching 23.01 °C, the output is disengaged, the signaling relay opens, and the gas boiler ceases heating, marking the onset of a cooling phase for the room where measurements are conducted.
The thermostat remains inactive until the temperature drops to 22.49 °C or lower, thereby triggering a new heating cycle. This precise temperature control ensures optimal comfort and energy efficiency in maintaining the desired room temperature.
Main page for target temperature and hysteresis modification:Processing of datas that user entered by HTML form:JSON web server output in browser / client via websocket:
Output to UART monitor - system logic + set IP address, mDNS record:
Available libraries for microcontrollers (ESP)
Library archive (.zip) expand to C:/Users/[User]/Documents/Arduino/libraries
Library name
Library function
Download
Dallas
Library for ESP8266 and ESP32 microcontrollers.
It allows communication with the Dallas DS18B20 sensor on the OneWire bus. Possibility of communication after normal or parasitic connection.
Library for ESP8266 and ESP32 microcontrollers.
Creates an access point (AP) and Captive portal for configuring a WiFi thermostat on a home WiFi network.