← Stack & Solder ESP32 · HOME AUTOMATION

Building a Room Temperature Display with Automatic AC Control

A complete guide from bare parts to a working automation — including what an IR blaster actually is, how Tuya/SmartLife fits in, and where to buy everything.

ESP32 and DHT22 sensor on a workbench
The finished sensor setup: ESP32 + DHT22, before the display was removed.

What You'll Build

This project reads the real temperature and humidity of a room, sends that data to a home automation system, and uses it to automatically turn a normal (non-smart) air conditioner on and off — no manual remote needed, no schedule guessing. If you've ever left the AC running in an empty room, or come home to a hot house because it wasn't running at all, this fixes that.

By the end of this guide you'll have:

Parts List & Where to Buy

Everything here is easy to find on general electronics marketplaces (Amazon, AliExpress, or local electronics stores — in India, Robu.in and similar sites also stock all of these). Prices vary by region, so shop around.

PartWhat it's for
ESP32 Dev BoardThe "brain" — a small Wi-Fi-capable microcontroller
DHT22 SensorMeasures temperature and humidity
1.3" TFT LCD Display (ST7789 driver)Shows the live temperature and humidity on the device itself
Jumper wires (female-to-female, a handful)Connects the sensor and display to the ESP32 without soldering
Micro-USB or USB-C cablePowers the board and uploads firmware (check which port your board uses)
Wi-Fi IR Blaster (Tuya/SmartLife compatible)Sends remote-control signals to your AC — explained fully below
No soldering required for this build. The DHT22 connects with plug-in jumper wires, and the IR blaster is a separate plug-and-play device — you're only assembling and configuring, not building circuits from scratch.

Part 1: Understanding the IR Blaster (Read This First)

Before wiring anything, it's worth understanding the two "black box" pieces of this project, because they're doing more work than they look like they are.

What is an IR blaster?

Almost every air conditioner remote — like almost every TV remote — talks to its appliance using infrared light, invisible to your eyes but readable by a small sensor on the AC unit. Every button press sends a unique pattern of infrared pulses.

A Wi-Fi IR blaster is a small device — usually a plastic puck about the size of a hockey puck — that does two things:

In other words, it's a universal remote that a computer can control. It doesn't know anything about temperature or automation by itself — it just replays button presses when told to.

What is Tuya / SmartLife?

Tuya is a company that makes generic "smart home" hardware — plugs, bulbs, sensors, and IR blasters — which get sold under many different brand names. If you've ever bought a cheap smart plug from an unfamiliar brand, there's a good chance it's a Tuya device underneath.

SmartLife (and its close sibling, the "Tuya Smart" app) is the mobile app used to set up and control these devices. When you buy a Tuya-based IR blaster, this is the app you'll use first — you connect the blaster to your Wi-Fi through the app, then use the app to "teach" it your AC remote's signals by pointing the real remote at it.

Later, instead of controlling it through the SmartLife app by hand, Home Assistant connects to your Tuya account and can trigger those same learned signals automatically — that's the bridge that makes automation possible.

IR blaster placed with line of sight to an AC unit
The IR blaster needs a direct line of sight to the AC unit's receiver — just like pointing a remote at it.

Setting up the IR blaster, step by step

  1. Download the SmartLife app (or "Tuya Smart") from your phone's app store
  2. Create an account and add the IR blaster device following the app's pairing instructions (usually holding a button until an LED blinks, then connecting via the app)
  3. Once connected, use the app's "Add Remote" or "Air Conditioner" feature — it will ask you to point your real AC remote at the blaster and press specific buttons (like Power) so it can learn the signal
  4. Test it directly in the app first — tap the on-screen power button and confirm the AC responds — before moving on to Home Assistant
  5. Place the blaster somewhere with a clear line of sight to the AC's IR receiver (usually a small dark window on the front of the unit) — the same way you'd need line of sight when using the physical remote

Part 2: Wiring the Temperature Sensor

The DHT22 sensor connects to the ESP32 with just three wires — no resistors or extra components needed for most breakout boards.

