ESP32 & ESP8266

Build a Subscription-Free ESP32 Smart Thermostat for Your Home

Build a Subscription-Free ESP32 Smart Thermostat for Your Home

Parts list first: one ESP32 dev board, a temperature sensor such as a DHT22 or SHT31, a 0.96-inch I2C OLED, a rotary encoder with push button, a relay module with 2 or 3 channels, and a buck converter that takes 24 V down to 5 V. Add a breadboard and jumper wires and the whole kit lands under PHP 1,500 at circuit.rocks. That is the entire bill of materials behind the open source smart thermostat that YouTuber Designing Good Ideas built, as covered on Hackster.

Why build one at all

The maker got tired of thermostats that ship with a free app, then lock the useful features behind a monthly fee a year later. A mechanical thermostat is just a bimetallic strip closing a contact for heat, fan or cooling; a digital one swaps the strip for a sensor and a microcontroller. Put a Wi-Fi radio on that microcontroller and you already have 90 percent of a “smart” thermostat with zero recurring cost.

How the hardware goes together

The ESP32 reads the sensor over I2C (SDA on GPIO 21, SCL on GPIO 22 by default) and draws the setpoint on the OLED, which shares the same bus. The rotary encoder feeds two GPIO inputs plus one for the button, and the usual gotcha is contact bounce, so debounce in code or add 100 nF caps across the pins. Each relay channel stands in for the old switch contact: one closes the heat circuit, one the fan, one the compressor. The buck converter sips power from the 24 V line on the furnace control board, so nothing needs a wall adapter.

Control logic lives on the chip. A rule like “turn the heater on when the room drops under 70 F and the last cycle ended more than 5 minutes ago” is a dozen lines of Arduino code, and daily schedules fit in a small array stored in flash. For the extras, remote control and presence-based setbacks, the board exposes itself to Home Assistant through Matter. From there a free automation can raise the cooling setpoint to 78 F when every phone leaves the house.

  • Keep the relay board on its own 5 V rail; relay coils cause brownouts on the ESP32 if they share a thin trace.
  • Read the sensor every 10 seconds and average 6 readings before acting, or the relay will chatter.
  • Put a 2 degree hysteresis band around the setpoint so heat and cool never fight.

Adapting it for a Filipino home

Few houses here have a furnace with a 24 V thermostat wire. Most of us run a split-type aircon from an IR remote, so swap the relay for a 940 nm IR LED on a transistor and send the unit’s own codes with the IRremoteESP8266 library. The sensor, OLED, encoder and Home Assistant side stay the same, and you end up with a thesis-grade energy saver for a dorm room. Start with the sensor and display, get the setpoint logic working on the bench, and only then wire anything to the aircon.

Frequently Asked Questions

How does this DIY thermostat switch the heater or aircon?

Relay channels stand in for the mechanical thermostat contacts, one each for heat, fan and cooling. The ESP32 closes a relay when the room temperature crosses the setpoint, with a hysteresis band to stop chatter.

What parts and skills do I need?

An ESP32, a temperature sensor, a 0.96-inch OLED, a rotary encoder, a relay module and a 24 V to 5 V buck converter, roughly PHP 1,500 in parts. You need basic I2C wiring, Arduino coding, and care around the HVAC or aircon power side.

What will I learn if I build this?

You practice reading sensors over I2C, debouncing a rotary encoder, writing control logic with hysteresis, driving relays or IR LEDs safely, and linking a device to Home Assistant through Matter. All of that maps directly onto IoT and energy-monitoring thesis projects.

This article was inspired by reporting from Hackster. Find the parts and modules to build it at Circuitrocks.

// written by Ann Arandia

Ann Arandia covers community projects and maker events for the Circuitrocks blog. She writes about local workshops, kid-friendly electronics, and the Philippine maker scene — the people, the meet-ups, the projects that come out of them.