Skip to content
My Account

HomeKit

A HomeKit Thermostat Built on esp32-homekit

A community project: a HomeKit thermostat with a touch screen on an ESP32-C6, built by jozefcipa on the esp32-homekit library, and an invitation to build with it yourself.

  • ESP32
  • HomeKit
  • 3 min read
No ratings yet, be the first.

Open source is at its best when someone takes your work and builds something you never planned. This thermostat is one of those projects: a HomeKit thermostat on an ESP32, with a touch screen, made by jozefcipa on GitHub, and built on the esp32-homekit library from this site.

He got in touch with me himself, to point out what he had built, and I was glad to share it. All credit for the thermostat goes to its author. This article describes what he made, links to his work, and hopes to encourage you to build something with esp32-homekit too.

Why he built it

According to the author, a thermostat that supports HomeKit usually costs $150 or more, so he decided to build one himself, and says it cost him less than $40. He wrote about how it came together in a blog post, and the code is on GitHub.

What it does

FeatureDetails
Touch screenA 2.4 inch colour LCD with a touch screen, where you set the temperature you want
HomeKitThe thermostat is an accessory in the Home app, built on esp32-homekit
Two-way syncChange the temperature in the Home app or on the screen, and the other follows
HeatingA relay switches a boiler on when the room is colder than the target, and off again when it is warm enough
TimeThe clock is kept right over the internet with NTP
SetupWiFi is set up from a phone over Bluetooth Low Energy, without typing the password in the firmware

The hardware

PartWhat it is for
ESP32-C6 boardThe brain, with WiFi and Bluetooth LE
SHT40 sensorMeasures the temperature and humidity every minute, over I²C
5 V relay moduleSwitches the boiler
2.4 inch ILI9341 touch displayThe screen, on SPI, shared with its touch controller

The sensor is on GPIO 6 for SDA and GPIO 7 for SCL, and the relay input on GPIO 12. If you want to know more about the sensor family, see the SHT sensor series guide.

The screens and the setup

The interface is built with the LVGL library and has three screens. The first is the WiFi setup screen, shown when the thermostat starts for the first time. Once a network is chosen, a loading screen shows what the device is doing, and if the WiFi connection fails five times it offers a button to start the setup again. The main screen shows the room temperature, the date and time, and the temperature you want.

Setting it up takes two steps. First you give the thermostat your WiFi credentials with a Bluetooth provisioning app on your phone, by scanning the QR code on the screen. After that you add it to the Home app with a second code. They cannot be one step, because Apple does not support WiFi provisioning for custom HomeKit devices that are not MFi certified.

What it is built on

The project uses esp32-homekit by Achim Pieters for the HomeKit part, the i2cdev and sht4x components by UncleRus for the sensor, and the lv_qrcode library from LVGL for the QR codes on the screen.

Build your own

Want to build something with esp32-homekit? A good place to start is ESP32 HomeKit for total beginners, which takes you from an empty computer to a working accessory, followed by ESP32 HomeKit Development with ESP-IDF. For a bigger example that uses the library, look at the ESP32 HomeKit Sunshade. And for an older thermostat on an ESP8266, see the ESP8266 HomeKit Thermostat.

If you build something with the library, whatever it is, tell me about it. It is great to see what other people make with it.

Good to know

  • This is another person’s project. The thermostat, its code and its pictures belong to its author, so this article only describes it and links to it. The repository carries no licence file, so ask the author before you reuse anything from it.
  • The thermostat is a fork on this site’s GitHub account, and the original is the one linked above.

The original is at jozefcipa/homekit-thermostat and the author’s write-up is his blog post.

Advertisement
All HomeKit

More HomeKit

Keep building.

Switches, sensors, plugs and blinds: more accessories that you build yourself and add to the Home app.

All HomeKit