---
title: "esp32-local-thermostat"
url: "https://maker.wiznet.io/scarlet/projects/esp32-local-thermostat/"
markdown_url: "https://maker.wiznet.io/scarlet/projects/esp32-local-thermostat/md"
type: "UCC: User Created Content"
author: "RomLab"
author_url: "https://github.com/RomLab/esp32-local-thermostat"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "RomLab"
original_url: "https://github.com/RomLab/esp32-local-thermostat"
published: "2023-08-01"
language: "en"
hardware: ["WIZnet W5500"]
likes: 1
views: 318
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# esp32-local-thermostat

> Software (C/C++) for Wall-mounted room temperature sensors. with W5500

Original author: RomLab (source: https://github.com/RomLab/esp32-local-thermostat)

## Components

- **WIZnet W5500** x 1 ([docs](https://docs.wiznet.io/Product/Chip/Ethernet/W5500))

WIZnet parts: W5500 ([Datasheet](https://docs.wiznet.io/Product/Chip/Ethernet/W5500/datasheet?utm_source=maker&utm_medium=project&utm_campaign=w5500), [product hub](https://maker.wiznet.io/products/w5500/))

## Article

This project is an IoT-based application that implements a temperature control system. It utilizes the Dallas DS18B20 temperature sensor to measure real-time temperatures and communicates temperature data with other devices or servers using the MQTT protocol. The system also includes a TFT display to visualize temperature values and display user messages.

Key features and components:

1. Temperature Measurement: Real-time temperatures are measured using the Dallas DS18B20 sensor.

2. MQTT Communication: The MQTT protocol is employed to exchange temperature data with other devices or servers.

3. TFT Display: Temperature values and user messages are displayed on a TFT display.

4. Button Input Handling: The system detects button inputs to interact with the TFT display and adjust temperature values.

5. Timer Functionality: Timers are utilized for automatic TFT display turn-off and periodic temperature sampling.

6. MQTT Subscription and Processing: The system subscribes to MQTT topics to handle real-time temperature requests and temperature value changes.

This project has the potential to be applied in various fields, such as smart home temperature control systems, automated greenhouse management, and HVAC systems. The code offers flexibility and versatile functionalities focused on temperature measurement and control.

---

[**local_thermostat.ino**](https://github.com/RomLab/esp32-local-thermostat/blob/master/local_thermostat/local_thermostat.ino)

[Temperature Control-related Code]

Temperature Measurement and Control: Measures real-time temperature using the Dallas DS18B20 temperature sensor and displays temperature values on the TFT display. Button inputs enable interaction with the TFT display and temperature adjustment. Additionally, it communicates temperature data through MQTT with other devices or servers.

MQTT Communication: Utilizes the MQTT protocol to send temperature data to a broker and subscribes to topics to handle real-time temperature requests and temperature value changes.

Timer Functionality: Includes timers for automatic TFT display turn-off and periodic temperature sampling.

[connection_ethernet.ino](https://github.com/RomLab/esp32-local-thermostat/blob/master/local_thermostat/connection_ethernet.ino)

[Ethernet setup for MQTT]

This code section handles Ethernet setup for MQTT communication, performs connection status checks, and processes incoming MQTT messages for temperature control.

[butto**ns.ino**](https://github.com/RomLab/esp32-local-thermostat/blob/master/local_thermostat/buttons.ino)

[Button Input and Handling-related Code]

Button Input Detection: Detects three buttons for temperature adjustment and TFT display manipulation.

Button Input Timing Handling: Controls TFT display on/off and temperature value changes based on button inputs.

[timers.ino](https://github.com/RomLab/esp32-local-thermostat/blob/master/local_thermostat/timers.ino)

[Timer-related Code]

TFT Display Timer: Manages timers for automatic TFT display turn-off.

Temperature Sampling Timer: Sets and manages timers for periodic temperature sampling.

[ds18b20.ino](https://github.com/RomLab/esp32-local-thermostat/blob/master/local_thermostat/ds18b20.ino)

[Temperature Measurement and Sensor-related Code]

Temperature Sensor Initialization: Initializes the Dallas DS18B20 sensor for temperature measurement.

Temperature Measurement: Measures real-time temperature using the temperature sensor and applies temperature correction.

[mqtt.ino](https://github.com/RomLab/esp32-local-thermostat/blob/master/local_thermostat/mqtt.ino)

[MQTT Communication-related Code]

MQTT Topic Creation: Creates MQTT topics for temperature-related data.

MQTT Communication Setup: Configures settings and subscriptions for MQTT broker communication.

MQTT Message Transmission: Sends temperature values and user messages to the MQTT broker.

MQTT Message Processing: Handles received messages from the MQTT broker, managing temperature requests and temperature value changes.

---

Source: https://maker.wiznet.io/scarlet/projects/esp32-local-thermostat/