Wiring diagram of ESP32 to DHT22 sensor
DHT22 to ESP32 wiring: VCC → 3.3V, GND → GND, DATA → GPIO22.
DHT22 PinConnects to (ESP32)
VCC3.3V
GNDGND
DATAGPIO22

If your DHT22 module is a bare 4-pin sensor (not a breakout board), you'll also need a 4.7kΩ–10kΩ resistor between VCC and DATA. Most breakout boards (the small blue PCBs the sensor is often mounted on) already include this resistor, so check yours before adding one.

Hands connecting jumper wires from a DHT22 sensor to an ESP32 board
Connecting the DHT22 to the ESP32 with jumper wires — no soldering needed at this stage.

Part 3: Wiring the Display

This build uses the same 1.3" TFT LCD (ST7789 driver) as the ESP32 voice assistant project — a small, sharp color display that talks to the ESP32 over SPI. It shows the live temperature and humidity right on the device, so you don't need to open Home Assistant just to check the room.

Wiring diagram of ESP32 to 1.3 inch ST7789 TFT display
ST7789 display wiring — SPI connection to the ESP32.
Display PinConnects to (ESP32)
VCC3.3V
GNDGND
SCL / SCK (clock)GPIO18
SDA / MOSI (data)GPIO23
RES / RST (reset)GPIO4
DC (data/command)GPIO2
CS (chip select)GPIO5
BLK (backlight)3.3V, or a GPIO if you want to control brightness/on-off in software

These pin numbers match the wiring used in the ESP32 voice assistant project — if your display module labels pins slightly differently (some boards swap SDA/SDI naming, for instance), match by function rather than by label name.

Add the display to your ESPHome configuration alongside the sensor, along with a time source so the display can show a live clock:

time:
  - platform: sntp
    id: my_time
    timezone: "Asia/Kolkata"

spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23

display:
  - platform: st7789v
    model: "TTGO TDisplay 135x240"
    cs_pin: GPIO5
    dc_pin: GPIO2
    reset_pin: GPIO4
    rotation: 0
    lambda: |-
      it.strftime(0, 0, id(clock_font), "%H:%M:%S", id(my_time).now());
      it.print(0, 40, id(my_font), "Temp:");
      it.printf(0, 60, id(my_font), "%.1f C", id(bedroom_temp).state);
      it.print(0, 90, id(my_font), "Humidity:");
      it.printf(0, 110, id(my_font), "%.1f %%", id(bedroom_humidity).state);

font:
  - file: "gfonts://Roboto"
    id: my_font
    size: 20
  - file: "gfonts://Roboto"
    id: clock_font
    size: 28

The sntp time platform syncs the clock automatically over the internet once the ESP32 connects to Wi-Fi — no Home Assistant connection needed for the clock specifically. Set timezone to your own region using the standard tz database name (e.g. Asia/Kolkata for India).

Match the display model to your exact board. "ST7789" is a display driver chip used across many differently-sized and differently-wired boards, so the exact model line and resolution can vary. Check your display's datasheet or product listing, or reuse the working config from a previous ST7789 project if you have one, and adjust the resolution/rotation to match.

You'll also need to give the temperature and humidity sensors from Part 1 fixed IDs (e.g. id: bedroom_temp) so the display's lambda block above can reference their live values directly on the device, without needing Home Assistant to be involved at all.

Part 4: Flashing the ESP32

This build uses ESPHome, a tool that lets you describe your device in a simple text file instead of writing full code. It handles Wi-Fi, over-the-air updates, and Home Assistant integration automatically.

ESP32 board connected via USB cable to a laptop during firmware flashing
First flash needs a USB cable — every update after that can go out over Wi-Fi.

Install the ESPHome dashboard (it runs in your browser, or as a Home Assistant add-on if you're already running Home Assistant), then create a new device using this configuration:

esphome:
  name: bedroom-room-display

esp32:
  board: esp32dev
  framework:
    type: arduino

wifi:
  ssid: "YOUR_WIFI_NAME"
  password: "YOUR_WIFI_PASSWORD"

sensor:
  - platform: dht
    pin: GPIO22
    model: DHT22
    temperature:
      name: "Bedroom Room Display Room Temperature"
    humidity:
      name: "Bedroom Room Display Humidity"
    update_interval: 60s

api:
ota:
Replace the placeholders with your real Wi-Fi detailsYOUR_WIFI_NAME and YOUR_WIFI_PASSWORD are stand-ins so this guide doesn't show anyone's actual network. Just type your real Wi-Fi name and password directly in place of them on your own device.

Connect the ESP32 to your computer or phone via USB, select it in the ESPHome dashboard, and click Install. The first flash needs a cable; every update after that can be sent wirelessly (OTA).

Part 5: Connecting to Home Assistant

If you're running Home Assistant (see the full setup guide if you haven't installed it yet), the new ESP32 device should appear automatically as a discovered device (Settings → Devices & Services). Add it, and you'll get two live entities:

These update every 60 seconds and are now available to build automations from.

Home Assistant dashboard showing the live temperature and humidity entities
The two new sensor entities showing up live in Home Assistant.

Separately, connect your Tuya/SmartLife account to Home Assistant through the Tuya integration (Settings → Devices & Services → Add Integration → Tuya). Once linked, the IR signals you learned earlier become "scenes" you can trigger from Home Assistant — in this build, they're named scene.air_on and scene.air_off.

Part 6: The Automation Logic

The simple version of this automation sounds easy: "turn on the AC when the temperature goes above 26°C." But a naive version of that rule has a real flaw.

Home Assistant's temperature-based triggers are edge-triggered — they only fire at the exact moment the temperature crosses the threshold. If Home Assistant restarts, or briefly loses connection right when that crossing happens, the automation can miss it entirely — and the AC gets stuck in the wrong state with nothing to correct it.

The fix is to add a second, time-based trigger that re-checks the condition every few minutes, so the system corrects itself even if it missed the original moment:

automation:
  - alias: "AC Auto Control"
    trigger:
      - platform: numeric_state
        entity_id: sensor.bedroom_room_display_room_temperature
        above: 26
      - platform: time_pattern
        minutes: "/5"
    condition:
      - condition: numeric_state
        entity_id: sensor.bedroom_room_display_room_temperature
        above: 26
      - condition: state
        entity_id: input_boolean.ac_should_be_on
        state: "off"
    action:
      - service: scene.turn_on
        target:
          entity_id: scene.air_on
      - service: input_boolean.turn_on
        target:
          entity_id: input_boolean.ac_should_be_on

A mirrored automation handles turning the AC off once the temperature drops back down. The input_boolean.ac_should_be_on helper matters more than it looks — IR blasters are one-way devices, so Home Assistant has no way to ask the AC "are you actually on right now?" This helper is Home Assistant's own memory of what it last told the AC to do, and the automation relies on it to avoid sending redundant or conflicting signals.

Part 7: Living With It — and Simplifying Later If You Want

With the display wired up and the automation running, you get both: a live readout on the device itself, and a fully hands-off AC. In practice, once the automation has proven itself reliable, the on-device number becomes less necessary day-to-day — Home Assistant is already making the decisions, and the display is mostly a nice-to-have for a glance-and-check.

That's exactly what happened with this build over time: after the automation was trusted, the physical display was removed and the firmware simplified back down to sensor-only. This isn't a required step — it's just worth knowing it's a reasonable option later, rather than something you have to decide now. Build it with the display first; simplify only if you find you want to.

Finished ESP32 sensor and display mounted on a bedroom wall
The finished build, mounted and running — showing live temperature while the AC automation runs quietly in the background.

Troubleshooting

AC turns on or off at the wrong time after a restart. This is the edge-trigger issue from Part 5 — make sure the time-based secondary trigger is included.

Sensor shows "unavailable" in Home Assistant. Usually a loose DATA wire or a Wi-Fi drop. Check the ESPHome logs first — DHT22 sensors are sensitive to shaky jumper connections.

IR signal isn't reaching the AC. Reposition the blaster for a clearer, more direct line of sight to the AC's receiver window. A reflective wall behind the AC can sometimes help bounce the signal if a direct line isn't possible.